WordPress.org

Make WordPress Core

Changeset 33808


Ignore:
Timestamp:
08/30/2015 03:00:45 AM (6 years ago)
Author:
wonderboymusic
Message:

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.

File:
1 edited

Legend:

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

    r33694 r33808  
    689689    }
    690690
     691    $nav_menu_locations = get_theme_mod( 'nav_menu_locations' );
     692
    691693    $old_theme  = wp_get_theme();
    692694    $new_theme = wp_get_theme( $stylesheet );
     
    717719    if ( is_admin() && false === get_option( 'theme_mods_' . $stylesheet ) ) {
    718720        $default_theme_mods = (array) get_option( 'mods_' . $new_name );
     721        if ( ! empty( $nav_menu_locations ) && empty( $default_theme_mods['nav_menu_locations'] ) ) {
     722            $default_theme_mods['nav_menu_locations'] = $nav_menu_locations;
     723        }
    719724        add_option( "theme_mods_$stylesheet", $default_theme_mods );
    720725    } else {
     
    726731        if ( 'wp_ajax_customize_save' === current_action() ) {
    727732            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            }
    728740        }
    729741    }
Note: See TracChangeset for help on using the changeset viewer.