Created
April 16, 2012 10:16
-
-
Save jdevalk/2397515 to your computer and use it in GitHub Desktop.
Pinterest button shortcode
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// Usage [pin img="<url>" title="<title>"] | |
function yoast_pinterest_shortcode( $atts ) { | |
extract( shortcode_atts( array( | |
'url' => get_permalink(), | |
'img' => '', | |
'title' => get_the_title(), | |
'align' => 'alignright' | |
), $atts ) ); | |
return '<div class="'.esc_attr( $align ).'"><a href="http://pinterest.com/pin/create/button/?url='.esc_attr( urlencode($url) ).'&media='.esc_attr( urlencode($img) ).'&description='.esc_attr( urlencode( $title) ).'" class="pin-it-button" count-layout="vertical"><img border="0" src="//assets.pinterest.com/images/PinExt.png" title="Pin It" /></a><script type="text/javascript" src="//assets.pinterest.com/js/pinit.js"></script></div>'; | |
} | |
add_shortcode( 'pin', 'yoast_pinterest_shortcode' ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment