Skip to content

Instantly share code, notes, and snippets.

@celticwebdesign
Created December 21, 2015 10:37
Show Gist options
  • Save celticwebdesign/d84adc8327e143293261 to your computer and use it in GitHub Desktop.
Save celticwebdesign/d84adc8327e143293261 to your computer and use it in GitHub Desktop.
Twitter share pop-up
JS ----
$('a.share_twitter').click(function(e) {
e.preventDefault();
var width = 520,
height = 350,
left = ($(window).width() - width) / 2,
top = ($(window).height() - height) / 2,
url = this.href,
opts = 'status=1' +
',width=' + width +
',height=' + height +
',top=' + top +
',left=' + left;
window.open(url, 'twitter', opts);
return false;
});
PHP & WordPress ----
echo "<li>
<a href='http://twitter.com/share?text=".urlencode(get_the_title()." - ".get_field('cottage_long_location_name'))."' class='share_twitter'><i class='fa fa-twitter'></i></a>
</li>";
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment