Created
April 27, 2017 16:09
-
-
Save bob-moore/c13c311d9b5e56bb265dbfcf20af1bc6 to your computer and use it in GitHub Desktop.
Functions to tweak share button placement of jetpack
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Function to remove automatic placement of sharing buttons from jetpack | |
*/ | |
if( !function_exists( 'jptweak_remove_share' ) ) { | |
function jptweak_remove_share() { | |
remove_filter( 'the_content', 'sharing_display', 19 ); | |
remove_filter( 'the_excerpt', 'sharing_display', 19 ); | |
if ( class_exists( 'Jetpack_Likes' ) ) { | |
remove_filter( 'the_content', array( Jetpack_Likes::init(), 'post_likes' ), 30, 1 ); | |
} | |
} | |
add_action( 'loop_start', 'jptweak_remove_share' ); | |
} | |
/** | |
* Function to manually place the sharing buttons from jetpack wherever we want | |
*/ | |
if( !function_exists( 'jptweak_place_share' ) ) { | |
function jptweak_place_share() { | |
if ( function_exists( 'sharing_display' ) ) { | |
sharing_display( '', true ); | |
} | |
if ( class_exists( 'Jetpack_Likes' ) ) { | |
$custom_likes = new Jetpack_Likes; | |
echo $custom_likes->post_likes( '' ); | |
} | |
} | |
add_action( 'jp_share_buttons', 'jptweak_place_share' ); | |
} | |
/** | |
* Usage: Place this code in theme to add the share buttons where you want | |
*/ | |
do_action( 'jp_share_buttons' ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment