Pin It on Images

<?php
/**
* Scripts
*
*/
function ea_scripts() {
wp_enqueue_script( 'pinit', '//assets.pinterest.com/js/pinit.js', false, false, true );
}
add_action( 'wp_enqueue_scripts', 'ea_scripts' );
/**
* Script Loader
*
*/
function ea_script_loader( $tag, $handle ) {
if( 'pinit' == $handle )
$tag = str_replace( ' src', ' async="async" src', $tag );
return $tag;
}
add_filter( 'script_loader_tag', 'ea_script_loader', 10, 2 );
view raw functions.php hosted with ❤ by GitHub
jQuery(function($){
// Pinterest PinIt
$('.page-header .wrap, .wp-caption').each(function(){
margin_top = 42;
if( $(this).find('.wp-caption-text').length ) {
margin_top += $(this).find('.wp-caption-text').height() + 35;
}
$(this).append('<span class="pinit" style="margin-top: -' + margin_top + 'px; margin-right: 10px; float: right;"><a data-pin-do="buttonBookmark" data-pin-tall="true" data-pin-round="true" data-pin-save="false" href="https://www.pinterest.com/pin/create/button/"><img src="//assets.pinterest.com/images/pidgets/pinit_fg_en_round_red_32.png" /></a></span>');
});
});
view raw global.js hosted with ❤ by GitHub

javascript social