From 0c10eec60cac66e99d379d7be1829b5d339f4808 Mon Sep 17 00:00:00 2001 From: markjaquith Date: Mon, 6 Dec 2010 03:54:57 +0000 Subject: [PATCH] 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 --- wp-includes/nav-menu-template.php | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/wp-includes/nav-menu-template.php b/wp-includes/nav-menu-template.php index 3d15070844..f3407b072f 100644 --- a/wp-includes/nav-menu-template.php +++ b/wp-includes/nav-menu-template.php @@ -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 ); \ No newline at end of file +add_filter( 'nav_menu_item_id', '_nav_menu_item_id_use_once', 10, 2 );