Skip to content

Instantly share code, notes, and snippets.

@GaryJones
Last active April 16, 2019 14:23
Show Gist options
  • Save GaryJones/6496730 to your computer and use it in GitHub Desktop.
Save GaryJones/6496730 to your computer and use it in GitHub Desktop.
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
* @link https://garyjones.io/move-floating-social-bar-genesis
*/
function mfsbig_remove_floating_social_bar() {
if ( class_exists( 'floating_social_bar' ) ) {
remove_filter( 'the_excerpt', array( floating_social_bar::get_instance(), 'fsb' ), apply_filters( 'fsb_social_bar_priority', 10 ) );
remove_filter( 'the_content', array( floating_social_bar::get_instance(), 'fsb' ), apply_filters( 'fsb_social_bar_priority', 10 ) );
}
}
add_action( 'genesis_before_entry_content', 'mfsbig_add_floating_social_bar' );
/**
* Echo the Floating Social Bar in the right place, just before the entry
* content (after the header and entry meta) in Genesis child themes.
*
* As fsb() is really a function for filtering, it requires a single argument
* (the content or excerpt), so we fool it by passing in an empty string instead.
*
* @author Gary Jones
* @link https://garyjones.io/move-floating-social-bar-genesis
*/
function mfsbig_add_floating_social_bar() {
if ( class_exists( 'floating_social_bar' ) ) {
echo floating_social_bar::get_instance()->fsb('');
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment