Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Show sharing buttons, e.g. from Jetpack
// Show sharing buttons, e.g. from Jetpack
// TODO: Rewrite code as filter hook
function form($instance) {
<label for="<?php echo $this->get_field_id("hide_social_buttons"); ?>">
<input type="checkbox" class="checkbox" id="<?php echo $this->get_field_id("hide_social_buttons"); ?>" name="<?php echo $this->get_field_name("hide_social_buttons"); ?>"<?php checked( (bool) $instance["hide_social_buttons"], true ); ?> />
<?php _e( 'Hide social buttons in widget output',TEXTDOMAIN ); ?>
class Widget extends \WP_Widget {
* Apply the_content filter for excerpt
* This should show sharing buttons which comes with other widgets in the widget output in the same way as on the main content
* @param string The HTML with other applied excerpt filters
* @return string If option hide_social_buttons is unchecked applay the_content filter
* @since 4.6
function apply_the_excerpt($text) {
$ret = "";
if (isset($this->instance["hide_social_buttons"]) && $this->instance["hide_social_buttons"])
$ret = $text;
$ret = apply_filters('the_content', $text);
return $ret;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment