Añade un botón para compartir tus entradas en Digg y Facebook

Este plugin te permite añadir a tus entradas un botón para compartirlas en digg o facebook. Es un plugin muy sencillo y te permitirá atraer muchos visitante a tu blog.

Comprimir en zip, subirlo a la carpeta mu-plugins y descomprimirlo. Despues, activar en el escritorio.

<?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’);

?>

Seguir

Get every new post delivered to your Inbox.