mirror of
https://github.com/gosticks/wordpress-develop.git
synced 2026-08-11 20:30:23 +00:00
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. git-svn-id: https://develop.svn.wordpress.org/trunk@33808 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
@@ -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() );
|
||||
|
||||
Reference in New Issue
Block a user