Skip to content

Instantly share code, notes, and snippets.

@nicomollet
Last active July 25, 2017 13:04
Show Gist options
  • Save nicomollet/12784012e236d902a58aa52cabe609d3 to your computer and use it in GitHub Desktop.
Save nicomollet/12784012e236d902a58aa52cabe609d3 to your computer and use it in GitHub Desktop.
Add gift icon the Shop menu item
<?php
/**
* Add gift icon the Shop menu item
*
* @param $sorted_menu_items
*
* @return mixed
*/
function gifticon_nav_menu_objects( $sorted_menu_items )
{
if ( in_array( 'woocommerce/woocommerce.php', apply_filters( 'active_plugins', get_option( 'active_plugins' ) ) ) ) {
$woocommerce_shop_page_id = get_option( 'woocommerce_shop_page_id' );
foreach ( $sorted_menu_items as $item ) {
if($item->object_id == $woocommerce_shop_page_id){
$item->attr_title = 'glyphicon-gift';
}
}
}
return $sorted_menu_items;
}
add_filter( 'wp_nav_menu_objects', 'gifticon_nav_menu_objects' );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment