WordPress.org

Make WordPress Core

Ticket #15954: root_relative_current.15954.2.diff

File root_relative_current.15954.2.diff, 1.2 KB (added by filosofo, 3 years ago)
  • wp-includes/nav-menu-template.php

     
    360360 
    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; 
    370371                                $_anc_id = (int) $menu_item->db_id;