From 828dff99e9db98d02354b9a3f3ee5b33244bb259 Mon Sep 17 00:00:00 2001 From: Konstantin Obenland Date: Tue, 10 Oct 2017 17:05:01 +0000 Subject: [PATCH] Customizer: Account for legacy menu data Checks for menu location data from when a previewed theme was previously active. See #39692. git-svn-id: https://develop.svn.wordpress.org/trunk@41810 602fd350-edb4-49c9-b593-d223f7449a82 --- src/wp-includes/class-wp-customize-nav-menus.php | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/wp-includes/class-wp-customize-nav-menus.php b/src/wp-includes/class-wp-customize-nav-menus.php index b15c9dce5b..3243c12c59 100644 --- a/src/wp-includes/class-wp-customize-nav-menus.php +++ b/src/wp-includes/class-wp-customize-nav-menus.php @@ -597,7 +597,14 @@ final class WP_Customize_Nav_Menus { // Attempt to re-map the nav menu location assignments when previewing a theme switch. $mapped_nav_menu_locations = array(); if ( ! $this->manager->is_theme_active() ) { - $mapped_nav_menu_locations = wp_map_nav_menu_locations( get_nav_menu_locations(), $this->original_nav_menu_locations ); + $theme_mods = get_option( 'theme_mods_' . $this->manager->get_stylesheet(), array() ); + + // If there is no data from a previous activation, start fresh. + if ( empty( $theme_mods['nav_menu_locations'] ) ) { + $theme_mods['nav_menu_locations'] = array(); + } + + $mapped_nav_menu_locations = wp_map_nav_menu_locations( $theme_mods['nav_menu_locations'], $this->original_nav_menu_locations ); } foreach ( $locations as $location => $description ) {