Tasty Pins integration for Shared Counts

Tasty Pins is a popular plugin for optimizing your content for Pinterest. It includes a feature to specify a Pinterest-specific image and description, just like the Shared Counts – Pinterest Image addon.

The following code will let Shared Counts use the image and description you specify in Tasty Pins:

This code snippet goes in a core functionality plugin or Code Snippets.

/** * Pinterest image from Tasty Pins * */ function be_shared_counts_tasty_pin_image( $image_url, $id, $link ) { if( 'pinterest' != $link['type'] ) return $image_url; $pinterest_image = get_post_meta( $id, 'tp_pinterest_hidden_image', true ); if( !empty( $pinterest_image ) ) $image_url = wp_get_attachment_image_url( $pinterest_image, 'full' ); return $image_url; } add_filter( 'shared_counts_single_image', 'be_shared_counts_tasty_pin_image', 10, 3 ); /** * Pinterest description from Tasty Pins * */ function be_shared_counts_tasty_pin_desc( $link, $id, $style ) { if( 'pinterest' !== $link['type'] ) return $link; $description = get_post_meta( $id, 'tp_pinterest_default_text', true ); if( empty( $description ) ) return $link; $url = explode( 'description=', $link['link'] ); $link['link'] = $url[0] . 'description=' . rawurlencode( wp_strip_all_tags( $description ) ); return $link; } add_filter( 'shared_counts_link', 'be_shared_counts_tasty_pin_desc', 10, 3 );

Filters used:

Published by Bill Erickson

Bill Erickson is a freelance WordPress developer and a contributor to the Genesis framework. For the past 14 years he has worked with attorneys, publishers, corporations, and non-profits, building custom websites tailored to their needs and goals.