mirror of
https://github.com/gosticks/wordpress-develop.git
synced 2026-08-11 12:20:22 +00:00
Customize: Ensure that a setting (especially a multidimensional one) can still be previewed when the post value to preview is set after preview() is invoked.
* Introduce `customize_post_value_set_{$setting_id}` and `customize_post_value_set` actions which are done when `WP_Customize_Manager::set_post_value()` is called.
* Clear the `preview_applied` flag for aggregated multidimensional settings when a post value is set. This ensures the new value is used instead of a previously-cached previewed value.
* Move `$is_preview` property from subclasses to `WP_Customize_Setting` parent class.
* Deferred preview: Ensure that when `preview()` short-circuits due to not being applicable that it will be called again later when the post value is set.
* Populate post value for updated-widget with the (unsanitized) JS-value in `WP_Customize_Widgets::call_widget_update()` so that value will be properly sanitized when accessed in `WP_Customize_Manager::post_value()`.
Includes unit tests with assertions to check the reported issues and validate the fixes.
Fixes defect introduced in [35007].
See #32103.
Fixes #34738.
git-svn-id: https://develop.svn.wordpress.org/trunk@35724 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
@@ -659,6 +659,36 @@ final class WP_Customize_Manager {
|
||||
public function set_post_value( $setting_id, $value ) {
|
||||
$this->unsanitized_post_values();
|
||||
$this->_post_values[ $setting_id ] = $value;
|
||||
|
||||
/**
|
||||
* Announce when a specific setting's unsanitized post value has been set.
|
||||
*
|
||||
* Fires when the {@see WP_Customize_Manager::set_post_value()} method is called.
|
||||
*
|
||||
* The dynamic portion of the hook name, `$setting_id`, refers to the setting ID.
|
||||
*
|
||||
* @since 4.4.0
|
||||
*
|
||||
* @param mixed $value Unsanitized setting post value.
|
||||
* @param WP_Customize_Manager $this WP_Customize_Manager instance.
|
||||
*/
|
||||
do_action( "customize_post_value_set_{$setting_id}", $value, $this );
|
||||
|
||||
/**
|
||||
* Announce when any setting's unsanitized post value has been set.
|
||||
*
|
||||
* Fires when the {@see WP_Customize_Manager::set_post_value()} method is called.
|
||||
*
|
||||
* This is useful for <code>WP_Customize_Setting</code> instances to watch
|
||||
* in order to update a cached previewed value.
|
||||
*
|
||||
* @since 4.4.0
|
||||
*
|
||||
* @param string $setting_id Setting ID.
|
||||
* @param mixed $value Unsanitized setting post value.
|
||||
* @param WP_Customize_Manager $this WP_Customize_Manager instance.
|
||||
*/
|
||||
do_action( 'customize_post_value_set', $setting_id, $value, $this );
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user