Skip to content

Instantly share code, notes, and snippets.

@DriftwoodJP
Last active June 2, 2016 08:03
Show Gist options
  • Save DriftwoodJP/39e894a5d4d32b1c55f2040f45f19cc6 to your computer and use it in GitHub Desktop.
Save DriftwoodJP/39e894a5d4d32b1c55f2040f45f19cc6 to your computer and use it in GitHub Desktop.
CSS Simple Sharing Buttons with SNS Count Cache plugin - Use `<?php get_template_part('socialButtons'); ?>` in WordPress post template file.
<?php
/**
* CSS Simple Sharing Buttons with SNS Count Cache plugin
* Use `<?php get_template_part('socialButtons'); ?>` in WordPress post template file.
*
* CSS Simple Sharing Buttons: http://codepen.io/DriftwoodJP/pen/XdQKZY
* WordPress with SNS Count Cache plugin: https://gist.github.com/DriftwoodJP/39e894a5d4d32b1c55f2040f45f19cc6
* Blog: http://www.d-wood.com/blog/2016/06/02_8104.html
*/
$title = urlencode( the_title_attribute( 'echo=0' ) );
$url = get_permalink();
$via = 'DriftwoodJP';
$feed = 'http://www.d-wood.com/feed';
if ( function_exists( 'scc_get_share_twitter' ) &&
function_exists( 'scc_get_share_facebook' ) &&
function_exists( 'scc_get_share_gplus' ) &&
function_exists( 'scc_get_share_hatebu' ) &&
function_exists( 'scc_get_share_pocket' ) &&
function_exists( 'scc_get_follow_feedly' )
) {
$count_twitter = scc_get_share_twitter();
$count_facebook = scc_get_share_facebook();
$count_gplus = scc_get_share_gplus();
$count_hatebu = scc_get_share_hatebu();
$count_pocket = scc_get_share_pocket();
$count_feedly = scc_get_follow_feedly();
$url_twitter = esc_url( "http://twitter.com/share?text=$title&url=$url&via=$via" );
$url_facebook = esc_url( "https://www.facebook.com/sharer/sharer.php?u=$url" );
$url_gplus = esc_url( "https://plus.google.com/share?url=$url" );
$url_hatebu = esc_url( "http://b.hatena.ne.jp/add?mode=confirm&url=$url" );
$url_pocket = esc_url( "http://getpocket.com/edit?url=$url" );
$url_feedly = esc_url( "http://cloud.feedly.com/#subscription/feed/$feed" );
echo <<< EOM
<ul class="sb">
<li class="sb__item sb--twitter">
<a href="$url_twitter" target="_blank" rel="nofollow">Twitter $count_twitter</a>
</li>
<li class="sb__item sb--facebook">
<a href="$url_facebook" target="_blank" rel="nofollow">Facebook $count_facebook</a>
</li>
<li class="sb__item sb--google">
<a href="$url_gplus" target="_blank" rel="nofollow">Google+ $count_gplus</a>
</li>
<li class="sb__item sb--hatena">
<a href="$url_hatebu" target="_blank" rel="nofollow">Hatena $count_hatebu</a>
</li>
<li class="sb__item sb--pocket">
<a href="$url_pocket" target="_blank" rel="nofollow">Pocket $count_pocket</a>
</li>
<li class="sb__item sb--feedly">
<a href="$url_feedly" target='_blank' rel="nofollow">Feedly $count_feedly</a>
</li>
</ul>
EOM;
}
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment