Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save ahmedeshaan/b88bff0f63f78766e31b7e03bfce933c to your computer and use it in GitHub Desktop.
Save ahmedeshaan/b88bff0f63f78766e31b7e03bfce933c to your computer and use it in GitHub Desktop.
function my_shortcode_to_remove_nofollow_from_flatsome_share($atts, $content = null) {
extract(shortcode_atts(array(
'title' => '',
'size' => '',
'align' => '',
'scale' => '',
'style' => '',
), $atts));
// Get Custom Share icons if set
if(get_theme_mod('custom_share_icons')){
return do_shortcode(get_theme_mod('custom_share_icons'));
}
global $post;
if(!$post) return false;
$permalink = get_permalink($post->ID);
$featured_image = wp_get_attachment_image_src( get_post_thumbnail_id($post->ID), 'large');
$featured_image_2 = $featured_image['0'];
$post_title = rawurlencode(get_the_title($post->ID));
$whatsapp_text = rawurlencode($post_title.' - '.$permalink);
if($title) $title = '<span class="share-icons-title">'.$title.'</span>';
// Style default
// Get Custom Theme Style
if(!$style) $style = get_theme_mod('social_icons_style','outline');
$classes = get_flatsome_icon_class($style);
$classes = $classes.' tooltip';
$share = get_theme_mod('social_icons', array('facebook','twitter','email','linkedin','googleplus','pinterest','whatsapp'));
// Scale
if($scale) $scale = 'style="font-size:'.$scale.'%"';
// Align
if($align) $align = 'full-width text-'.$align;
// Fix old depricated
if(!isset($share[0])){
$fix_share = array();
foreach ($share as $key => $value) {
if($value == '1') $fix_share[] = $key;
}
$share = $fix_share;
}
ob_start();
?>
<div class="social-icons share-icons share-row relative icon-style-<?php echo $style; ?> <?php echo $align; ?>" <?php echo $scale;?>>
<?php echo $title; ?>
<?php if(in_array('whatsapp', $share)){ ?>
<a href="whatsapp://send?text=<?php echo $whatsapp_text; ?>" data-action="share/whatsapp/share" class="<?php echo $classes;?> whatsapp show-for-medium" title="<?php _e('Share on WhatsApp','flatsome'); ?>"><i class="icon-phone"></i></a>
<?php } if(in_array('facebook', $share)){ ?>
<a href="//www.facebook.com/sharer.php?u=<?php echo $permalink; ?>" data-label="Facebook" onclick="window.open(this.href,this.title,'width=500,height=500,top=300px,left=300px'); return false;" target="_blank" class="<?php echo $classes;?> facebook" title="<?php _e('Share on Facebook','flatsome'); ?>"><?php echo get_flatsome_icon('icon-facebook'); ?></a>
<?php } if(in_array('twitter', $share)){ ?>
<a href="//twitter.com/share?url=<?php echo $permalink; ?>" onclick="window.open(this.href,this.title,'width=500,height=500,top=300px,left=300px'); return false;" target="_blank" class="<?php echo $classes;?> twitter" title="<?php _e('Share on Twitter','flatsome'); ?>"><?php echo get_flatsome_icon('icon-twitter'); ?></a>
<?php } if(in_array('email', $share)){ ?>
<a href="mailto:[email protected]?subject=<?php echo $post_title; ?>&amp;body=Check%20this%20out:%20<?php echo $permalink; ?>" class="<?php echo $classes;?> email" title="<?php _e('Email to a Friend','flatsome'); ?>"><?php echo get_flatsome_icon('icon-envelop'); ?></a>
<?php } if(in_array('pinterest', $share)){ ?>
<a href="//pinterest.com/pin/create/button/?url=<?php echo $permalink; ?>&amp;media=<?php echo $featured_image_2; ?>&amp;description=<?php echo $post_title; ?>" onclick="window.open(this.href,this.title,'width=500,height=500,top=300px,left=300px'); return false;" target="_blank" class="<?php echo $classes;?> pinterest" title="<?php _e('Pin on Pinterest','flatsome'); ?>"><?php echo get_flatsome_icon('icon-pinterest'); ?></a>
<?php } if(in_array('googleplus', $share)){ ?>
<a href="//plus.google.com/share?url=<?php echo $permalink; ?>" target="_blank" class="<?php echo $classes;?> google-plus" onclick="window.open(this.href,this.title,'width=500,height=500,top=300px,left=300px'); return false;" title="<?php _e('Share on Google+','flatsome'); ?>"><?php echo get_flatsome_icon('icon-google-plus'); ?></a>
<?php } if(in_array('vk', $share)){ ?>
<a href="//vkontakte.ru/share.php?url=<?php echo $permalink; ?>" target="_blank" class="<?php echo $classes;?> vk" onclick="window.open(this.href,this.title,'width=500,height=500,top=300px,left=300px'); return false;" title="<?php _e('Share on VKontakte','flatsome'); ?>"><?php echo get_flatsome_icon('icon-vk'); ?></a>
<?php } if(in_array('linkedin', $share)){ ?>
<a href="//www.linkedin.com/shareArticle?mini=true&url=<?php echo $permalink; ?>&title=<?php echo $post_title; ?>" onclick="window.open(this.href,this.title,'width=500,height=500,top=300px,left=300px'); return false;" target="_blank" class="<?php echo $classes;?> linkedin" title="<?php _e('Share on LinkedIn','flatsome'); ?>"><?php echo get_flatsome_icon('icon-linkedin'); ?></a>
<?php } if(in_array('tumblr', $share)){ ?>
<a href="//tumblr.com/widgets/share/tool?canonicalUrl=<?php echo $permalink; ?>" target="_blank" class="<?php echo $classes;?> tumblr" onclick="window.open(this.href,this.title,'width=500,height=500,top=300px,left=300px'); return false;" title="<?php _e('Share on Tumblr','flatsome'); ?>"><?php echo get_flatsome_icon('icon-tumblr'); ?></a>
<?php } ?>
</div>
<?php
$content = ob_get_contents();
ob_end_clean();
return $content;
}
//add a custom shortcode
add_action( 'init', 'my_add_shortcodes_for_nofollow_remove_from_share' );
function my_add_shortcodes_for_nofollow_remove_from_share()
{ remove_shortcode( 'share' );
add_shortcode( 'share', 'my_shortcode_to_remove_nofollow_from_flatsome_share' );}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment