Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- add_filter( 'the_content', 'sharingButtons_addThis', 100 );
- // Put AddThis buttons at the bottom of every post.
- function sharingButtons_addThis( $content ) {
- global $post;
- if(isset($post)) {
- //Set Pinterest image using "Get The Image" plugin by Justin Tadlock
- if ( function_exists( 'get_the_image' ) ) {
- $getTheImageOptions = array(
- 'meta_key' => array( 'Thumbnail', 'thumbnail' ),
- 'post_id' => $post->ID,
- 'attachment' => true,
- 'the_post_thumbnail' => true,
- 'size' => 'large',
- 'default_image' => false,
- 'order_of_image' => 1,
- 'link_to_post' => true,
- 'image_class' => false,
- 'image_scan' => false,
- 'width' => false,
- 'height' => false,
- 'format' => 'array',
- 'meta_key_save' => false,
- 'callback' => null,
- 'cache' => true,
- 'echo' => false
- );
- $pinterest = get_the_image($getTheImageOptions);
- $pinterestURL = $pinterest['url'];
- } else {
- $pinterestURL = wp_get_attachment_url( get_post_thumbnail_id($post->ID) );
- }
- } else {
- $pinterestURL = "";
- }
- $currentURL = 'http://'.$_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'];
- $content .= ' <!-- AddThis Button BEGIN -->';
- $content .= ' <div class="addthis_toolbox addthis_default_style ">';
- $content .= ' <a class="addthis_button_facebook_like" fb:like:layout="button_count"></a>';
- if(!empty($pinterestURL)) {
- $content .= ' <a class="addthis_button_pinterest" pi:pinit:url="'. $currentURL .'" pi:pinit:media="'. $pinterestURL .'" pi:pinit:layout="horizontal"></a>';
- }
- $content .= ' <a class="addthis_button_tweet"></a>';
- $content .= ' <a class="addthis_button_google_plusone" g:plusone:size="medium"></a>';
- $content .= ' <a class="addthis_counter addthis_pill_style"></a> ';
- $content .= ' </div>';
- $content .= ' <script type="text/javascript" src="http://s7.addthis.com/js/250/addthis_widget.js#pubid=btrivers"></script>';
- $content .= ' <!-- AddThis Button END --> ';
- // Returns the content.
- return $content;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement