Skip to content

Instantly share code, notes, and snippets.

@igmoweb
Last active February 21, 2017 13:29
Show Gist options
  • Save igmoweb/c9ee5bd16c2e342fd90973bbb5584a4b to your computer and use it in GitHub Desktop.
Save igmoweb/c9ee5bd16c2e342fd90973bbb5584a4b to your computer and use it in GitHub Desktop.
<?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() {
// 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
echo '<div class="tuexperto-social">';
// Facebook
echo '<a target="_blank" href="http://www.facebook.com/sharer/sharer.php?u=';
echo get_permalink();
echo '&t=';
echo rawurlencode( get_the_title() );
echo '"><img src="'.$sharedir_url.'imgs/face.png"></a>';
// Twitter
echo '<a target="_blank" href="http://twitter.com/share?text=';
echo rawurlencode( get_the_title() );
echo '&url=';
echo get_permalink();
echo '&hashtags=tuexperto';
echo ' @tuexperto';
echo '"><img src="'.$sharedir_url.'imgs/twitter.png"></a>';
// Pinterest
$thumb_id = get_post_thumbnail_id();
$thumb_url_array = wp_get_attachment_image_src($thumb_id, 'thumbnail-size', true);
$thumb_url = $thumb_url_array[0]; echo '<a target="_blank" href="http://pinterest.com/pin/create/button/?url=';
echo get_permalink();
echo '&media=';
echo $thumb_url;
echo '&description=';
echo rawurlencode( get_the_title() );
echo '"><img src="'.$sharedir_url.'imgs/pinterest.png"></a>';
// Email
echo '<a href="mailto:?subject=' . rawurlencode( 'Hola, quiero compartir contigo este artículo de Tu Experto' ) . '&body=';
echo rawurlencode( get_the_title() );
echo ': ';
echo get_permalink();
echo '"><img src="'.$sharedir_url.'imgs/email.png"></a>';
// Whatsappp
// echo '<a class="solomovil" target="_blank" href="whatsapp://send?text=';
// echo the_title();
// echo ': ';
// echo the_permalink();
// echo '"><img src="'.$sharedir_url.'imgs/tlfno.png"></a>';
// Cerrar contenedor Botones
echo '</div>';
}
add_filter( 'wp_footer', 'tuexperto_social' );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment