diff --git a/src/wp-admin/js/customize-nav-menus.js b/src/wp-admin/js/customize-nav-menus.js index df696bd963..3b7af24302 100644 --- a/src/wp-admin/js/customize-nav-menus.js +++ b/src/wp-admin/js/customize-nav-menus.js @@ -1177,7 +1177,11 @@ // @todo It would be better if this was added directly on the setting itself, as opposed to the control. control.setting.validate = function( value ) { - return parseInt( value, 10 ); + if ( '' === value ) { + return 0; + } else { + return parseInt( value, 10 ); + } }; // Edit menu button. diff --git a/src/wp-includes/class-wp-customize-nav-menus.php b/src/wp-includes/class-wp-customize-nav-menus.php index ca1b72f7eb..49c92198fa 100644 --- a/src/wp-includes/class-wp-customize-nav-menus.php +++ b/src/wp-includes/class-wp-customize-nav-menus.php @@ -531,10 +531,7 @@ final class WP_Customize_Nav_Menus { */ public function customize_register() { - /* - * Preview settings for nav menus early so that the sections and controls will be added properly. - * See https://github.com/xwp/wp-customize-snapshots/blob/962586659688a5b1fd9ae93618b7ce2d4e7a421c/php/class-customize-snapshot-manager.php#L506-L543 - */ + // Preview settings for nav menus early so that the sections and controls will be added properly. $nav_menus_setting_ids = array(); foreach ( array_keys( $this->manager->unsanitized_post_values() ) as $setting_id ) { if ( preg_match( '/^(nav_menu_locations|nav_menu|nav_menu_item)\[/', $setting_id ) ) { @@ -542,10 +539,12 @@ final class WP_Customize_Nav_Menus { } } $this->manager->add_dynamic_settings( $nav_menus_setting_ids ); - foreach ( $nav_menus_setting_ids as $setting_id ) { - $setting = $this->manager->get_setting( $setting_id ); - if ( $setting ) { - $setting->preview(); + if ( ! $this->manager->doing_ajax( 'customize_save' ) ) { + foreach ( $nav_menus_setting_ids as $setting_id ) { + $setting = $this->manager->get_setting( $setting_id ); + if ( $setting ) { + $setting->preview(); + } } }