Make WordPress Core


Ignore:
Timestamp:
02/24/2018 01:43:07 PM (6 years ago)
Author:
SergeyBiryukov
Message:

Menus: When checking if a Custom Link matches the current URL to add the current-menu-item class, check for decoded URL as well.

Props soulseekah, campusboy1987.
Fixes #43401.

File:
1 edited

Legend:

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

    r42343 r42732  
    442442                $_root_relative_current = strtok( untrailingslashit( $_SERVER['REQUEST_URI'] ), '?' );
    443443            }
     444
    444445            $current_url        = set_url_scheme( 'http://' . $_SERVER['HTTP_HOST'] . $_root_relative_current );
    445446            $raw_item_url       = strpos( $menu_item->url, '#' ) ? substr( $menu_item->url, 0, strpos( $menu_item->url, '#' ) ) : $menu_item->url;
     
    447448            $_indexless_current = untrailingslashit( preg_replace( '/' . preg_quote( $wp_rewrite->index, '/' ) . '$/', '', $current_url ) );
    448449
    449             if ( $raw_item_url && in_array( $item_url, array( $current_url, $_indexless_current, $_root_relative_current ) ) ) {
     450            $matches = array(
     451                $current_url,            urldecode( $current_url ),
     452                $_indexless_current,     urldecode( $_indexless_current ),
     453                $_root_relative_current, urldecode( $_root_relative_current ),
     454            );
     455
     456            if ( $raw_item_url && in_array( $item_url, $matches ) ) {
    450457                $classes[]                   = 'current-menu-item';
    451458                $menu_items[ $key ]->current = true;
Note: See TracChangeset for help on using the changeset viewer.