Skip to content

Instantly share code, notes, and snippets.

@Dan0sz
Created October 21, 2018 12:57
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 Dan0sz/c311fa5d35322c6e9e55ed06658d4743 to your computer and use it in GitHub Desktop.
Save Dan0sz/c311fa5d35322c6e9e55ed06658d4743 to your computer and use it in GitHub Desktop.
Pure PHP template for Facebook, Twitter and Google+ Share Buttons
<?php
/* Social Share Buttons template for Wordpress
* By Daan van den Bergh
*/
$postUrl = 'http' . ( isset( $_SERVER['HTTPS'] ) ? 's' : '' ) . '://' . "{$_SERVER['HTTP_HOST']}{$_SERVER['REQUEST_URI']}"; ?>
<section class="sharing-box content-margin content-background clearfix">
<h5 class="sharing-box-name">Don't be selfish. Share the knowledge!</h5>
<div class="share-button-wrapper">
<a target="_blank" class="share-button share-twitter" href="https://twitter.com/intent/tweet?url=<?php echo $postUrl; ?>&text=<?php echo the_title(); ?>&via=<?php the_author_meta( 'twitter' ); ?>" title="Tweet this">Tweet this</a>
<a target="_blank" class="share-button share-facebook" href="https://www.facebook.com/sharer/sharer.php?u=<?php echo $postUrl; ?>" title="Share on Facebook">Share on Facebook</a>
<a target="_blank" class="share-button share-googleplus" href="https://plus.google.com/share?url=<?php echo $postUrl; ?>" title="Share on Google+">Share on Google+</a>
</div>
</section>
@richardkrone
Copy link

Is there associated CSS that should accompany this?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment