Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save iWebbers/469ef220e68118ae4bbed579558ab829 to your computer and use it in GitHub Desktop.
Save iWebbers/469ef220e68118ae4bbed579558ab829 to your computer and use it in GitHub Desktop.
// Get social share icons via shortcode: [iw_social_share_icons]
function iw_social_share_icons_function( $atts ) {
$title = get_the_title();
$excerpt = implode(' ', array_slice(str_word_count(wp_strip_all_tags(get_the_excerpt()),1), 0, 17)) . '...';
$image = get_the_post_thumbnail_url();
$permalink = get_permalink();
$author = get_the_author();
$folder = site_url() . '/wp-content/uploads/iwebbers/social-share-icons';
$class = ' class="uk-border-rounded"';
return
'
<div class="uk-grid-small uk-margin-top" uk-grid>
<div class="uk-width-1-2@m">
<div class="uk-grid-small uk-child-width-1-6" uk-grid>
<div>
<a href="http://twitter.com/intent/tweet?url=' . $permalink . '&text=' . $title . '" target="_blank">
<img src="' . $folder . '/iWebbers-social-share-twitter-icon.svg"' . $class . ' title="' . __( 'Share via Twitter', 'yoowoo' ) . '" alt="' . __( 'Share via Twitter', 'yoowoo' ) . '">
</a>
</div>
<div>
<a href="http://www.facebook.com/sharer.php?u=' . $permalink . '&amp;t=' . $title . '" target="_blank">
<img src="' . $folder . '/iWebbers-social-share-facebook-icon.svg"' . $class . ' title="' . __( 'Share via Facebook', 'yoowoo' ) . '" alt="' . __( 'Share via Facebook', 'yoowoo' ) . '">
</a>
</div>
<div>
<a href="http://www.linkedin.com/shareArticle?mini=true&url=' . $permalink . '&title=' . $title . '&summary=' . $excerpt . '&source=' . $author . '" target="_blank">
<img src="' . $folder . '/iWebbers-social-share-linkedin-icon.svg"' . $class . ' title="' . __( 'Share via LinkedIn', 'yoowoo' ) . '" alt="' . __( 'Share via LinkedIn', 'yoowoo' ) . '">
</a>
</div>
<div>
<a href="http://plus.google.com/share?url=' . $permalink . '" target="_blank">
<img src="' . $folder . '/iWebbers-social-share-google-plus-icon.svg"' . $class . ' title="' . __( 'Share via Google+', 'yoowoo' ) . '" alt="' . __( 'Share via Google+', 'yoowoo' ) . '">
</a>
</div>
<div class="uk-hidden@m">
<a href="whatsapp://send?text=' . $title . ' - ' . $permalink. '" target="_blank">
<img src="' . $folder . '/iWebbers-social-share-whatsapp-icon.svg"' . $class . ' title="' . __( 'Share via WhatsApp', 'yoowoo' ) . '" alt="' . __( 'Share via WhatsApp', 'yoowoo' ) . '">
</a>
</div>
<div class="uk-hidden@m">
<a href="http://telegram.me/share/url?url=' . $title . ' - ' . $permalink . '" target="_blank">
<img src="' . $folder . '/iWebbers-social-share-telegram-icon.svg"' . $class . ' title="' . __( 'Share via Telegram', 'yoowoo' ) . '" alt="' . __( 'Share via Telegram', 'yoowoo' ) . '">
</a>
</div>
</div>
</div>
</div>
';
}
add_shortcode('iw_social_share_icons', 'iw_social_share_icons_function');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment