Fix Issues With The 2-Click Social Media Buttons WordPress Plugin

Sometimes it happens that the 2-Click Social Media Buttons are badly aligned in your HTML code if you’re using that shortcode. To prevent this, remove the shortcode [twoclick_buttons] and create a new one with the same naming like this:

remove_shortcode('twoclick_buttons');

// create a new shortcode with the same naming
add_shortcode('twoclick_buttons', function($atts)
{
    global $post;

    ob_start();
        get_twoclick_buttons($post->ID);

        // put the buffered html output into a variable
        $twoclick_buttons = ob_get_contents();
    ob_end_clean();

    // return the buffered content
    return $twoclick_buttons;
});

If you want, you can wrap the output content with an DIV

// remove the twoclick_buttons shortcode
remove_shortcode('twoclick_buttons');

// create a new shortcode with the same naming
add_shortcode('twoclick_buttons', function($atts)
{
    global $post;

    ob_start();
        get_twoclick_buttons($post->ID);

        // put the buffered html output into a variable
        $twoclick_buttons = ob_get_contents();
    ob_end_clean();

    // return the buffered content wrapped with an div tag plus css class
    return '<div class="twoclick-buttons-wrapper">'.$twoclick_buttons.'</div>';
});
Share on FacebookShare on Google+Tweet about this on TwitterShare on LinkedIn