<?php
/*
Plugin Name: Lightweght Share para Tu Experto
Description: Botones de compartir ligeritos y sin javascript.
Version: 0.1
Author: Mr.FoxTalbot
Author URI: http://mrfoxtalbot.com
License: GPL2
*/
function tuexperto_social() {
if ( ! is_singular() ) {
return;
}
// Estilos
echo '
<style>
.tuexperto-social {
width:40px;
position:fixed;
left:0;
bottom:50%;
z-index:1000;
background:rgba(255,255,255,0.8) none repeat scroll 0 0;
padding:5px;
}
.tuexperto-social a img {display:inline-block;}
.tuexperto-social img {
max-width:30px;
height:auto;
padding:4px 2px;
}
.tuexperto-social a img:hover {
opacity:0.6
}
@media all and (max-width:800px) {.tuexperto-social{display:none;}} /* Ocultar por debajo de 800px */
</style>';
// URL de la carpeta de plugins
$sharedir_url = plugin_dir_url( __FILE__ );
// BOTONES
$fb_url = add_query_arg(
array(
'u' => get_permalink(),
't' => rawurlencode( get_the_title() )
),
'http://www.facebook.com/sharer/sharer.php'
);
$twitter_url = add_query_arg(
array(
'text' => rawurlencode( get_the_title() ),
'url' => get_permalink(),
'hashtags' => 'tuexperto @tuexperto'
),
'http://twitter.com/share'
);
$thumb_id = get_post_thumbnail_id();
$thumb_url_array = wp_get_attachment_image_src( $thumb_id, 'thumbnail-size', true );
$pinterest_url = add_query_arg(
array(
'description' => rawurlencode( get_the_title() ),
'url' => get_permalink(),
'media' => $thumb_url_array[0]
),
'http://pinterest.com/pin/create/button/'
);
$email_url = add_query_arg(
array(
'subject' => rawurlencode( 'Hola, quiero compartir contigo este artículo de Tu Experto' ),
'body' => rawurlencode( get_the_title() ),
'media' => $thumb_url_array[0]
),
'mailto:'
);
?>
<div class="tuexperto-social">
<a target="_blank" href="<?php echo esc_url( $fb_url ); ?>">
<img src="<?php echo esc_url( $sharedir_url . 'imgs/face.png' ); ?>">
</a>
<a target="_blank" href="<?php echo esc_url( $twitter_url ); ?>">
<img src="<?php echo esc_url( $sharedir_url . 'imgs/twitter.png' ); ?>">
</a>
<a target="_blank" href="<?php echo esc_url( $pinterest_url ); ?>">
<img src="<?php echo esc_url( $sharedir_url . 'imgs/pinterest.png' ); ?>">
</a>
<a target="_blank" href="<?php echo esc_url( $email_url ); ?>">
<img src="<?php echo esc_url( $sharedir_url . 'imgs/email.png' ); ?>">
</a>
</div>
<?php
}
add_action( 'wp_footer', 'tuexperto_social' );