diff --git a/wp-includes/class-wp-customize-nav-menus.php b/wp-includes/class-wp-customize-nav-menus.php index 87e95009a3..d178de3e24 100644 --- a/wp-includes/class-wp-customize-nav-menus.php +++ b/wp-includes/class-wp-customize-nav-menus.php @@ -529,10 +529,11 @@ final class WP_Customize_Nav_Menus { * @since 4.3.0 */ public function customize_register() { + $changeset = $this->manager->unsanitized_post_values(); // Preview settings for nav menus early so that the sections and controls will be added properly. $nav_menus_setting_ids = array(); - foreach ( array_keys( $this->manager->unsanitized_post_values() ) as $setting_id ) { + foreach ( array_keys( $changeset ) as $setting_id ) { if ( preg_match( '/^(nav_menu_locations|nav_menu|nav_menu_item)\[/', $setting_id ) ) { $nav_menus_setting_ids[] = $setting_id; } @@ -627,7 +628,7 @@ final class WP_Customize_Nav_Menus { } // Override the assigned nav menu location if mapped during previewed theme switch. - if ( isset( $mapped_nav_menu_locations[ $location ] ) ) { + if ( empty( $changeset[ $setting_id ] ) && isset( $mapped_nav_menu_locations[ $location ] ) ) { $this->manager->set_post_value( $setting_id, $mapped_nav_menu_locations[ $location ] ); } diff --git a/wp-includes/theme.php b/wp-includes/theme.php index a69f4830cc..4e5f63bb8e 100644 --- a/wp-includes/theme.php +++ b/wp-includes/theme.php @@ -694,7 +694,7 @@ function switch_theme( $stylesheet ) { } $nav_menu_locations = get_theme_mod( 'nav_menu_locations' ); - add_option( 'theme_switch_menu_locations', $nav_menu_locations ); + update_option( 'theme_switch_menu_locations', $nav_menu_locations ); if ( func_num_args() > 1 ) { $stylesheet = func_get_arg( 1 ); @@ -2724,8 +2724,9 @@ function check_theme_switched() { if ( $stylesheet = get_option( 'theme_switched' ) ) { $old_theme = wp_get_theme( $stylesheet ); - // Prevent retrieve_widgets() from running since Customizer already called it up front + // Prevent widget & menu mapping from running since Customizer already called it up front if ( get_option( 'theme_switched_via_customizer' ) ) { + remove_action( 'after_switch_theme', '_wp_menus_changed' ); remove_action( 'after_switch_theme', '_wp_sidebars_changed' ); update_option( 'theme_switched_via_customizer', false ); } diff --git a/wp-includes/version.php b/wp-includes/version.php index b95739da49..bcc51f5d35 100644 --- a/wp-includes/version.php +++ b/wp-includes/version.php @@ -4,7 +4,7 @@ * * @global string $wp_version */ -$wp_version = '4.9-beta3-41994'; +$wp_version = '4.9-beta3-41995'; /** * Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.