Skip to content

Instantly share code, notes, and snippets.

Jonathan Goldford jg314

Block or report user

Report or block jg314

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@jg314
jg314 / comment_reply_emails.php
Created Mar 23, 2015
Send comment reply emails to the parent comment author automatically in WordPress.
View comment_reply_emails.php
<?php
add_action( 'wp_set_comment_status', 'wi_comment_notification', 99, 2 );
function wi_comment_notification( $comment_id, $comment_status ){
$comment_object = get_comment( $comment_id );
if( $comment_status == 'approve' && $comment_object->comment_parent > 0 ){
$comment_parent = get_comment( $comment_object->comment_parent );
$mailcontent = 'Hi ' . $comment_parent->comment_author . ',<br><br>';
$mailcontent .= $comment_object->comment_author . ' replied to your comment on <a href="' . get_permalink( $comment_parent->comment_post_ID ) . '">' . get_the_title( $comment_parent->comment_post_ID ).'</a> with the following:';
$mailcontent .= '<blockquote>' . $comment_object->comment_content . '</blockquote>';
@jg314
jg314 / wp_secondary_primary_nav.php
Created Jan 5, 2015
WordPress: Add secondary navigation to end of primary navigation in PHP for mobile.
View wp_secondary_primary_nav.php
<div class="main-navigation-container">
<nav id="site-navigation" class="main-navigation navigation" role="navigation">
<?php
$secondary_nav = wp_nav_menu( array(
'theme_location' => 'secondary',
'echo' => false,
'items_wrap' => '%3$s',
'container' => false
) );
@jg314
jg314 / ce-redirect.php
Last active Sep 29, 2016
Events Calendar Community Events: Redirect users to a new page after submission
View ce-redirect.php
<?php
/*
* Send visitors who submit events to a different page after submission.
*
* This actually does the redirect. If an event was submitted, and we're about
* to reload the submission page (with a message instead of a form), this will
* redirect the user.
*
* @param WP $wp
* @return void
@jg314
jg314 / gravity_forms_pageview_track.html
Last active Mar 5, 2017
Google Analytics tracking code for virtual pageviews for Gravity Forms submissions that don't send users to a new page.
View gravity_forms_pageview_track.html
<!--
The js code snippet below should be placed in the confirmation text for a Gravity Form that does not send to a thank you
page on submission, such as a sidebar or footer email newsletter signup form.
* This snippet will work for forms that submit via both ajax and non-ajax.
* This snippet will work with plugins such as Google Analytics for WordPress by MonsterInsights.
* This snippet will work for Universal Analytics, but not Classic Analytics.
You can read more about tracking pageviews at https://developers.google.com/analytics/devguides/collection/analyticsjs/pages.
-->
@jg314
jg314 / wp-picturefill.php
Last active Aug 29, 2015
WordPress Featured Image Using Picturefill Responsive Image Solution
View wp-picturefill.php
<?php
//Created using code from http://scottjehl.github.io/picturefill/,
//http://ericportis.com/posts/2014/srcset-sizes/,
//http://www.taupecat.com/2014/05/picturefill-js-wordpress/,
//http://www.smashingmagazine.com/2014/05/12/picturefill-2-0-responsive-images-and-the-perfect-polyfill/
//For homepage where featured image should live
if( has_post_thumbnail() ){
$thumbnail_id = get_post_thumbnail_id();
$alt = get_post_meta( $thumbnail_id, '_wp_attachment_image_alt', true );
View wpseo_remove_home_breadcrumb.php
function tg_remove_home_breadcrumb($links)
{
if ($links[0]['url'] == get_home_url()) { array_shift($links); }
return $links;
}
add_filter('wpseo_breadcrumb_links', 'tg_remove_home_breadcrumb');
@jg314
jg314 / gravity_forms_ga_tracking.php
Last active Nov 30, 2017
Add Google Analytics Ecommerce tracking to a donation form created through Gravity Forms.
View gravity_forms_ga_tracking.php
<?php
/*
* Add custom query vars to handle Google Analytics Ecommerce tracking.
* This should be placed in a plugin or in functions.php of the theme.
*
* You'll want to use the redirect method for Gravity Forms confirmations and
* turn on passing field data via a query string. An example we used was:
* donation_amount={Donation Amount:13}&donation_id={entry_id}&donation_recurring=0
*/
function sm_add_query_vars( $vars ){
@jg314
jg314 / nonprofit_board_management_plugin_frontend_members_shortcode.php
Last active Dec 28, 2015
Display all the board members for the Nonprofit Board Management plugin using a shortcode.
View nonprofit_board_management_plugin_frontend_members_shortcode.php
<?php
/*
* Display all the board members for the Nonprofit Board Management plugin
* using a shortcode.
*
* Copy and paste this code into your functions.php file to use it.
*
* example for use on a page: [list_board_members]
*/
function wi_list_board_members(){
View gist:4489191
//Set up the color pickers to work with our text input field
jQuery( document ).ready(function(){
"use strict";
//This if statement checks if the color picker widget exists within jQuery UI
//If it does exist then we initialize the WordPress color picker on our text input field
if( typeof jQuery.wp === 'object' && typeof jQuery.wp.wpColorPicker === 'function' ){
jQuery( '#color' ).wpColorPicker();
}
else {
View gist:4489186
<input id="color" name="color_options[color]" type="text" value="" />
<div id="colorpicker"></div>
You can’t perform that action at this time.