mirror of
https://github.com/gosticks/wordpress-develop.git
synced 2026-04-14 17:44:25 +00:00
Map nav menu locations on theme switch
This will send nav menu locations through three levels of mapping: 1. If both themes have only one location, that gets mapped. 2. If both themes have locations with the same slug, they get mapped. 3. Locations that (even partially) match slugs from a similar kind of menu location will get mapped. Menu locations are mapped for Live Previews in the Customizer and during theme switches. Props westonruter, obenland, welcher, melchoyce. Fixes #39692. git-svn-id: https://develop.svn.wordpress.org/trunk@41237 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
@@ -691,6 +691,7 @@ function switch_theme( $stylesheet ) {
|
||||
}
|
||||
|
||||
$nav_menu_locations = get_theme_mod( 'nav_menu_locations' );
|
||||
add_option( 'theme_switch_menu_locations', $nav_menu_locations );
|
||||
|
||||
if ( func_num_args() > 1 ) {
|
||||
$stylesheet = func_get_arg( 1 );
|
||||
@@ -731,13 +732,6 @@ 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