Ticket #14208: custom-menu-item-unslashed.14208.diff

File custom-menu-item-unslashed.14208.diff, 1.1 KB (added by filosofo, 3 years ago)
  • wp-includes/nav-menu-template.php

     
    349349 
    350350                // if the menu item corresponds to the currently-requested URL 
    351351                } elseif ( 'custom' == $menu_item->object ) { 
    352                         $current_url = ( is_ssl() ? 'https://' : 'http://' ) . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI']; 
    353                         $item_url = strpos( $menu_item->url, '#' ) ? substr( $menu_item->url, 0, strpos( $menu_item->url, '#' ) ) : $menu_item->url; 
    354                         $_indexless_current = preg_replace( '/index.php$/', '', $current_url ); 
     352                        $current_url = untrailingslashit( ( is_ssl() ? 'https://' : 'http://' ) . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'] ); 
     353                        $item_url = untrailingslashit( strpos( $menu_item->url, '#' ) ? substr( $menu_item->url, 0, strpos( $menu_item->url, '#' ) ) : $menu_item->url ); 
     354                        $_indexless_current = untrailingslashit( preg_replace( '/index.php$/', '', $current_url ) ); 
    355355                         
    356356                        if ( in_array( $item_url, array( $current_url, $_indexless_current ) ) ) { 
    357357                                $classes[] = 'current-menu-item';