Skip to content

Instantly share code, notes, and snippets.

Joshua Nelson joshuadavidnelson

View GitHub Profile
View notification.php
<?php
// Route to user address from drop down list, update the '1' to the ID of your form – I am using this on 6 forms so I have removed the ID requirement
add_filter( 'gform_notification', 'welcome_email', 10, 3 );
function welcome_email( $notification, $form , $entry ) {
foreach( $form['fields'] as &$field ) {
// Similar to above, find the right field
if( $field['type'] != 'select' || strpos($field['cssClass'], 'user-emails') === false )
continue;
// Pull out the user id selected, by the field id and the $entry element
@joshuadavidnelson
joshuadavidnelson / git-commit-after-plugin-update.php
Last active Jun 27, 2020
Create a commit for every plugin update.
View git-commit-after-plugin-update.php
<?php
/**
* Plugin Name: Commit on Update
* Plugin Author: Joshua David Nelson
**/
defined( 'ABSPATH' ) or die( 'Nope!' );
class Commit_On_Update {
@joshuadavidnelson
joshuadavidnelson / allow-shortcodes-in-genesis-archive-intro.php
Created Jan 27, 2017
Allow shortcodes in the intro text output of Genesis archives.
View allow-shortcodes-in-genesis-archive-intro.php
<?php
/**
* Allow shortcodes in genesis archive intro text.
*
* @author Joshua David Nelson, josh@joshuadnelson.com
**/
// Custom Post Type Archive Intro Text
add_filter( 'genesis_cpt_archive_intro_text_output', 'do_shortcode' );
View filter-woocommerce-gridlist-button-wrap-end.php
<?php
/**
* Filter the Gridlist Button Wrap End tag.
*
* Requires Grid/List plugin version 1.1.0 or greater
*
* @param string $output The output value
*
* @return string $output The filtered output value
*/
@joshuadavidnelson
joshuadavidnelson / filter-woocommerce-myaccount-order-date.php
Created Dec 13, 2016
Alter the output of a specific WooCommerce My Account column, in this case replacing the date format used for displaying the order date.
View filter-woocommerce-myaccount-order-date.php
<?php
/**
* Alter the date order output (in this case, the format of the displayed date).
*
* @param object $order
*/
add_action( 'woocommerce_my_account_my_orders_column_order-date', 'alter_order_date_format', 10, 1 );
function alter_order_date_format( $order ) {
echo '<time datetime="' . date( 'Y-m-d', strtotime( $order->order_date ) ) . '" title="' . esc_attr( strtotime( $order->order_date ) ) . '">' . date_i18n( 'm/d/Y', strtotime( $order->order_date ) ) . '</time>';
@joshuadavidnelson
joshuadavidnelson / rename-woocommerce-brands.php
Created Dec 13, 2016
Rename WooCommerce "Brands" to "Manufacturers"
View rename-woocommerce-brands.php
<?php
/**
* Rename WooCommerce "Brands" to "Manufacturers"
*
* @param array $args
*
* @return array
*/
add_filter( 'register_taxonomy_product_brand', 'woocomerce_brands_filter', 10, 1 );
function woocomerce_brands_filter( $args ) {
View deactive-plugin.php
<?php
/**
* Example code taken from: https://pento.net/2014/02/18/dont-let-your-plugin-be-activated-on-incompatible-sites/
*/
// In this example, only allow activation on WordPress 3.7 or higherclass
MyPlugin {
function __construct() {
add_action( 'admin_init', array( $this, 'check_version' ) );
View gf-user-list.php
<?php
/**
* Route the notification to multiple users in a bcc field.
*
* @see https://joshuadnelson.com/user-dropdown-list-custom-notification-routing-gravity-forms/#comment-12376
* @see https://www.gravityhelp.com/documentation/article/notification/
*/
// NOTE: This is untested code, please use with caution. Test and improve as necessary.
@joshuadavidnelson
joshuadavidnelson / get-page-id-by-template.php
Created May 29, 2016
Grab the page id for the first page using a specific template. Ideal for situations with a template intended for a only one page.
View get-page-id-by-template.php
<?php
/**
* Get the first page id with the matching template slug.
*
* @author Joshua David Nelson, josh@joshuadnelson.com
*
* @param string $template This is the template slug, like 'template-about-page.php'
*
* @return mixed $page_id Int or false on failure
*/
@joshuadavidnelson
joshuadavidnelson / default-tax-archive-title.php
Last active Mar 29, 2018
Use Taxonomy Name for Default Taxonomy Archive Title in Genesis
View default-tax-archive-title.php
<?php
/**
* Default Titles for Term Archives
*
* @author Bill Erickson
* @see http://www.billerickson.net/default-category-and-tag-titles
*
* @param string $headline
* @param object $term
* @return string $headline
You can’t perform that action at this time.