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: http://svn.automattic.com/wordpress/trunk@16742 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
markjaquith 2010-12-06 03:54:57 +00:00
parent 5cfe6c81cc
commit 0c10eec60c
1 changed files with 7 additions and 1 deletions

View File

@ -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 );