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. git-svn-id: https://develop.svn.wordpress.org/branches/4.7@39570 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
parent
1a84a32ffd
commit
ce5e63c224
@ -1169,7 +1169,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.
|
||||
|
@ -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();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user