WordPress.org

Make WordPress Core

Changeset 18746


Ignore:
Timestamp:
09/22/2011 02:25:57 AM (9 years ago)
Author:
nacin
Message:

Detect current menu items for root-relative URLs. props filosofo, fixes #15954.

File:
1 edited

Legend:

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

    r17228 r18746  
    361361        // if the menu item corresponds to the currently-requested URL
    362362        } elseif ( 'custom' == $menu_item->object ) {
    363             $current_url = untrailingslashit( ( is_ssl() ? 'https://' : 'http://' ) . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'] );
     363            $_root_relative_current = untrailingslashit( $_SERVER['REQUEST_URI'] );
     364            $current_url = ( is_ssl() ? 'https://' : 'http://' ) . $_SERVER['HTTP_HOST'] . $_root_relative_current;
    364365            $item_url = untrailingslashit( strpos( $menu_item->url, '#' ) ? substr( $menu_item->url, 0, strpos( $menu_item->url, '#' ) ) : $menu_item->url );
    365366            $_indexless_current = untrailingslashit( preg_replace( '/index.php$/', '', $current_url ) );
    366367
    367             if ( in_array( $item_url, array( $current_url, $_indexless_current ) ) ) {
     368            if ( in_array( $item_url, array( $current_url, $_indexless_current, $_root_relative_current ) ) ) {
    368369                $classes[] = 'current-menu-item';
    369370                $menu_items[$key]->current = true;
Note: See TracChangeset for help on using the changeset viewer.