Make WordPress Core


Ignore:
Timestamp:
08/09/2017 09:03:16 PM (7 years ago)
Author:
obenland
Message:

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.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/theme.php

    r41219 r41237  
    692692
    693693    $nav_menu_locations = get_theme_mod( 'nav_menu_locations' );
     694    add_option( 'theme_switch_menu_locations', $nav_menu_locations );
    694695
    695696    if ( func_num_args() > 1 ) {
     
    731732        if ( 'wp_ajax_customize_save' === current_action() ) {
    732733            remove_theme_mod( 'sidebars_widgets' );
    733         }
    734 
    735         if ( ! empty( $nav_menu_locations ) ) {
    736             $nav_mods = get_theme_mod( 'nav_menu_locations' );
    737             if ( empty( $nav_mods ) ) {
    738                 set_theme_mod( 'nav_menu_locations', $nav_menu_locations );
    739             }
    740734        }
    741735    }
Note: See TracChangeset for help on using the changeset viewer.