Skip to content

Instantly share code, notes, and snippets.

View nfsarmento's full-sized avatar

NS nfsarmento

View GitHub Profile
@nfsarmento
nfsarmento / functions.php
Last active March 13, 2023 19:45 — forked from dibakarjana/functions.php
Wordpress: Send Email after any Post type status change
/**
*
* https://codex.wordpress.org/Post_Status_Transitions
*
* Send email to admin after user create new product from frontend form.
* Send emails on products publication
* @param WP_Post $post
*
*
*/
@nfsarmento
nfsarmento / addinfunctions.php
Created January 30, 2023 20:34 — forked from neilgee/addinfunctions.php
Gravity Form Word Count
<?php
/* Gravity Forms Word Count Script */
function els_load_scripts() {
wp_enqueue_script('gravity-forms-word-count', get_stylesheet_directory_uri() . '/js/jquery.gravity_word_count.js', array('jquery'), '0.1', true);
}
add_action('wp_enqueue_scripts', 'els_load_scripts');
/*Then in the form, for fields that need the word count, add the class ‘els-word-count[300].' Change [300] as needed for the maximum words that can be added to that particular field.*/
/*Source http://www.gravityhelp.com/forums/topic/maximum-word-count#post-149331*/
@nfsarmento
nfsarmento / NPM installation requirements
Created June 6, 2022 11:21 — forked from kompuser/NPM installation requirements
Roots Sage Gulpfile Including Critical CSS and CombineMQ
npm install --save asset-builder browser-sync del gulp gulp-autoprefixer gulp-changed gulp-concat gulp-cssnano gulp-flatten gulp-if gulp-imagemin gulp-jshint gulp-less gulp-plumber gulp-rename gulp-rev gulp-sass gulp-sourcemaps gulp-uglify imagemin-pngcrush jshint jshint-stylish lazypipe merge-stream minimist run-sequence traverse wiredep gulp-util gulp-combine-mq critical gulp-rename gulp-penthouse
@nfsarmento
nfsarmento / 01-gulpfile.js
Created June 3, 2022 19:32 — forked from markgoodyear/01-gulpfile.js
Comparison between gulp and Grunt. See http://markgoodyear.com/2014/01/getting-started-with-gulp/ for a write-up.
/*!
* gulp
* $ npm install gulp-ruby-sass gulp-autoprefixer gulp-cssnano gulp-jshint gulp-concat gulp-uglify gulp-imagemin gulp-notify gulp-rename gulp-livereload gulp-cache del --save-dev
*/
// Load plugins
var gulp = require('gulp'),
sass = require('gulp-ruby-sass'),
autoprefixer = require('gulp-autoprefixer'),
cssnano = require('gulp-cssnano'),
@nfsarmento
nfsarmento / yz-send-bp-welcome-msg.php
Created March 31, 2021 10:27 — forked from KaineLabs/yz-send-bp-welcome-msg.php
Send Buddypress Welcome Message !
<?php
//send a welcome email when a user account is activated
add_action( 'bp_core_activated_user', 'yz_welcome_user_notification', 10, 3 );
function yz_welcome_user_notification( $user_id, $key = false, $user = false ) {
if ( is_multisite() ) {
return ;// we don't need it for multisite
}
//send the welcome mail to user
@nfsarmento
nfsarmento / wg_install.sh
Created July 16, 2020 18:07 — forked from Anachron/wg_install.sh
A script to spin up a Wireguard VPN server with Unbound recursive DNS in a hurry
#!/bin/bash
# This file is designed to spin up a Wireguard VPN quickly and easily,
# including configuring a recursive local DNS server using Unbound
#
# Make sure to change the public/private keys before running the script
# Also change the IPs, IP ranges, and listening port if desired
# iptables-persistent currently requires user input
# add wireguard repo
sudo add-apt-repository ppa:wireguard/wireguard -y
@nfsarmento
nfsarmento / bitbucket-pipelines.yml
Created May 5, 2020 13:00 — forked from mcnamee/bitbucket-pipelines.yml
Bitbucket Pipelines - Deploy via FTP to shared hosting
# Installation ---
# 1. In Bitbucket, add $FTP_USERNAME $FTP_PASSWORD and $FTP_HOST as environment variables.
# 2. Commit this file to your repo
# 3. From Bitbucket Cloud > Commits > Commit Number > Run Pipeline > Custom:Init (this will
# push everything and initial GitFTP)
#
# Usage ---
# - On each commit to master branch, it'll push all files to the $FTP_HOST
# - You also have the option to 'init' (from Bitbucket Cloud) - pushes everything and initialises
# - Finally you can also 'deploy-all' (from Bitbucket Cloud) - if multiple deploys fail, you
@nfsarmento
nfsarmento / last-modified-admin-columns
Created April 18, 2020 00:40 — forked from acolson/last-modified-admin-columns
WordPress sortable custom admin column for last modified date and user
add_filter( 'manage_edit-post_columns', 'aco_last_modified_admin_column' );
// Create the last modified column
function aco_last_modified_admin_column( $columns ) {
$columns['modified-last'] =__( 'Last Modified', 'aco' );
return $columns;
}
add_filter( 'manage_edit-post_sortable_columns', 'aco_sortable_last_modified_column' );
@nfsarmento
nfsarmento / quick_edit.js
Created April 15, 2020 01:24 — forked from michael-cannon/quick_edit.js
Working WordPress bulk and quick edit example for a video custom post type. http://aihr.us/wordpress/working-examples-for-wordpress-bulk-and-quick-edit/
// @ref http://rachelcarden.com/2012/03/manage-wordpress-posts-using-bulk-edit-and-quick-edit/
(function($) {
// we create a copy of the WP inline edit post function
var $wp_inline_edit = inlineEditPost.edit;
// and then we overwrite the function with our own code
inlineEditPost.edit = function( id ) {
// "call" the original WP edit function
// we don't want to leave WordPress hanging
$wp_inline_edit.apply( this, arguments );
@nfsarmento
nfsarmento / quick-edit.php
Last active April 15, 2020 01:44 — forked from daronspence/quick-edit.php
Quick Edit Plugin
<?php
/**
* Plugin Name: NS inline edit
* Plugin URL: https://www.nuno-sarmento.com
* Description: Add excerpt to WordPress Posts Quick Edit
* Requires at least: 5.0
* Tested up to: 5.4
* Version: 0.1
* Plugin Author: Nuno Sarmento
* Author URI: https://www.nuno-sarmento.com