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
This commit is contained in:
parent
0d3f30ba61
commit
32110c7f77
|
@ -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() );
|
||||
|
|
|
@ -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.
|
||||
|
|
Loading…
Reference in New Issue