From b2018dc679c85fe0c8ad3cfe712357d132d3ab59 Mon Sep 17 00:00:00 2001 From: Adam Silverstein Date: Fri, 12 May 2017 20:34:43 +0000 Subject: [PATCH] Customizer: Fix an issue with menu classes in the customizer preview. In customizer preview, strip changeset uuid in menu urls before comparing with current url to determine menu item classes. In the customizer, menu items now contain a changeset uuid as part of their urls. Strip the changeset uuid off the url before comparing with current url (which lacks the changeset uuid). Props priyankabehera155, jipmoors. Fixes #39758. git-svn-id: https://develop.svn.wordpress.org/trunk@40658 602fd350-edb4-49c9-b593-d223f7449a82 --- src/wp-includes/nav-menu-template.php | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/wp-includes/nav-menu-template.php b/src/wp-includes/nav-menu-template.php index 3c517d150f..737d6e6c2f 100644 --- a/src/wp-includes/nav-menu-template.php +++ b/src/wp-includes/nav-menu-template.php @@ -397,6 +397,11 @@ function _wp_menu_item_classes_by_context( &$menu_items ) { // if the menu item corresponds to the currently-requested URL } elseif ( 'custom' == $menu_item->object && isset( $_SERVER['HTTP_HOST'] ) ) { $_root_relative_current = untrailingslashit( $_SERVER['REQUEST_URI'] ); + + //if it is the customize page then it will strips the query var off the url before entering the comparison block. + if ( is_customize_preview() ) { + $_root_relative_current = strtok( untrailingslashit( $_SERVER['REQUEST_URI'] ), '?' ); + } $current_url = set_url_scheme( 'http://' . $_SERVER['HTTP_HOST'] . $_root_relative_current ); $raw_item_url = strpos( $menu_item->url, '#' ) ? substr( $menu_item->url, 0, strpos( $menu_item->url, '#' ) ) : $menu_item->url; $item_url = set_url_scheme( untrailingslashit( $raw_item_url ) );