Last active
July 25, 2017 13:04
-
-
Save nicomollet/12784012e236d902a58aa52cabe609d3 to your computer and use it in GitHub Desktop.
Add gift icon the Shop menu item
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
<?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