Created
July 31, 2017 10:33
-
-
Save ahmedeshaan/9401356153954b70ba49221994011fb7 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function functions_to_change_mailto_link($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;" rel="nofollow" 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;" rel="nofollow" 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; ?>&body=Se%20det%20her%20fra%20Mambeno: %20<?php echo $permalink; ?>" rel="nofollow" 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; ?>&media=<?php echo $featured_image_2; ?>&description=<?php echo $post_title; ?>" onclick="window.open(this.href,this.title,'width=500,height=500,top=300px,left=300px'); return false;" rel="nofollow" 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;" rel="nofollow" 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;" rel="nofollow" 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;" rel="nofollow" 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;" rel="nofollow" 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', 'add_to_remove_tooltip_from_instagram' ); | |
function add_to_remove_tooltip_from_instagram() | |
{ remove_shortcode( 'share' ); | |
add_shortcode( 'share', 'functions_to_change_mailto_link' );} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment