|
<?php |
|
/* |
|
Plugin Name: Lightweght Share para Tu Experto |
|
Description: Botones de compartir ligeritos y sin javascript. |
|
Version: 0.3 |
|
Author: Mr.FoxTalbot |
|
Author URI: http://mrfoxtalbot.com |
|
License: GPL2 |
|
*/ |
|
function tuexperto_social() { |
|
if ( ! is_singular() ) { |
|
return; |
|
} |
|
// Estilos |
|
echo ' |
|
<style> |
|
.tuexperto-social { |
|
width:60px; |
|
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:45px; |
|
height:auto; |
|
padding:4px 2px; |
|
} |
|
.tuexperto-social a img:hover { |
|
opacity:0.6 |
|
} |
|
.solomovil { |
|
display:none |
|
} |
|
@media all and (max-width:700px) { |
|
.solomovil { display:inline-block } |
|
.tuexperto-social { |
|
left: 0; |
|
padding: 0; |
|
position: fixed; |
|
bottom: -5px; |
|
width: 100%; |
|
z-index: 1000; |
|
text-align:center; |
|
} |
|
.tuexperto-social a { |
|
display: inline-block; |
|
padding: 0; |
|
} |
|
.tuexperto-social img { |
|
display: inline-block; |
|
height: auto; |
|
width: 100%; |
|
padding:5px; |
|
} |
|
} |
|
</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 tuexperto.com' ), |
|
'body' => rawurlencode( get_permalink() ), |
|
'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> |
|
<a class="solomovil" target="_blank" href="whatsapp://send?text=Hola, quiero compartir contigo este artículo de tuexperto.com: <?php the_title(); ?>: <?php the_permalink(); ?>" > |
|
<img src="<?php echo esc_url( $sharedir_url . 'imgs/tlfno.png' ); ?>" > |
|
</a> |
|
</div> |
|
<?php |
|
} |
|
add_action( 'wp_footer', 'tuexperto_social' ); |