JoeHana
6/27/2013 - 8:52 PM

Add AddThis beside Social Icons (http://support.wpcasa.com/topic/add-this-button/)

Add AddThis beside Social Icons (http://support.wpcasa.com/topic/add-this-button/)

<?php

/**
 * Add AddThis beside Social Icons
 */
 
add_filter('wpcasa_social_icons_top', 'custom_social_icons_top');

function custom_social_icons_top() {
    
		// Check if social icons to display
		$nr = apply_filters( 'wpcasa_social_icons_nr', 5 );
				
		$social_icons = array();
		
		for( $i = 1; $i <= $nr; $i++ ) {				    
		    $social_icons[] = wpcasa_get_social_icon( wpcasa_get_option( 'icon_' . $i ) );				    
		}
		
		// Remove empty elements
		$social_icons = array_filter( $social_icons );
			
		// Loop through social icons
		
		if( ! empty( $social_icons ) ) {
		
			$i = 1;
			
			$output  = '<div id="top-right" class="span4">' . "\n";
			$output .= '<div class="social-icons">' . "\n";
			
			$output .= '<!– AddThis Button BEGIN –>';
			$output .= '<a class="addthis_button" href="http://www.addthis.com/bookmark.php?v=300&amp;pubid=[YOUR-ID]" style="margin: 0 10px 0 0;"><img src="http://s7.addthis.com/static/btn/v2/lg-share-en.gif" width="125" height="16" alt="Bookmark and Share" style="border:0"/></a>';
			$output .= '<script type="text/javascript" src="//s7.addthis.com/js/300/addthis_widget.js#pubid=[YOUR-ID]"></script>';
			$output .= '<!– AddThis Button END –>';
			
			foreach( $social_icons as $k => $v ) {				
				$social_link = wpcasa_get_option( 'icon_' . $i . '_link' );				    	
				$output .= '<a href="' . $social_link . '" target="_blank" title="' . $v['title'] . '" class="social-icon social-icon-' . $v['id'] . '"><img src="' . $v['icon'] . '" alt="" /></a>' . "\n";				    		
				$i++;				    		
			}
			
			$output .= '</div><!-- .social-icons -->' . "\n";
			$output .= '</div><!-- #top-right -->' . "\n";
			
			echo $output;
		}
	
}