WordPress.org

Ready to get started?Download WordPress

Forums

Sharebar
sharebar_button function for facebook showing 3.7M (1 post)

  1. mojojojo
    Member
    Posted 11 months ago #

    I noticed when including the inline code in a theme template file that the facebook like count was 3.7M. When viewing the source I saw the [url] token wasn't replaced with the post url.

    This is the code that have to be inserted in your template file as instructed on the plugin page to display the share button.

    sharebar_button('facebook','small');

    The problem:

    function sharebar_button($name, $size = 'big'){
    	global $wpdb;
    	$item = $wpdb->get_row($wpdb->prepare("SELECT * FROM ".$wpdb->prefix."sharebar WHERE name='$name'"));
    	if($size == 'big') echo stripslashes($item->big); else echo stripslashes($item->small);
    }

    The solution:

    function custom_sharebar_button($name, $size = 'big'){
    	global $wpdb;
    	$item = $wpdb->get_row($wpdb->prepare("SELECT * FROM ".$wpdb->prefix."sharebar WHERE name='$name'"));
    	if($size == 'big') echo stripslashes(sharebar_filter($item->big)); else echo stripslashes(sharebar_filter($item->small));
    }

    Add this code to your functions.php file and call the custom_sharebar_button function instead in your template files where needed, this is to keep your changes in case the plugin gets updated:

    Example:

    custom_sharebar_button('facebook','small');

    The sharebar_filter function need to be applied to the $item->small and $item->big properties.

    If this sounds right, could you please add this fix to one of your next plugin updates.

    Thanks for the nice plugin, really easy to use.

    http://wordpress.org/extend/plugins/sharebar/

Reply

You must log in to post.

About this Plugin

About this Topic