Customize: Allow previewed menus to be customized

Fixes a bug where menu assignements couldn't be changed when previewing a theme.
Also removes an unnecessary call to menu mapping after a theme switch from the customizer and makes sure the locations option is always written, for good measure.

Props westonruter.
See #39692.


git-svn-id: https://develop.svn.wordpress.org/trunk@41995 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Konstantin Obenland
2017-10-24 18:34:21 +00:00
parent a411d5571a
commit 619f0b4b34
2 changed files with 6 additions and 4 deletions

View File

@@ -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 );
}