Highlight home page Custom Nav Menu item even when extra query args are present in the URL (only if all other highlights fail). props filosofo. fixes #13994
git-svn-id: https://develop.svn.wordpress.org/trunk@16742 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
parent
67ca818f87
commit
f2702dd794
@ -311,6 +311,8 @@ function _wp_menu_item_classes_by_context( &$menu_items ) {
|
||||
|
||||
$possible_object_parents = array_filter( $possible_object_parents );
|
||||
|
||||
$front_page_url = home_url();
|
||||
|
||||
foreach ( (array) $menu_items as $key => $menu_item ) {
|
||||
|
||||
$menu_items[$key]->current = false;
|
||||
@ -381,6 +383,10 @@ function _wp_menu_item_classes_by_context( &$menu_items ) {
|
||||
$active_parent_item_ids[] = (int) $menu_item->menu_item_parent;
|
||||
$active_parent_object_ids[] = (int) $menu_item->post_parent;
|
||||
$active_object = $menu_item->object;
|
||||
|
||||
// give front page item current-menu-item class when extra query arguments involved
|
||||
} elseif ( $item_url == $front_page_url && is_front_page() ) {
|
||||
$classes[] = 'current-menu-item';
|
||||
}
|
||||
|
||||
if ( untrailingslashit($item_url) == home_url() )
|
||||
@ -477,4 +483,4 @@ function _nav_menu_item_id_use_once( $id, $item ) {
|
||||
$_used_ids[] = $item->ID;
|
||||
return $id;
|
||||
}
|
||||
add_filter( 'nav_menu_item_id', '_nav_menu_item_id_use_once', 10, 2 );
|
||||
add_filter( 'nav_menu_item_id', '_nav_menu_item_id_use_once', 10, 2 );
|
||||
|
Loading…
Reference in New Issue
Block a user