[wp-trac] [WordPress Trac] #34893: Improve Customizer setting validation model
WordPress Trac
noreply at wordpress.org
Sun May 15 07:54:02 UTC 2016
#34893: Improve Customizer setting validation model
-------------------------------------------------+-------------------------
Reporter: westonruter | Owner:
Type: enhancement | westonruter
Priority: normal | Status: accepted
Component: Customize | Milestone: 4.6
Severity: normal | Version: 3.4
Keywords: has-patch needs-testing needs-unit- | Resolution:
tests | Focuses: javascript
-------------------------------------------------+-------------------------
Changes (by westonruter):
* keywords: has-patch needs-testing => has-patch needs-testing needs-unit-
tests
Comment:
Please see [attachment:34893.2.diff].
* Introduces `wp.customize.Notification` which can represent `WP_Error`
instances returned from the server.
* Introduces `wp.customize.Control.prototype.notifications`.
* Introduces `wp.customize.Setting.prototype.notifications`.
* Injects a notification area into existing controls which is populated in
response to the control's `notifications` collection changing, where this
collection is synced with the `notifications` collections for each of its
settings.
* Attempting to save settings that are invalid will result in the save
being blocked entirely, with the errors being sent in the
`customize_save_response` for the controls to display notifications for,
and the first such invalid control will be focused.
* Introduces `wp.customize.settingConstructor`, allowing custom setting
types to be used in the same way that custom controls, panels, and
sections can be made.
* Introduces `WP_Customize_Setting::validate()`,
`WP_Customize_Setting::$validate_callback`, and the
`customize_validate_{$setting_id}` filter.
* Modifies `WP_Customize_Manager::save()` to check all settings for
validity issues prior to calling their `save` methods.
* Introduces `WP_Customize_Setting::json()` for parity with the other
Customizer classes. This includes exporting of the `type`.
Needs more unit tests.
--
Ticket URL: <https://core.trac.wordpress.org/ticket/34893#comment:24>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list