From 32110c7f77638f83b2e7e7c263e6c225d0b11940 Mon Sep 17 00:00:00 2001 From: Scott Taylor Date: Sun, 30 Aug 2015 03:01:21 +0000 Subject: [PATCH] Switching themes: if the new theme doesn't have `nav_menu_locations` defined, but the old theme does, copy the old theme's `nav_menu_locations` into the new theme's theme mods. cc melchoyce Fixes #18588. Built from https://develop.svn.wordpress.org/trunk@33808 git-svn-id: http://core.svn.wordpress.org/trunk@33776 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- wp-includes/theme.php | 12 ++++++++++++ wp-includes/version.php | 2 +- 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/wp-includes/theme.php b/wp-includes/theme.php index ae12810961..a9f0e6ed8d 100644 --- a/wp-includes/theme.php +++ b/wp-includes/theme.php @@ -688,6 +688,8 @@ function switch_theme( $stylesheet ) { set_theme_mod( 'sidebars_widgets', array( 'time' => time(), 'data' => $_sidebars_widgets ) ); } + $nav_menu_locations = get_theme_mod( 'nav_menu_locations' ); + $old_theme = wp_get_theme(); $new_theme = wp_get_theme( $stylesheet ); @@ -716,6 +718,9 @@ function switch_theme( $stylesheet ) { // Migrate from the old mods_{name} option to theme_mods_{slug}. if ( is_admin() && false === get_option( 'theme_mods_' . $stylesheet ) ) { $default_theme_mods = (array) get_option( 'mods_' . $new_name ); + if ( ! empty( $nav_menu_locations ) && empty( $default_theme_mods['nav_menu_locations'] ) ) { + $default_theme_mods['nav_menu_locations'] = $nav_menu_locations; + } add_option( "theme_mods_$stylesheet", $default_theme_mods ); } else { /* @@ -726,6 +731,13 @@ function switch_theme( $stylesheet ) { if ( 'wp_ajax_customize_save' === current_action() ) { remove_theme_mod( 'sidebars_widgets' ); } + + if ( ! empty( $nav_menu_locations ) ) { + $nav_mods = get_theme_mod( 'nav_menu_locations' ); + if ( empty( $nav_mods ) ) { + set_theme_mod( 'nav_menu_locations', $nav_menu_locations ); + } + } } update_option( 'theme_switched', $old_theme->get_stylesheet() ); diff --git a/wp-includes/version.php b/wp-includes/version.php index a8d16b2f97..b454f45983 100644 --- a/wp-includes/version.php +++ b/wp-includes/version.php @@ -4,7 +4,7 @@ * * @global string $wp_version */ -$wp_version = '4.4-alpha-33807'; +$wp_version = '4.4-alpha-33808'; /** * Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.