Make WordPress Core

Changeset 15320


Ignore:
Timestamp:
06/24/2010 05:39:29 PM (15 years ago)
Author:
ryan
Message:

Fix current page detection for home when index.php is in the requested URL. Props filosofo. fixes #13977 for 3.1

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/wp-includes/nav-menu-template.php

    r15302 r15320  
    352352            $current_url = ( is_ssl() ? 'https://' : 'http://' ) . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'];
    353353            $item_url = strpos( $menu_item->url, '#' ) ? substr( $menu_item->url, 0, strpos( $menu_item->url, '#' ) ) : $menu_item->url;
    354             if ( $item_url == $current_url ) {
     354            $_indexless_current = preg_replace( '/index.php$/', '', $current_url );
     355           
     356            if ( in_array( $item_url, array( $current_url, $_indexless_current ) ) ) {
    355357                $classes[] = 'current-menu-item';
    356358                $_anc_id = (int) $menu_item->db_id;
     
    363365                }
    364366
    365                 if ( untrailingslashit($current_url) == home_url() ) {
     367                if ( in_array( home_url(), array( untrailingslashit( $current_url ), untrailingslashit( $_indexless_current ) ) ) ) {
    366368                    // Back compat for home limk to match wp_page_menu()
    367369                    $classes[] = 'current_page_item';
Note: See TracChangeset for help on using the changeset viewer.