WordPress/wp-includes/js
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
..
crop
imgareaselect
jcrop
jquery Update jQuery Migrate to 1.4.1 2016-05-20 06:11:28 +00:00
mediaelement External Libraries: Update MediaElement.js from upstream. 2016-05-06 17:51:36 +00:00
plupload External Libraries: Update plupload from upstream 2016-05-06 18:02:26 +00:00
swfupload
thickbox Accessibility: Improve accessibility for the Plugin details modal. 2016-03-10 22:37:26 +00:00
tinymce TinyMCE: use new non-editable implementation 2016-05-17 18:49:30 +00:00
admin-bar.js
admin-bar.min.js Update grunt-contrib-uglify from ~0.10.0 to ~1.0.1 2016-04-15 16:10:37 +00:00
autosave.js Admin: fix repositioning of notices when the first header is not an immediate children of .wrap. 2015-12-31 11:05:31 +00:00
autosave.min.js Admin: fix repositioning of notices when the first header is not an immediate children of .wrap. 2015-12-31 11:05:31 +00:00
backbone.min.js Update Backbone and Underscore to the latest versions. 2016-02-17 15:22:26 +00:00
colorpicker.js
colorpicker.min.js Update grunt-contrib-uglify from ~0.10.0 to ~1.0.1 2016-04-15 16:10:37 +00:00
comment-reply.js
comment-reply.min.js
customize-base.js Customize: Add setting validation model and control notifications to augment setting sanitization. 2016-05-20 21:10:27 +00:00
customize-base.min.js Customize: Add setting validation model and control notifications to augment setting sanitization. 2016-05-20 21:10:27 +00:00
customize-loader.js Customize: Don't auto-close the customizer when a new theme is activated. 2016-05-01 19:54:27 +00:00
customize-loader.min.js Customize: Don't auto-close the customizer when a new theme is activated. 2016-05-01 19:54:27 +00:00
customize-models.js
customize-models.min.js Update grunt-contrib-uglify from ~0.10.0 to ~1.0.1 2016-04-15 16:10:37 +00:00
customize-preview-nav-menus.js Customize: Fix regressions and harden implementation of selective refresh for nav menus. 2016-03-09 00:09:26 +00:00
customize-preview-nav-menus.min.js Customize: Fix regressions and harden implementation of selective refresh for nav menus. 2016-03-09 00:09:26 +00:00
customize-preview-widgets.js Customize: Remove format placeholders from widget templates and selectors, fixing a jQuery selector syntax error and the broken highlight/shift-click behaviors. 2016-04-28 18:20:29 +00:00
customize-preview-widgets.min.js Customize: Remove format placeholders from widget templates and selectors, fixing a jQuery selector syntax error and the broken highlight/shift-click behaviors. 2016-04-28 18:20:29 +00:00
customize-preview.js Customize: Rely on selective refresh exclusively for previewing custom logo changes. 2016-03-14 19:17:28 +00:00
customize-preview.min.js Customize: Rely on selective refresh exclusively for previewing custom logo changes. 2016-03-14 19:17:28 +00:00
customize-selective-refresh.js Customize: Require opt-in for selective refresh of widgets. 2016-03-21 21:59:29 +00:00
customize-selective-refresh.min.js Customize: Require opt-in for selective refresh of widgets. 2016-03-21 21:59:29 +00:00
customize-views.js Customizer: Contain "No image set/selected" in dashed border. 2016-02-23 17:27:26 +00:00
customize-views.min.js Customizer: Contain "No image set/selected" in dashed border. 2016-02-23 17:27:26 +00:00
heartbeat.js Spelling: Standardize on "front end"/"back end" (noun) and "front-end"/"back-end" (adjective). 2016-02-25 12:53:27 +00:00
heartbeat.min.js
hoverIntent.js
hoverIntent.min.js
json2.js
json2.min.js
masonry.min.js
mce-view.js TinyMCE: use new non-editable implementation 2016-05-17 18:49:30 +00:00
mce-view.min.js TinyMCE: use new non-editable implementation 2016-05-17 18:49:30 +00:00
media-audiovideo.js Update Backbone and Underscore to the latest versions. 2016-02-17 15:22:26 +00:00
media-audiovideo.min.js Update Backbone and Underscore to the latest versions. 2016-02-17 15:22:26 +00:00
media-editor.js
media-editor.min.js Update grunt-contrib-uglify from ~0.10.0 to ~1.0.1 2016-04-15 16:10:37 +00:00
media-grid.js Media: Fix broken delete/trash functionality in the library after [36546]. 2016-02-24 16:03:26 +00:00
media-grid.min.js Update grunt-contrib-uglify from ~0.10.0 to ~1.0.1 2016-04-15 16:10:37 +00:00
media-models.js
media-models.min.js Update grunt-contrib-uglify from ~0.10.0 to ~1.0.1 2016-04-15 16:10:37 +00:00
media-views.js Customize: Respect aspect ratio on cropped images. 2016-03-30 15:14:27 +00:00
media-views.min.js Update grunt-contrib-uglify from ~0.10.0 to ~1.0.1 2016-04-15 16:10:37 +00:00
quicktags.js
quicktags.min.js
shortcode.js
shortcode.min.js
swfobject.js
tw-sack.js
tw-sack.min.js
twemoji.js Add grunt prerelease task 2016-03-10 05:37:27 +00:00
twemoji.min.js Add grunt prerelease task 2016-03-10 05:37:27 +00:00
underscore.min.js Update Backbone and Underscore to the latest versions. 2016-02-17 15:22:26 +00:00
utils.js
utils.min.js
wp-a11y.js
wp-a11y.min.js
wp-ajax-response.js jQuery: Replace the use of the .size() method with the .length property. 2016-01-13 16:17:27 +00:00
wp-ajax-response.min.js Update grunt-contrib-uglify from ~0.10.0 to ~1.0.1 2016-04-15 16:10:37 +00:00
wp-auth-check.js jQuery: Replace use of the .load() method for the "load" event with .on( 'load', handler ). 2016-01-13 17:22:27 +00:00
wp-auth-check.min.js jQuery: Replace use of the .load() method for the "load" event with .on( 'load', handler ). 2016-01-13 17:22:27 +00:00
wp-backbone.js In wp.Backbone.Subviews, extract subviews with proper Underscore.js functions. 2016-01-15 04:02:28 +00:00
wp-backbone.min.js In wp.Backbone.Subviews, extract subviews with proper Underscore.js functions. 2016-01-15 04:02:28 +00:00
wp-embed-template.js Embeds: Make the click event handler work for dynamically added links. 2016-02-23 17:16:26 +00:00
wp-embed-template.min.js Embeds: Make the click event handler work for dynamically added links. 2016-02-23 17:16:26 +00:00
wp-embed.js Embeds: Use a more accessible way to initially hide the iframe. 2016-02-25 10:23:27 +00:00
wp-embed.min.js Embeds: Use a more accessible way to initially hide the iframe. 2016-02-25 10:23:27 +00:00
wp-emoji-loader.js Emoji: The diversity support test was incorrectly passing on all browsers. 2016-04-20 13:56:28 +00:00
wp-emoji-loader.min.js Emoji: The diversity support test was incorrectly passing on all browsers. 2016-04-20 13:56:28 +00:00
wp-emoji-release.min.js Emoji: Use SVG in supported browsers 2016-05-20 06:03:27 +00:00
wp-emoji.js Emoji: Use SVG in supported browsers 2016-05-20 06:03:27 +00:00
wp-emoji.min.js Emoji: Use SVG in supported browsers 2016-05-20 06:03:27 +00:00
wp-list-revisions.js
wp-list-revisions.min.js Update grunt-contrib-uglify from ~0.10.0 to ~1.0.1 2016-04-15 16:10:37 +00:00
wp-lists.js jQuery: Replace the use of the .size() method with the .length property. 2016-01-13 16:17:27 +00:00
wp-lists.min.js Update grunt-contrib-uglify from ~0.10.0 to ~1.0.1 2016-04-15 16:10:37 +00:00
wp-pointer.js
wp-pointer.min.js
wp-util.js Docs: Standardize on 'backward compatibility/compatible' nomenclature in core inline docs. 2016-05-13 18:41:31 +00:00
wp-util.min.js Update grunt-contrib-uglify from ~0.10.0 to ~1.0.1 2016-04-15 16:10:37 +00:00
wpdialog.js
wpdialog.min.js
wplink.js Editor, wpLink: 2016-04-01 21:13:29 +00:00
wplink.min.js Update grunt-contrib-uglify from ~0.10.0 to ~1.0.1 2016-04-15 16:10:37 +00:00
zxcvbn-async.js
zxcvbn-async.min.js
zxcvbn.min.js