|
<?php |
|
|
|
function PROJECT_NAME_social_buttons() { |
|
|
|
$social = ' |
|
<ul class="PROJECT_NAME-social"> |
|
<li class="facebook"> |
|
<a href="http://www.facebook.com/sharer.php?u=' . urlencode( get_permalink() ) . '" target="_blank">Facebook</a><span class="count">' . PROJECT_NAME_get_facebook_count( get_permalink() ) . '</span> |
|
</li> |
|
<li class="twitter"> |
|
<a href="https://twitter.com/intent/tweet?url=' . urlencode( get_permalink() ) . '&text=' . urlencode( get_the_title() ) . '" target="_blank">Twitter</a><span class="count">' . PROJECT_NAME_get_twitter_count( get_permalink() ) . '</span> |
|
</li> |
|
<li class="linkedin"> |
|
<a href="http://www.linkedin.com/shareArticle?mini=true&url=' . urlencode( get_permalink() ) . '&title=' . urlencode( get_the_title() ) . '&source='. urlencode( 'Bee Square' ) . '" target="_blank">Linkedin</a><span class="count">' . PROJECT_NAME_get_linkedin_count( get_permalink() ) . '</span> |
|
</li> |
|
</ul> |
|
'; |
|
|
|
echo $social; |
|
} |
|
|
|
|
|
function PROJECT_NAME_get_facebook_count( $url = null ) { |
|
if ( is_null( $url ) ) |
|
return "0"; |
|
|
|
$fb_details = file_get_contents('http://graph.facebook.com/' . $url); |
|
$arrFacebookShareDetails = json_decode( $fb_details, true ); |
|
$intFacebookShareCount = ( isset( $arrFacebookShareDetails['shares'] ) ? $arrFacebookShareDetails['shares'] : 0 ); |
|
return ( $intFacebookShareCount ) ? $intFacebookShareCount : '0'; |
|
} |
|
|
|
function PROJECT_NAME_get_twitter_count( $url = null ) { |
|
if ( is_null( $url ) ) |
|
return "0"; |
|
|
|
$htmlTwitterShareDetails = file_get_contents('http://urls.api.twitter.com/1/urls/count.json?url=' . $url); |
|
$arrTwitterShareDetails = json_decode($htmlTwitterShareDetails, true); |
|
$intTwitterShareCount = $arrTwitterShareDetails['count']; |
|
return ($intTwitterShareCount ) ? $intTwitterShareCount : '0'; |
|
} |
|
|
|
function PROJECT_NAME_get_linkedin_count( $url = null ) { |
|
if ( is_null( $url ) ) |
|
return "0"; |
|
|
|
$htmlLinkedinShareDetails = file_get_contents('http://www.linkedin.com/countserv/count/share?url=' . $url); |
|
$htmlLinkedinShareDetails = str_replace('IN.Tags.Share.handleCount(', '', $htmlLinkedinShareDetails); |
|
$htmlLinkedinShareDetails = str_replace(');', '', $htmlLinkedinShareDetails); |
|
$arrLinkedinShareDetails = json_decode($htmlLinkedinShareDetails, true); |
|
$intLinkedinShareCount = $arrLinkedinShareDetails['count']; |
|
return ($intLinkedinShareCount ) ? $intLinkedinShareCount : '0'; |
|
} |
|
|
|
?> |