mackebryrsig
6/9/2017 - 6:53 AM

WordPress share.

WordPress share.

<?php
function macke_social_sharing_buttons() {
	global $post;

	// Get current page URL
	$url = urlencode(get_permalink());

	// Get current page title
	$title = str_replace( ' ', '%20', get_the_title());

	// Construct sharing URL without using any script
	$twitterURL = 'https://twitter.com/intent/tweet?text='.$title.'&amp;url='.$url.'&amp;via=WhistleB';
	$facebookURL = 'https://www.facebook.com/sharer/sharer.php?u='.$url;
	$linkedInURL = 'https://www.linkedin.com/shareArticle?mini=true&url='.$url.'&amp;title='.$url;

	// Add sharing button at the end of page/page content
	echo '<ul class="social-share">';
	echo '<li><span>'.__('Share article:').'</span></li>';
	echo '<li><a class="share-link share-twitter" href="'. $twitterURL .'" target="_blank"><i class="fa fa-twitter" aria-hidden="true"></i></a></li>';
	echo '<li><a class="share-link share-linkedin" href="'.$linkedInURL.'" target="_blank"><i class="fa fa-linkedin" aria-hidden="true"></i></a></li>';
	echo '<li><a class="share-link share-facebook" href="'.$facebookURL.'" target="_blank"><i class="fa fa-facebook" aria-hidden="true"></i></a></li>';
	echo '</ul>';

}