WordPress.org

Ready to get started?Download WordPress

Forums

Add Twitter, Facebook Like, Google plus one Social share
Add filter to change Facebook post link (1 post)

  1. daymobrew
    Member
    Posted 1 year ago #

    I am using version 2.4.0 of your plugin on WordPress 3.4.2.
    My client wanted the number beside the Facebook Like button reflect the likes of her Facebook page, not the web site page.

    Could you please add an add_filter() that would allow me to achieve this without having to edit the plugin code.

    The change would be to the kc_social_share() function in tf_display.php.
    Here is a diff of my proposed code:

    --- tf_display.orig.php	2012-05-16 16:12:41.000000000 +0100
    +++ tf_display.php	2012-12-11 20:41:11.271545500 +0000
    @@ -212,7 +212,7 @@
     		if ($option['active_buttons']['facebook_like']==true) {
     		$output .= '
     			<div class="buttons">
    -			<iframe src="http'.(is_ssl()?'s':'').'://www.facebook.com/plugins/like.php?href=' . urlencode($post_link) . '&layout=box_count&show_faces=false&action=like&font=verdana&colorscheme=light" scrolling="no" frameborder="0" allowTransparency="true" style="border:none; overflow:hidden; width:50px; height:65px;"></iframe>
    +			<iframe src="http'.(is_ssl()?'s':'').'://www.facebook.com/plugins/like.php?href=' . urlencode(apply_filters('kc_social_share_facebook',$post_link)) . '&layout=box_count&show_faces=false&action=like&font=verdana&colorscheme=light" scrolling="no" frameborder="0" allowTransparency="true" style="border:none; overflow:hidden; width:50px; height:65px;"></iframe>
     			</div>';
     		}

    It is also on: http://pastebin.com/zAiGxHF6
    The change is just changing
    $post_link
    to
    apply_filters('kc_social_share_facebook',$post_link)

    Additional filters could be provided for the approx 15 other uses of $post_link. In the plugin user's code they could all point to the same function.

    Sample usage:

    // Change the url used in the Facebook Like link.
    add_filter('kc_social_share_facebook', byb_like_facebook_page, 10, 1);
    
    function byb_like_facebook_page($post_link) {
      return 'http://www.facebook.com/pages/bags-your-bag/305290386181182';
    }

    http://wordpress.org/extend/plugins/twitter-facebook-google-plusone-share/

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic