-
Notifications
You must be signed in to change notification settings - Fork 11
Static Social Sharing
Add social sharing buttons that use static sharing urls.
This:
- Keeps your site fast by not including slow javascript from social networks.
- Keeps your site private by not adding 3rd party tracking scripts.
By default the social sharing will display on blog posts and, if the module is enabled, portfolio posts. You can change this with a filter.
function my_social_sharing_post_types() {
return '';
}
add_filter( 'toolbelt_social_sharing_post_types', 'my_social_sharing_post_types' );function my_social_sharing_post_types() {
return array( 'post', 'page' );
}
add_filter( 'toolbelt_social_sharing_post_types', 'my_social_sharing_post_types' );function my_social_sharing_post_types( $types ) {
$types[] = 'my-post-type';
return $types;
}
add_filter( 'toolbelt_social_sharing_post_types', 'my_social_sharing_post_types' );This filter runs after the post types have been filtered out. You can use this to hide the sharing options on specific posts, or older content, or whatever you can think of.
function my_display_social_sharing() {
// Hide for post id 4.
if ( 4 === (int) get_the_ID() ) {
return false;
}
// Show for all other posts.
return true;
}
add_filter( 'toolbelt_display_social_sharing', 'my_display_social_sharing' );Filter the social networks that are displayed. This is a 1 dimensional array.
The following example changes the social networks so that only Twitter, Facebook, and Email buttons are displayed.
function my_social_networks( $networks ) {
return array(
'twitter',
'facebook',
'email'
);
}
add_filter( 'toolbelt_social_networks', 'my_social_networks' );The easiest way to hide social networks is to use some custom css added to the 'additional css' section of the customizer.
The following example will hide the Pinterest link.
.toolbelt-social-share .toolbelt_pinterest { display: none; }Note: If you are comfortable with programming then using the new toolbelt_social_networks filter is the better option.
By default the plugin adds support for Facebook, Twitter, LinkedIn, Whatsapp, Pinterest, Pocket, Wallabag, Reddit, and Email.
Toolbelt is built by Ben from Pro Theme Design.