LeoLopesWeb
5/19/2019 - 10:10 PM

custom follow social shortcode - flatsome

[follow style="small" facebook="#" instagram="#" twitter="#" linkedin="#" pinterest="#" youtube="#"]

// [follow]
function custom_flatsome_follow($atts, $content = null) {
	$sliderrandomid = rand();
	extract(shortcode_atts(array(
		'title' => '',
		'class' => '',
		'visibility' => '',
		'style' => 'outline',
		'align' => '',
		'scale' => '',
		'defaults' => '',
		'twitter' => '',
		'facebook' => '',
		'pinterest' => '',
		'email' => '',
		'phone' => '',
		'googleplus' => '',
		'instagram' => '',
		'rss' => '',
		'linkedin' => '',
		'youtube' => '',
		'flickr' => '',
		'vkontakte' => '',
		'px500' => '',
		'snapchat' => '',

		// Depricated
		'size' => '',

	), $atts));
	ob_start();


	$wrapper_class = array('social-icons','follow-icons');
	if( $class ) $wrapper_class[] = $class;
	if( $visibility ) $wrapper_class[] = $visibility;
	if( $align ) {
		$wrapper_class[] = 'full-width';
		$wrapper_class[] = 'text-'.$align;
	}


	// Get Defaults
	if($defaults){
		$twitter = get_theme_mod('follow_twitter');
		$facebook = get_theme_mod('follow_facebook');
		$instagram = get_theme_mod('follow_instagram');
		$snapchat = get_theme_mod('follow_snapchat');
		$youtube = get_theme_mod('follow_youtube');
		$pinterest = get_theme_mod('follow_pinterest');
		$googleplus = get_theme_mod('follow_google');
		$linkedin = get_theme_mod('follow_linkedin');
		$px500 = get_theme_mod('follow_500px');
		$vkontakte = get_theme_mod('follow_vk');
		$flickr = get_theme_mod('follow_flickr');
		$email = get_theme_mod('follow_email');
		$phone = get_theme_mod('follow_phone');
		$rss = get_theme_mod('follow_rss');
	}

	if($size == 'small') $style = 'small';
	$style = get_flatsome_icon_class($style);

	// Scale
	if($scale) $scale = 'style="font-size:'.$scale.'%"';
	

	?>
    <div class="<?php echo implode(' ', $wrapper_class); ?>" <?php echo $scale;?>>
    	<?php if($title){?>
			<span><?php echo $title; ?></span>
			<?php }?>
		<?php if($twitter){?>
	       <a href="<?php echo $twitter; ?> "target="_blank"><i class="svgi twitter"></i>
	       </a>
		<?php }?>
    	<?php if($facebook){?>
    	<a href="<?php echo $facebook; ?>" target="_blank"><i class="svgi facebook"></i>
    	</a>
		<?php }?>
		<?php if($instagram){?>
		    <a href="<?php echo $instagram; ?>" target="_blank"><i class="svgi instagram"></i>
			 </a>
		<?php }?>
		<?php if($youtube){?>
		       <a href="<?php echo $youtube; ?>" target="_blank"><i class="svgi youtube"></i>
		       </a>
		<?php }?>
		<?php if($snapchat){?>
		    <a href="#" data-open="#follow-snapchat-lightbox" data-color="dark" data-pos="center" target="_blank" rel="noopener noreferrer nofollow" data-label="SnapChat" class="<?php echo $style; ?> snapchat tooltip" title="<?php _e('Follow on SnapChat','flatsome')?>"><?php echo get_flatsome_icon('icon-snapchat'); ?>
		   </a>
		   <div id="follow-snapchat-lightbox" class="mfp-hide">
		   		<div class="text-center">
			   		<?php echo do_shortcode(flatsome_get_image($snapchat)) ;?>
			   		<p><?php _e('Point the SnapChat camera at this to add us to SnapChat.','flatsome'); ?></p>
		   		</div>
		   </div>
		
		<?php }?>
		<?php if($email){?>
		     <a href="mailto:<?php echo $email; ?>" data-label="E-mail"  rel="nofollow" class="<?php echo $style; ?>  email tooltip" title="<?php _e('Send us an email','flatsome') ?>"><?php echo get_flatsome_icon('icon-envelop'); ?>
			</a>
		<?php }?>
	    <?php if($phone){?>
			<a href="tel:<?php echo $phone; ?>" target="_blank"  data-label="Phone"  rel="noopener noreferrer nofollow" class="<?php echo $style; ?>  phone tooltip" title="<?php _e('Call us','flatsome') ?>"><?php echo get_flatsome_icon('icon-phone'); ?>
			</a>
	    <?php }?>
		<?php if($pinterest){?>
		       <a href="<?php echo $pinterest; ?>" target="_blank"><i class="svgi pinterest"></i></a>
		       </a>
		<?php }?>
		<?php if($googleplus){?>
		       <a href="<?php echo $googleplus; ?>" target="_blank" rel="noopener noreferrer nofollow"  data-label="Google+"  class="<?php echo $style; ?>  google-plus tooltip" title="<?php _e('Follow on Google+','flatsome')?>"><?php echo get_flatsome_icon('icon-google-plus'); ?>
		       </a>
		<?php }?>
		<?php if($rss){?>
		       <a href="<?php echo $rss; ?>" target="_blank" rel="noopener noreferrer nofollow" data-label="RSS Feed" class="<?php echo $style; ?>  rss tooltip" title="<?php _e('Subscribe to RSS','flatsome') ?>"><?php echo get_flatsome_icon('icon-feed'); ?></a>
		<?php }?>
		<?php if($linkedin){?>
		       <a href="<?php echo $linkedin; ?>" target="_blank"><i class="svgi linkedin"></i></a>		
		<?php }?>
		<?php if($flickr){?>
		       <a href="<?php echo $flickr; ?>" target="_blank" rel="noopener noreferrer nofollow" data-label="Flickr" class="<?php echo $style; ?>  flickr tooltip" title="<?php _e('Flickr','flatsome') ?>"><?php echo get_flatsome_icon('icon-flickr'); ?>
		       </a>
		<?php }?>
		<?php if($px500){?>
		     <a href="<?php echo $px500; ?>" target="_blank"  data-label="500px"  rel="noopener noreferrer nofollow" class="<?php echo $style; ?> px500 tooltip" title="<?php _e('Follow on 500px','flatsome') ?>"><?php echo get_flatsome_icon('icon-500px'); ?>
			</a>
		<?php }?>
		<?php if($vkontakte){?>
		       <a href="<?php echo $vkontakte; ?>" target="_blank" data-label="VKontakte" rel="noopener noreferrer nofollow" class="<?php echo $style; ?> vk tooltip" title="<?php _e('Follow on VKontakte','flatsome') ?>"><?php echo get_flatsome_icon('icon-vk'); ?>
		       </a>
		<?php }?>
     </div>

	<?php
	$content = ob_get_contents();
	ob_end_clean();
	$content = flatsome_sanitize_whitespace_chars( $content);
	return $content;
}


//add a custom shortcode 
add_action( 'init', 'my_add_shortcodes' );
function my_add_shortcodes() {  
  remove_shortcode( 'follow' );   
  add_shortcode( 'follow', 'custom_flatsome_follow' )
;}