Pintrest Share link
if(!function_exists('pinterest_share_url'))
{
function pinterest_share_url ($url, $media, $desc, $link_text = '', $attributes = array(), $popup = TRUE)
{
$url = htmlentities($url);
$media = htmlentities($media);
$desc = htmlentities($desc);
$share_url = 'http://www.pinterest.com/pin/create/button/?url='.$url.'&media='.$media.'&description='.$desc;
if (empty ($attributes['href']))
$attributes['href'] = $share_url;
if ($popup !== FALSE)
{
$default_settings = array('name' => 'Pinterest', 'width' => 780, 'height' => 360);
$window_settings = (is_array ($popup))
? array_merge ($default_settings, $popup)
: $default_settings;
$window_name = $window_settings['name'];
unset ($window_settings['name']);
$window_features = array();
foreach ($window_settings as $k => $v)
$window_features [] = htmlentities ($k).'='.htmlentities ($v);
$window_features = implode (',', $window_features);
$window = array($share_url, $window_name);
if (!empty ($window_features))
$window[] = $window_features;
$window = 'window.open(\''.implode('\',\'', $window).'\');';
if (empty ($attributes['onclick']))
$attributes['onclick'] = $window.' return false;';
else
{
$attributes['onclick'] = (preg_match ('\/s*return\s+false;\s*$/i', $attributes['onclick']))
? preg_replace ('\/s*return\s+false;\s*$/i', ' '.$window.' return false;', $attributes['onclick'])
: $attributes['onclick'].' '.$window.' return false';
}
}
$_attributes = array();
foreach ($attributes as $k => $v)
$_attributes [] = $k.'="'.htmlentities ($v).'"';
return '<a '.implode (' ', $_attributes).'><i class="icon-pinterest"></i> '.$link_text.'</a>';
}
}
function mf_social_shares($id){
$pintrest = pinterest_share_url( $url, wp_get_attachment_image_src( get_post_thumbnail_id( $id ), 'single-post-thumbnail' )[0], get_permalink($id), 'SHARE ON PINTREST', array('id' => 'pinterest-share', 'class' => 'btn btn-box pinterest'));
echo $pintrest;
}
add_action('mf_social_shares', 'mf_social_shares', 1);
<?php do_action('mf_social_shares', $post->ID ); ?>