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 Add grunt prerelease task 2016-03-10 05:37:27 +00:00
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 Install/Upgrade: Keep indexing bots away until a site is ready to be seen. 2015-12-08 21:56:27 +00:00
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 Spelling: Standardize on "front end"/"back end" (noun) and "front-end"/"back-end" (adjective). 2016-02-25 12:53:27 +00:00
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 Correct the title used on the user dashboard. 2015-06-24 00:37:28 +00:00
admin-post.php Spelling: Standardize on "front end"/"back end" (noun) and "front-end"/"back-end" (adjective). 2016-02-25 12:53:27 +00:00
admin.php Docs: Standardize on 'backward compatibility/compatible' nomenclature in core inline docs. 2016-05-13 18:41:31 +00:00
async-upload.php Superglobals: Revert [34059] until further notice. 2015-09-17 12:33:26 +00:00
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 `callback` is not a valid type in PHP, PSR-5, or phpDocumentor. `callable` should be used instead. 2015-09-25 23:58:25 +00:00
custom-header.php I18N: Remove `<strong>` tags from translatable strings in `wp-admin/custom-header.php`. 2016-02-23 23:43:26 +00:00
customize.php Accessibility: Customizer, improve UI controls in `customize.php` 2016-04-17 15:41:27 +00:00
edit-comments.php Allow searching for `0` throughout the admin. 2016-01-14 20:06:25 +00:00
edit-form-advanced.php Editor: Remove trailing space from a help text string. 2016-04-05 10:54:29 +00:00
edit-form-comment.php Comments: On the Edit Comment screen do not show the permalink for unapproved comments. 2016-03-10 21:18:27 +00:00
edit-link-form.php Bump H3 headings to H2 on the legacy Link Manager screen for better accessibility. 2015-10-14 17:32:24 +00:00
edit-tag-form.php Taxonomy: After [36874], rename `$term_id` to `$tag_ID` in `wp-admin/edit-tag-form.php`. 2016-03-11 08:52:29 +00:00
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 Allow searching for `0` throughout the admin. 2016-01-14 20:06:25 +00:00
export.php Export: Add a missing Oxford comma. 2015-12-31 19:33:25 +00:00
freedoms.php 4.5 About Page, second round. 2016-04-10 02:03:29 +00:00
import.php Accessibility: Improve accessibility for the Plugin details modal. 2016-03-10 22:37:26 +00:00
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 Docs: Add missing descriptions for the `$wpdb` global in DocBlocks all the places. 2015-10-14 23:44:25 +00:00
install.php I18N: Remove `<code>` tags from translatable strings in `wp-admin/install.php`. 2016-02-24 01:22:26 +00:00
link-add.php
link-manager.php Allow searching for `0` throughout the admin. 2016-01-14 20:06:25 +00:00
link-parse-opml.php Add `@global` annotations for `wp-admin/*`. 2015-05-28 21:41:30 +00:00
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-new.php`, when using the browser uploader, if the result of uploading is a `WP_Error` - `wp_die()` with the error, instead of redirecting with a generic error. 2015-09-10 17:18:24 +00:00
media-upload.php Provide more helful feedback than just "Cheatin' uh?" for permission errors in `wp-admin/media-upload.php`. 2015-09-02 16:21:21 +00:00
media.php Media: Change wording for media files which aren't attached. 2016-03-08 17:43:25 +00:00
menu-header.php Docs: Correct grammar when referring to "a URL" vs "an URL" in several places. 2016-03-12 12:39:27 +00:00
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 Trim trailing space from string in site delete confirmation 2015-07-01 16:31:25 +00:00
ms-edit.php
ms-options.php
ms-sites.php
ms-themes.php
ms-upgrade-network.php
ms-users.php
my-sites.php Spelling: Standardize on "front end"/"back end" (noun) and "front-end"/"back-end" (adjective). 2016-02-25 12:53:27 +00:00
nav-menus.php Menus: Ensure theme location setting data is saved with a large menu. 2016-03-05 00:47:26 +00:00
network.php Network Setup: don't use `<code>` in translation strings in `wp-admin/network` files. 2015-09-18 18:18:27 +00:00
options-discussion.php Admin: Fix default avatar handling in Settings -> Discussion. 2016-04-17 10:19:28 +00:00
options-general.php I18N: Remove `<a>` tag from translatable string in `wp-admin/options-general.php`. 2016-02-23 23:28:25 +00:00
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 Remove `<code>` tag from translatable string in `wp-admin/options-media.php`. 2015-11-06 00:28:25 +00:00
options-permalink.php Accessibility: Don't mark up "URL" as an abbreviation. 2016-01-01 12:10:26 +00:00
options-reading.php Move ad hoc Options functions to `wp-admin/includes/options.php`: 2015-09-10 21:45:24 +00:00
options-writing.php I18N: Remove `<kbd>` tags from translatable string in `wp-admin/options-writing.php`. 2016-04-14 02:25:26 +00:00
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 Replace `get_bloginfo( 'wpurl' )` with `admin_url()` in plugin editor. 2015-10-13 02:05:24 +00:00
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 Provide more helpful feedback than just "Cheatin' uh?" for permission errors in `wp-admin/post-new.php`. 2015-09-02 18:36:22 +00:00
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 Provide more helpful feedback than just "Cheatin' uh?" for permission errors in `wp-admin/press-this.php`. 2015-09-02 18:38:21 +00:00
profile.php
revision.php Revisions screen: change language from "Return to post editor" to "Return to editor" - more generic for usage by custom post types. 2015-09-09 03:23:23 +00:00
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 Taxonomy: After [36874], rename `$term_id` to `$tag_ID` in `wp-admin/edit-tag-form.php`. 2016-03-11 08:52:29 +00:00
theme-editor.php Theme Editor: Repurpose the `'wp_theme_editor_filetypes'` filter added in [35134] to actually filter file types instead of files. 2015-10-15 02:20:24 +00:00
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 Bump H3 headings to H2 on Tools screen for better accessibility. 2015-08-31 03:32:21 +00:00
update-core.php I18N: On the Updates screen simplify plugin's version details link. 2016-04-06 12:52:30 +00:00
update.php Plugins: Don't request all fields via `plugins_api( 'plugin_information' )` for plugin installs and update checks. 2015-09-26 15:50:25 +00:00
upgrade-functions.php
upgrade.php Install/Upgrade: Keep indexing bots away until a site is ready to be seen. 2015-12-08 21:56:27 +00:00
upload.php Media: Fix typo introduced in [36887]. 2016-03-14 09:00:28 +00:00
user-edit.php Multisite: Validate new email address confirmations. 2016-03-30 14:44:26 +00:00
user-new.php I18N: Fix placeholders and add translator comments after [36695]. 2016-02-24 21:49:26 +00:00
users.php Use `admin_url()` for "Add New" links in `wp-admin/users.php`. 2016-03-09 19:09:50 +00:00
widgets.php After [36171] remove all the occurrences of the old CSS clearfix. 2016-01-30 13:46:27 +00:00