Skip to content

Instantly share code, notes, and snippets.

View GaryJones's full-sized avatar

Gary Jones GaryJones

View GitHub Profile
@GaryJones
GaryJones / gist:7183071
Last active December 26, 2015 16:49 — forked from salcode/gist:7164690
<?php
/*
* Examples to add custom classes to Genesis WordPress Framework Markup when using HTML5 output
*/
add_action( 'genesis_setup', 'srf_add_cust_classes', 15 ); // Priority 15 ensures it runs after Genesis itself has setup.
function srf_add_cust_classes() {
add_filter( 'genesis_attr_site-inner', 'srf_attr_site_inner' );
add_filter( 'genesis_attr_content-sidebar-wrap', 'srf_attr_content_sidebar_wrap' );
add_filter( 'genesis_attr_content', 'srf_attr_content' );
add_filter( 'genesis_attr_sidebar-primary', 'srf_attr_sidebar_primary' );
@GaryJones
GaryJones / functions.php
Last active May 27, 2017 18:13
Genesis: Stop archives from using first attached image as fallback when no featured image is set.
<?php
// Don't include the above.
add_filter( 'genesis_get_image_default_args', 'prefix_stop_auto_featured_image' );
/**
* Stop Genesis archives from using first attached image as fallback when no featured image is set.
*
* @param array $args Default image arguments.
*
@GaryJones
GaryJones / gist:7057100
Last active December 25, 2015 23:29
WordPress: Allow anchor target attribute in user biography field.
<?php
// Don't include the above
add_filter( 'wp_kses_allowed_html', 'georgef_allow_anchor_target_attribute_in_biography', 20, 2 );
/**
* Allow links to have a target attribute in user biographical information.
*
* @author Gary Jones
* @link http://www.studiopress.com/forums/topic/about-the-author-box-can-open-links-in-new-window/
@GaryJones
GaryJones / functions.php
Created October 19, 2013 03:04
Genesis: Change date format in Primary Nav Extras.
<?php
// Don't include the above
add_filter( 'wp_nav_menu_items', 'prefix_change_nav_date_format', 15, 2 );
/**
* Filter the Primary Navigation menu items in Genesis, to change the date format.
*
* @author Gary Jones
* @link http://www.studiopress.com/forums/topic/abbreviate-month-in-primary-navigation-bar-enterprise/
@GaryJones
GaryJones / readme.md
Last active July 14, 2019 20:46
Custom Featured Post Widget plugin: Skeleton for amending the output of the Genesis Featured Post widget.
@GaryJones
GaryJones / functions.php
Last active April 16, 2019 14:23
Remove the Floating Social Bar output from inside the entry-content div in Genesis child themes, and add it just before entry-content instead.This keeps the itemprop="text" for the BlogPosting / CreativeWork itemtype from starting with the textual content of Floating Social Bar.
<?php
add_action( 'pre_get_posts', 'mfsbig_remove_floating_social_bar', 15 );
/**
* Remove Floating Social Bar from outputting at the top of the content.
*
* FSB adds these filters at pre_get_posts, priorty 10, so we'll remove them
* just after that.
*
* @author Gary Jones
@GaryJones
GaryJones / functions.php
Created August 30, 2013 20:52
Use gettext filter to change the name of the menu location added by Genesis Header Nav plugin. Combine this with a filtered priority of <5 to place it before the site header element.
<?php
add_filter( 'gettext', 'prefix_genesis_header_nav_name', 10, 3 );
/**
* Change the name of the Header menu location added by Genesis Header Nav plugin.
*/
function prefix_genesis_header_nav_name( $translated_text, $original_text, $domain ) {
if ( 'genesis-header-nav' === $domain && 'Header' === $original_text )
return 'Top';
}
<?php
//* Do NOT include the opening php tag
//* Add Organization schema to our logo
add_filter( 'genesis_seo_title', 'rvam_header_title', 10, 3 );
function rvam_header_title( $title, $inside, $wrap ) {
$inside = sprintf( '<div itemscope="itemscope" itemtype="http://schema.org/Organization"><a itemprop="url" href="%s" title="%s"><img class="logo" itemprop="logo" src="http://www.rvamedia.com/img/rva-media.png" alt="%s" /></a></div>', trailingslashit( home_url() ), esc_attr( get_bloginfo( 'name' ) ), get_bloginfo( 'name' ) );
return sprintf( '<%1$s id="title">%2$s</%1$s>', 'span', $inside );
}
<?php
/**
* Registers an option sanitization filter.
*
* If the option is an "array" option type with "suboptions", you have to use the third param to specify the
* suboption or suboptions you want the filter to apply to. DO NOT call this without the third parameter on an option
* that is an array option, because in that case it will apply that filter to the array(), not each member.
*
* Use the 'genesis_settings_sanitizer_init' action to be notified when this function is safe to use
@GaryJones
GaryJones / functions.php
Last active December 20, 2015 19:19
Temporary fix for an incorrect escaping in genesis_post_author_link_shortcode() for Genesis 2.0.0.
<?php
// Don't include the above <?php when copying and pasting to your child theme functions.php!
add_filter( 'genesis_post_info', 'gmj_fix_post_info_linked_author', 10, 2 );
/**
* Temporary fix for an incorrect escaping in genesis_post_author_link_shortcode() for Genesis 2.0.0.
*
* This function can probably be removed once Genesis 2.0.1 is released.
*