Skip to content

Instantly share code, notes, and snippets.

@krmd
Created May 30, 2014 15:15
Show Gist options
  • Save krmd/ce7d3e36793dafd82a2a to your computer and use it in GitHub Desktop.
Save krmd/ce7d3e36793dafd82a2a to your computer and use it in GitHub Desktop.
WooTheme Canvas: Add Social Media Icons to Navigation
add_filter( 'wp_nav_menu_items', 'woo_custom_add_sociallink_navitems', 10, 2 );
function woo_custom_add_sociallink_navitems ( $items, $args ) {
global $woo_options;
if ( $args->theme_location == 'primary-menu' ) {
$template_directory = get_template_directory_uri();
$profiles = array(
'twitter' => __( 'Follow us on Twitter' , 'woothemes' ),
'facebook' => __( 'Connect on Facebook' , 'woothemes' ),
'youtube' => __( 'Watch on YouTube' , 'woothemes' ),
'flickr' => __( 'See photos on Flickr' , 'woothemes' ),
'linkedin' => __( 'Connect on LinkedIn' , 'woothemes' ),
'delicious' => __( 'Discover on Delicious' , 'woothemes' ),
'googleplus' => __( 'View Google+ profile' , 'woothemes' )
);
foreach ( $profiles as $key => $text ) {
if ( isset( $woo_options['woo_connect_' . $key] ) && $woo_options['woo_connect_' . $key] != '' ) {
$class = 'menu-item menu-item-type-social menu-item-object-social menu-item-' . $key;
$items .= '
<li id="menu-item-' . $key . '" class="' . $class . '">';
$items .= '<a class="' . $key .'" href="' . $woo_options['woo_connect_' . $key] . '" title="' . esc_attr( $text ) . '">';
$items .= '</a></li>
' . "
";
}
}
}
return $items;
} // End woo_custom_add_sociallink_navitems()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment