From a00f656cbce5ef4775525095af660dcb123775d2 Mon Sep 17 00:00:00 2001 From: ryan Date: Thu, 24 Jun 2010 17:39:29 +0000 Subject: [PATCH] Fix current page detection for home when index.php is in the requested URL. Props filosofo. fixes #13977 for 3.1 git-svn-id: http://svn.automattic.com/wordpress/trunk@15320 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- wp-includes/nav-menu-template.php | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/wp-includes/nav-menu-template.php b/wp-includes/nav-menu-template.php index b127cada6..a2a2ffbb1 100644 --- a/wp-includes/nav-menu-template.php +++ b/wp-includes/nav-menu-template.php @@ -351,7 +351,9 @@ function _wp_menu_item_classes_by_context( &$menu_items ) { } elseif ( 'custom' == $menu_item->object ) { $current_url = ( is_ssl() ? 'https://' : 'http://' ) . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI']; $item_url = strpos( $menu_item->url, '#' ) ? substr( $menu_item->url, 0, strpos( $menu_item->url, '#' ) ) : $menu_item->url; - if ( $item_url == $current_url ) { + $_indexless_current = preg_replace( '/index.php$/', '', $current_url ); + + if ( in_array( $item_url, array( $current_url, $_indexless_current ) ) ) { $classes[] = 'current-menu-item'; $_anc_id = (int) $menu_item->db_id; @@ -362,7 +364,7 @@ function _wp_menu_item_classes_by_context( &$menu_items ) { $active_ancestor_item_ids[] = $_anc_id; } - if ( untrailingslashit($current_url) == home_url() ) { + if ( in_array( home_url(), array( untrailingslashit( $current_url ), untrailingslashit( $_indexless_current ) ) ) ) { // Back compat for home limk to match wp_page_menu() $classes[] = 'current_page_item'; }