All about Wordpress Multi-user

WPMU Share Button


Friday, November 13th, 2009

This plugin is simple and designed to automatically add a “Digg This” badge or Facebook Share badge to your articles. This is very simple plugin and optionless plugin for WordpressMU. Just install and enable it on Discussion Menu.

Facebook Share Badge

Facebook Share Badge

Share Badge Disccussion Option

Share Badge Disccussion Option


<?php
/*
* Plugin Name: WPMU Facebook Share Badge
* Version: 2.0
* Plugin URI: http://patrick.bloggles.info/
* Author: Patrick
* Author URI: http://patrickchia.com/
* Description: This plugin is simple and designed to automatically add a "Digg This" badge or Facebook Share badge to your articles.
*/

add_filter('the_content', 'button_share');

function button_share( $content ){
if ( !get_option('digg_on') &amp;&amp; !get_option('fb_on') )
return $content;

global $wp_query;
$post = $wp_query->post;
$id = $post->ID;
$postlink = get_permalink($id);

$title = urlencode($post->post_title);

$digglink = split('#',$postlink);

if( is_home() || is_single() ) {
$button = "<div style='float:right;padding-left:10px;padding-bottom:10;'><table border='0' bgcolor='#ffffff'>";

if( get_option('digg_on') == '1' ) {
$button .= "<tr><td><iframe src='http://digg.com/api/diggthis.php?w=new&amp;amp;u=" .urlencode($digglink[0]) . "&amp;amp;t=" . $title . "&amp;amp;s=normal' height='80' width='52' frameborder='0' scrolling='no'></iframe></td></tr>";
}

if( get_option('fb_on') == '1' ) {
$button .= "<tr><td><script type=\"text/javascript\"> var fbShare = {url: '" . $digglink[0] . "',size:'large'}</script>";
$button .= "<script type=\"text/javascript\" src=\"http://widgets.fbshare.me/files/fbshare.js\"></script></td></tr>";
}

$button .= "</table></div>";
$content = $button . $content;
}

return $content;
}

function admin_share_button() {
?>
<label><input name="fb_on" type="checkbox" id="fb_on" value="1" <?php checked('1', get_option('fb_on')); ?> /> Enable Facebook Share Button</label><br />
<label><input name="digg_on" type="checkbox" id="digg_on" value="1" <?php checked('1', get_option('digg_on')); ?> /> Enable Digg Share Button</label>
<?php
}

function share_conf(){
add_settings_field('fb_on', 'Share Button', 'admin_share_button', 'discussion', 'default');
register_setting('discussion', 'fb_on', 'sanitize_title');
register_setting('discussion', 'digg_on');
}
add_action('admin_init','share_conf');

?>

Tags: ,

One Response to “WPMU Share Button”

  1. rickbsgu says:

    Hi -

    Tried installing this – nothing happening. It’s going through the code, though: I had to fix the ‘&amp;’ bits.

    Here’s where I put it: wordpress-mu/wp-content/mu-plugins

    I don’t see anyplace to activate it or otherwise make things happen.

    Any suggestions?

    thanks