Skip to content

Instantly share code, notes, and snippets.

@derak-kilgo
Created October 31, 2013 21:42
Show Gist options
  • Save derak-kilgo/7257699 to your computer and use it in GitHub Desktop.
Save derak-kilgo/7257699 to your computer and use it in GitHub Desktop.
PHP social button bar without javascript dependencies.
<?php
$url = urlencode($_SERVER['REQUEST_URI']);
$desc = urlencode('Title for your page');
//icons provied by iconfinder.com
$blueiconSize = 27;
$redIconSize = 24;
$template = <<<SOCIALTEMPLATE
<div class="social-bar">
<a href="http://www.facebook.com/sharer/sharer.php?u=$url"><img style="vertical-align: middle; margin-bottom: .25em;"width="$blueiconSize" height="$blueiconSize" src="https://cdn3.iconfinder.com/data/icons/free-social-icons/67/facebook_square-64.png" alt="Share on Facebook" /></a>
<a href="http://pinterest.com/pin/create/button/?url=$url&description=$desc"><img style="vertical-align: middle; margin-bottom: .25em;" width="$redIconSize" height="$redIconSize" src="https://cdn1.iconfinder.com/data/icons/Pinterest/61/big-p-button.png" alt="Share on Pintrest" /></a>
<a href="http://twitter.com/intent/tweet?text=$desc%20-%20$url"><img style="vertical-align: middle; margin-bottom: .25em;" width="$blueiconSize" height="$blueiconSize" src="https://cdn3.iconfinder.com/data/icons/free-social-icons/67/twitter_square-64.png" alt="Share on Twitter" /></a>
<a href="https://plus.google.com/share?url=$url" onclick="javascript:window.open(this.href,'', 'menubar=no,toolbar=no,resizable=yes,scrollbars=yes,height=600,width=600');return false;"><img style="vertical-align: middle; margin-bottom: .25em;" width="$redIconSize" height="$redIconSize" src="https://www.gstatic.com/images/icons/gplus-64.png" alt="Share on Google+"/></a>
</div>
SOCIALTEMPLATE;
echo $template;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment