Make WordPress Core


Ignore:
Timestamp:
01/03/2012 06:15:16 PM (13 years ago)
Author:
nacin
Message:

Properly handle a blank nav menu custom URL when determining what page we're on. see #19699 for trunk.

File:
1 edited

Legend:

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

    r19593 r19657  
    363363            $_root_relative_current = untrailingslashit( $_SERVER['REQUEST_URI'] );
    364364            $current_url = ( is_ssl() ? 'https://' : 'http://' ) . $_SERVER['HTTP_HOST'] . $_root_relative_current;
    365             $item_url = untrailingslashit( strpos( $menu_item->url, '#' ) ? substr( $menu_item->url, 0, strpos( $menu_item->url, '#' ) ) : $menu_item->url );
     365            $raw_item_url = strpos( $menu_item->url, '#' ) ? substr( $menu_item->url, 0, strpos( $menu_item->url, '#' ) ) : $menu_item->url;
     366            $item_url = untrailingslashit( $raw_item_url );
    366367            $_indexless_current = untrailingslashit( preg_replace( '/index.php$/', '', $current_url ) );
    367368
    368             if ( in_array( $item_url, array( $current_url, $_indexless_current, $_root_relative_current ) ) ) {
     369            if ( $raw_item_url && in_array( $item_url, array( $current_url, $_indexless_current, $_root_relative_current ) ) ) {
    369370                $classes[] = 'current-menu-item';
    370371                $menu_items[$key]->current = true;
Note: See TracChangeset for help on using the changeset viewer.