Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@jaredatch
Last active August 29, 2015 14:04
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jaredatch/403ed19a27e24e19b176 to your computer and use it in GitHub Desktop.
Save jaredatch/403ed19a27e24e19b176 to your computer and use it in GitHub Desktop.
Easy share buttons
<?php
$url = urlencode( get_permalink() );
$img = urlencode( genesis_get_image( array( 'format' => 'url' ) ) );
$title = urlencode( get_the_title() );
echo '<a href="http://www.facebook.com/sharer/sharer.php?u=' . $url . '&t=' . $title .'" class="share-button facebook" target="_blank">Share on Facebook</a>';
echo '<a href="http://www.twitter.com/intent/tweet?url=' . $url . '&text=' . $title . '" class="share-button twitter" target="_blank">Tweet Me!</a>';
echo '<a href="http://pinterest.com/pin/create/button/?url=' . $url . '&media=' . $img . ' &description=' . $title . '" class="share-button pinterest" target="_blank">Pinterest</a>';
echo '<a href="http://plus.google.com/share?url=' . $url . '" class="share-button google" target="_blank">Google+</a>';
echo '<a href="http://www.linkedin.com/shareArticle?mini=true&url=' . $url . '" class="share-button linkedin" target="_blank">LinkedIn</a>';
echo '<a href="http://www.reddit.com/submit?url=' . $url . '" class="share-button reddit" target="_blank">LinkedIn</a>';
?>
jQuery(document).ready(function($){
$(".share-button").click(function(event){
event.preventDefault();
var window_size = "";
var url = this.href;
var domain = url.split("/")[2];
switch(domain) {
case "www.facebook.com":
window_size = "width=585,height=368";
break;
case "www.twitter.com":
window_size = "width=585,height=261";
break;
case "plus.google.com":
window_size = "width=517,height=511";
break;
case "www.pinterest.com":
window_size = "width=700,height=300";
break;
case "www.reddit.com":
window_size = "width=800,height=400";
break;
default:
window_size = "width=585,height=511";
}
window.open(url, '', 'menubar=no,toolbar=no,resizable=yes,scrollbars=yes,' + window_size);
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment