WordPress.org

Make WordPress Core


Ignore:
Timestamp:
10/24/17 18:34:21 (4 weeks ago)
Author:
obenland
Message:

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.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/class-wp-customize-nav-menus.php

    r41956 r41995  
    530530     */ 
    531531    public function customize_register() { 
     532        $changeset = $this->manager->unsanitized_post_values(); 
    532533 
    533534        // Preview settings for nav menus early so that the sections and controls will be added properly. 
    534535        $nav_menus_setting_ids = array(); 
    535         foreach ( array_keys( $this->manager->unsanitized_post_values() ) as $setting_id ) { 
     536        foreach ( array_keys( $changeset ) as $setting_id ) { 
    536537            if ( preg_match( '/^(nav_menu_locations|nav_menu|nav_menu_item)\[/', $setting_id ) ) { 
    537538                $nav_menus_setting_ids[] = $setting_id; 
     
    628629 
    629630            // Override the assigned nav menu location if mapped during previewed theme switch. 
    630             if ( isset( $mapped_nav_menu_locations[ $location ] ) ) { 
     631            if ( empty( $changeset[ $setting_id ] ) && isset( $mapped_nav_menu_locations[ $location ] ) ) { 
    631632                $this->manager->set_post_value( $setting_id, $mapped_nav_menu_locations[ $location ] ); 
    632633            } 
Note: See TracChangeset for help on using the changeset viewer.