From eb658592dfbc9899146c4823a6fdf7e5f15f3bf7 Mon Sep 17 00:00:00 2001 From: Weston Ruter Date: Wed, 2 Aug 2017 05:11:44 +0000 Subject: [PATCH] Customize: For selective refresh of nav menus, prevent `preg_replace()` from dropping backslashes in JSON replaced into the `data-customize-partial-placement-context` HTML attribute. Props dlh, westonruter. Fixes #41488. Built from https://develop.svn.wordpress.org/trunk@41204 git-svn-id: http://core.svn.wordpress.org/trunk@41044 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- wp-includes/class-wp-customize-nav-menus.php | 4 ++-- wp-includes/version.php | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/wp-includes/class-wp-customize-nav-menus.php b/wp-includes/class-wp-customize-nav-menus.php index fdf45e5229..9b24fa0b67 100644 --- a/wp-includes/class-wp-customize-nav-menus.php +++ b/wp-includes/class-wp-customize-nav-menus.php @@ -1265,14 +1265,14 @@ final class WP_Customize_Nav_Menus { * * @param string $nav_menu_content The HTML content for the navigation menu. * @param object $args An object containing wp_nav_menu() arguments. - * @return null + * @return string Nav menu HTML with selective refresh attributes added if partial can be refreshed. */ public function filter_wp_nav_menu( $nav_menu_content, $args ) { if ( isset( $args->customize_preview_nav_menus_args['can_partial_refresh'] ) && $args->customize_preview_nav_menus_args['can_partial_refresh'] ) { $attributes = sprintf( ' data-customize-partial-id="%s"', esc_attr( 'nav_menu_instance[' . $args->customize_preview_nav_menus_args['args_hmac'] . ']' ) ); $attributes .= ' data-customize-partial-type="nav_menu_instance"'; $attributes .= sprintf( ' data-customize-partial-placement-context="%s"', esc_attr( wp_json_encode( $args->customize_preview_nav_menus_args ) ) ); - $nav_menu_content = preg_replace( '#^(<\w+)#', '$1 ' . $attributes, $nav_menu_content, 1 ); + $nav_menu_content = preg_replace( '#^(<\w+)#', '$1 ' . str_replace( '\\', '\\\\', $attributes ), $nav_menu_content, 1 ); } return $nav_menu_content; } diff --git a/wp-includes/version.php b/wp-includes/version.php index 0fcfe6749b..e0a0135d65 100644 --- a/wp-includes/version.php +++ b/wp-includes/version.php @@ -4,7 +4,7 @@ * * @global string $wp_version */ -$wp_version = '4.9-alpha-41200'; +$wp_version = '4.9-alpha-41204'; /** * Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.