Make WordPress Core


Ignore:
Timestamp:
08/02/2017 05:34:32 AM (9 years ago)
Author:
westonruter
Message:

Customize: Introduce settings_previewed arg and getter on WP_Customize_Manager which controls whether WP_Customize_Setting::preview() should be called on settings.

The settings_previewed property eliminates the need for the Customizer components from having to look at global doing_ajax state. This is in particular needed when saving settings, as some settings will short-circuit the update operation if they detect no changes are introduced. This is also needed for low-level integrations with the Customizer, such as in REST API endpoints under development.

Props stubgo, westonruter, utkarshpatel for testing.
See #38900.
Fixes #39221.

File:
1 edited

Legend:

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

    r41204 r41205  
    527527                        }
    528528                }
    529                 $this->manager->add_dynamic_settings( $nav_menus_setting_ids );
    530                 if ( ! $this->manager->doing_ajax( 'customize_save' ) ) {
    531                         foreach ( $nav_menus_setting_ids as $setting_id ) {
    532                                 $setting = $this->manager->get_setting( $setting_id );
    533                                 if ( $setting ) {
    534                                         $setting->preview();
    535                                 }
     529                $settings = $this->manager->add_dynamic_settings( $nav_menus_setting_ids );
     530                if ( $this->manager->settings_previewed() ) {
     531                        foreach ( $settings as $setting ) {
     532                                $setting->preview();
    536533                        }
    537534                }
Note: See TracChangeset for help on using the changeset viewer.