WordPress/wp-admin
Weston Ruter 87b0a1b989 Customize: Add setting validation model and control notifications to augment setting sanitization.
When a setting is invalid, not only will it be blocked from being saved but all other settings will be blocked as well. This ensures that Customizer saves aren't partial but are more transactional. User will be displayed the error in a notification so that they can fix and re-attempt saving.

PHP changes:

* Introduces `WP_Customize_Setting::validate()`, `WP_Customize_Setting::$validate_callback`, and the `customize_validate_{$setting_id}` filter.
* Introduces `WP_Customize_Manager::validate_setting_values()` to do validation (and sanitization) for the setting values supplied, returning a list of `WP_Error` instances for invalid 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`. 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`.
* Modifies `WP_Customize_Manager::post_value()` to apply `validate` after `sanitize`, and if validation fails, to return the `$default`.
* Introduces `customize_save_validation_before` action which fires right before the validation checks are made prior to saving.

JS changes:

* Introduces `wp.customize.Notification` in JS which to represent `WP_Error` instances returned from the server when setting validation fails.
* Introduces `wp.customize.Setting.prototype.notifications`.
* Introduces `wp.customize.Control.prototype.notifications`, which are synced with a control's settings' notifications.
* Introduces `wp.customize.Control.prototype.renderNotifications()` to re-render a control's notifications in its notification area. This is called automatically when the notifications collection changes.
* Introduces `wp.customize.settingConstructor`, allowing custom setting types to be used in the same way that custom controls, panels, and sections can be made.
* Injects a notification area into existing controls which is populated in response to the control's `notifications` collection changing. A custom control can customize the placement of the notification area by overriding the new `getNotificationsContainerElement` method.
* When a save fails due to setting invalidity, the invalidity errors will be added to the settings to then populate in the controls' notification areas, and the first such invalid control will be focused.

Props westonruter, celloexpressions, mrahmadawais.
See #35210.
See #30937.
Fixes #34893.

Built from https://develop.svn.wordpress.org/trunk@37476


git-svn-id: http://core.svn.wordpress.org/trunk@37444 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2016-05-20 21:10:27 +00:00
..
css Customize: Add setting validation model and control notifications to augment setting sanitization. 2016-05-20 21:10:27 +00:00
images
includes Refine the FTP credentials form interaction. 2016-05-19 22:59:28 +00:00
js Customize: Add setting validation model and control notifications to augment setting sanitization. 2016-05-20 21:10:27 +00:00
maint
network Multisite: Filter the links displayed on "Edit Site" views 2016-05-19 21:48:30 +00:00
user
about.php About Page: Add Final Video 2016-04-12 17:25:28 +00:00
admin-ajax.php
admin-footer.php Administration: Introduce admin_print_footer_scripts-$hook_suffix", a dynamic version of the admin_print_footer_scripts hook. 2016-04-21 15:17:27 +00:00
admin-functions.php
admin-header.php
admin-post.php
admin.php Docs: Standardize on 'backward compatibility/compatible' nomenclature in core inline docs. 2016-05-13 18:41:31 +00:00
async-upload.php
comment.php Make Moderate Comment Screen Great Again by showing links 2016-04-06 00:35:27 +00:00
credits.php Credits: Add a missing closing tag. 2016-05-14 18:58:31 +00:00
custom-background.php
custom-header.php
customize.php Accessibility: Customizer, improve UI controls in customize.php 2016-04-17 15:41:27 +00:00
edit-comments.php
edit-form-advanced.php
edit-form-comment.php
edit-link-form.php
edit-tag-form.php
edit-tags.php Accessibility: make the tab order match the visual order in the Edit terms screens. 2016-05-16 13:02:29 +00:00
edit.php
export.php
freedoms.php
import.php
index.php Docs: Remove inline @see tags from function, class, and method references in inline docs. 2016-05-02 04:00:28 +00:00
install-helper.php
install.php
link-add.php
link-manager.php
link-parse-opml.php
link.php
load-scripts.php Bootstrap/Load: Allow for ABSPATH to be defined outside of wp-load.php, e.g. in a script loaded via auto_prepend_file. 2016-04-14 17:53:28 +00:00
load-styles.php Bootstrap/Load: Allow for ABSPATH to be defined outside of wp-load.php, e.g. in a script loaded via auto_prepend_file. 2016-04-14 17:53:28 +00:00
media-new.php
media-upload.php
media.php
menu-header.php
menu.php Docs: Standardize on 'backward compatibility/compatible' nomenclature in core inline docs. 2016-05-13 18:41:31 +00:00
moderation.php
ms-admin.php
ms-delete-site.php
ms-edit.php
ms-options.php
ms-sites.php
ms-themes.php
ms-upgrade-network.php
ms-users.php
my-sites.php
nav-menus.php
network.php
options-discussion.php Admin: Fix default avatar handling in Settings -> Discussion. 2016-04-17 10:19:28 +00:00
options-general.php
options-head.php Docs: Standardize on 'backward compatibility/compatible' nomenclature in core inline docs. 2016-05-13 18:41:31 +00:00
options-media.php
options-permalink.php
options-reading.php
options-writing.php
options.php Media: Remove medium_large size from $whitelist_options['media'] in options.php. 2016-05-15 22:38:29 +00:00
plugin-editor.php
plugin-install.php Text Changes: Consistently refer to https://wordpress.org/plugins/ and https://wordpress.org/themes/ as WordPress Plugin Directory and WordPress Theme Directory, respectively. 2016-04-22 06:57:26 +00:00
plugins.php Plugin Install: show the upload form in place rather than sending users to the devoted upload plugin page. 2016-04-16 16:43:27 +00:00
post-new.php
post.php Posts: Fire a post_action_{$action} action for a custom post action request. 2016-05-12 15:44:28 +00:00
press-this.php
profile.php Don't rely on include_path to include files. 2013-09-25 00:18:11 +00:00
revision.php
setup-config.php Bootstrap/Load: Allow for ABSPATH to be defined outside of wp-load.php, e.g. in a script loaded via auto_prepend_file. 2016-04-14 17:53:28 +00:00
term.php
theme-editor.php
theme-install.php Docs: Standardize on 'backward compatibility/compatible' nomenclature in core inline docs. 2016-05-13 18:41:31 +00:00
themes.php Text Changes: Consistently refer to https://wordpress.org/plugins/ and https://wordpress.org/themes/ as WordPress Plugin Directory and WordPress Theme Directory, respectively. 2016-04-22 06:57:26 +00:00
tools.php
update-core.php
update.php
upgrade-functions.php
upgrade.php
upload.php
user-edit.php
user-new.php
users.php
widgets.php