Make WordPress Core

Changeset 39570 for branches/4.7


Ignore:
Timestamp:
12/12/2016 01:56:53 AM (8 years ago)
Author:
dd32
Message:

Customize: Fix inability to delete nav menus by preventing preview filters from being added during customize_save admin ajax request.

Also prevent setting nav_menu_locations[...] values to NaN which gets sent as null.

Props westonruter.
See #30937, [38810].
Merges [39558] to the 4.7 branch.
Fixes #39103.

Location:
branches/4.7
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • branches/4.7

  • branches/4.7/src/wp-admin/js/customize-nav-menus.js

    r39503 r39570  
    11701170            // @todo It would be better if this was added directly on the setting itself, as opposed to the control.
    11711171            control.setting.validate = function( value ) {
    1172                 return parseInt( value, 10 );
     1172                if ( '' === value ) {
     1173                    return 0;
     1174                } else {
     1175                    return parseInt( value, 10 );
     1176                }
    11731177            };
    11741178
  • branches/4.7/src/wp-includes/class-wp-customize-nav-menus.php

    r39507 r39570  
    532532    public function customize_register() {
    533533
    534         /*
    535          * Preview settings for nav menus early so that the sections and controls will be added properly.
    536          * See https://github.com/xwp/wp-customize-snapshots/blob/962586659688a5b1fd9ae93618b7ce2d4e7a421c/php/class-customize-snapshot-manager.php#L506-L543
    537          */
     534        // Preview settings for nav menus early so that the sections and controls will be added properly.
    538535        $nav_menus_setting_ids = array();
    539536        foreach ( array_keys( $this->manager->unsanitized_post_values() ) as $setting_id ) {
     
    543540        }
    544541        $this->manager->add_dynamic_settings( $nav_menus_setting_ids );
    545         foreach ( $nav_menus_setting_ids as $setting_id ) {
    546             $setting = $this->manager->get_setting( $setting_id );
    547             if ( $setting ) {
    548                 $setting->preview();
     542        if ( ! $this->manager->doing_ajax( 'customize_save' ) ) {
     543            foreach ( $nav_menus_setting_ids as $setting_id ) {
     544                $setting = $this->manager->get_setting( $setting_id );
     545                if ( $setting ) {
     546                    $setting->preview();
     547                }
    549548            }
    550549        }
Note: See TracChangeset for help on using the changeset viewer.