Commit Graph

37 Commits

Author SHA1 Message Date
Weston Ruter e0bc1e0c16 Customize: Ensure that qunit test enters in expected state and tests `wp.customize.dirtyValues` in starter content context.
Fixes regression in [38991].
See #38114.


git-svn-id: https://develop.svn.wordpress.org/trunk@38993 602fd350-edb4-49c9-b593-d223f7449a82
2016-10-28 03:28:07 +00:00
Weston Ruter 83b059aa19 Customize: Implement customized state persistence with changesets.
Includes infrastructure developed in the Customize Snapshots feature plugin.

See https://make.wordpress.org/core/2016/10/12/customize-changesets-technical-design-decisions/

Props westonruter, valendesigns, utkarshpatel, stubgo, lgedeon, ocean90, ryankienstra, mihai2u, dlh, aaroncampbell, jonathanbardo, jorbin.
See #28721.
See #31089.
Fixes #30937.
Fixes #31517.
Fixes #30028.
Fixes #23225.
Fixes #34142.
Fixes #36485.


git-svn-id: https://develop.svn.wordpress.org/trunk@38810 602fd350-edb4-49c9-b593-d223f7449a82
2016-10-18 20:04:36 +00:00
Weston Ruter f3e8e7735d Customize: Re-architect and harden panel/section UI logic.
Removes contents for sections and panels from being logically nested (in the DOM) in order to eliminate many issues related to using `margin-top` hacks. The element containing the link to expand the content element for panels and sections is now a sibling element to its content element: the content is removed from being nested at initialization. The content element is now available in a `contentContainer` property whereas the head element (containing the link to open the construct) is in a `headContainer` property. The existing `container` property is now a jQuery collection that contains both of these elements. Since the head element is no longer in an ancestor element to the `content` element, the `aria-owns` property is now used to maintain the relationship between the `headContainer` and the `contentContainer`. These changes are also accompanied by an improvement to the animation performance for the sliding panes.

Props delawski, celloexpressions.
Fixes #34391.
Fixes #34344.
Fixes #35947.


git-svn-id: https://develop.svn.wordpress.org/trunk@38648 602fd350-edb4-49c9-b593-d223f7449a82
2016-09-23 22:22:09 +00:00
Weston Ruter f5923b7fe8 Customize: Fix php warning due to `WP_Customize_Manager::prepare_setting_validity_for_js()` incorrectly assuming that `WP_Error` will only ever have arrays in its `$error_data`.
* Eliminates the server mutating the a `WP_Error`'s `$error_data` to merge-in a `$from_server` flag (since it may not be an array to begin with). Instead it defers to the client to add a `fromServer` param on any `Notification` instances created from server-sent errors.
* Ensures that notifications will be re-rendered if a notification's `message` changes but the `data` and `type` remain the same.
* Adds explicit support for the `Notification` class to have a `setting` property, ensuring that the property is set whereas previously it was dropped.

Fixes #37890.
Props westonruter, dlh.


git-svn-id: https://develop.svn.wordpress.org/trunk@38513 602fd350-edb4-49c9-b593-d223f7449a82
2016-09-02 22:34:48 +00:00
Dominik Schilling a9d1e10161 Remove `svn:executable` property from Requests and some other files.
git-svn-id: https://develop.svn.wordpress.org/trunk@38049 602fd350-edb4-49c9-b593-d223f7449a82
2016-07-13 14:38:21 +00:00
Konstantin Obenland 4dd1d9bef9 Update/Install: Shiny Updates v2.
Gone are the days of isolation and feelings of "meh", brought on by The Bleak Screen of Sadness. For a shiny knight has arrived to usher our plugins and themes along their arduous journey of installation, updates, and the inevitable fate of ultimate deletion.

Props swissspidy, adamsilverstein, mapk, afragen, ocean90, ryelle, j-falk, michael-arestad, melchoyce, DrewAPicture, AdamSoucie, ethitter, pento, dd32, kraftbj, Ipstenu, jorbin, afercia, stephdau, paulwilde, jipmoors, khag7, svovaf, jipmoors, obenland.
Fixes #22029, #25828, #31002, #31529, #31530, #31773, #33637, #35032.



git-svn-id: https://develop.svn.wordpress.org/trunk@37714 602fd350-edb4-49c9-b593-d223f7449a82
2016-06-15 16:36:07 +00:00
Weston Ruter f26ccf6fac Customize: Update server-sent setting validation notifications as changes are entered.
Send back setting validities with full refreshes and selective refreshes so that invalid settings can have notifications displayed immediately before attempting save, and so that these notifications can be cleared as soon as the input is corrected.

* Splits out JS logic for listing controls into separate methods  `wp.customize.Setting.prototype.findControls()` and `wp.customize.findControlsForSettings()`.
* Adds a `setting` property to the `data` on notifications added to controls that are synced from their settings.
* Adds `selective-refresh-setting-validities` message sent from preview to pane.
* Changes `WP_Customize_Manager::validate_setting_values()` to return when settings are valid as well as invalid.
* Adds `WP_Customize_Manager::prepare_setting_validity_for_js()`.
* Add setting validities to data exported to JS in Customizer Preview and in selective refresh responses.

Fixes #36944.


git-svn-id: https://develop.svn.wordpress.org/trunk@37700 602fd350-edb4-49c9-b593-d223f7449a82
2016-06-14 19:16:54 +00:00
Weston Ruter c7ff79df64 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.


git-svn-id: https://develop.svn.wordpress.org/trunk@37476 602fd350-edb4-49c9-b593-d223f7449a82
2016-05-20 21:09:40 +00:00
Weston Ruter d80ef26b48 Customize: Allow controls to be registered without any associated settings.
* Improves parity between partials and controls. A partial or control can be settingless if instantiated with `settings` param as empty array (otherwise, if null, then the partial/control ID is used). 
* Eliminate need to create dummy settings that serve no purpose except to place a control in the UI.
* Removes dummy settings for `create_new_menu` and `new_menu_name`.
* Introduces `WP_Customize_Control::$capability` and `WP_Customize_Partial::$capability`, and if set checks them in the respective `check_capabilities()` methods.
* Prevents PHP fatal error from happening when non-existing settings are provided to control: "Call to a member function `check_capabilities()` on a non-object".
* Fixes issue where nav menu items and widgets were no longer working with selective refresh because cap check was failing.

See #27355.
Fixes #35926.


git-svn-id: https://develop.svn.wordpress.org/trunk@36689 602fd350-edb4-49c9-b593-d223f7449a82
2016-02-24 18:27:45 +00:00
Weston Ruter 6dd1dd61a1 Customize: Add a user-friendly way to preview site responsiveness for desktop, tablet, and mobile.
Introduces `WP_Customize_Manager::get_previewable_devices()` with a `customize_previewable_devices` filter to change the default device and which devices are available for previewing. This is a feature that was first pioneered on WordPress.com.

Props celloexpressions, folletto, valendesigns, westonruter, welcher, adamsilverstein, michaelarestad, Fab1en.
Fixes #31195.


git-svn-id: https://develop.svn.wordpress.org/trunk@36532 602fd350-edb4-49c9-b593-d223f7449a82
2016-02-16 01:56:13 +00:00
Weston Ruter 370057b5d7 Customizer: Always show Widgets panel initially if sidebars are registered; show notice to users in panel if no widget areas are in current preview.
Widgets panel will not wait to display until the preview loads.

Also fixes problems with `margin-top` in panels where other panels' `active` states change, as well as ensuring sections of deactivated panel collapse before panel is hidden to prevent the pane from becoming empty of controls.

Fixes #33052.
Fixes #33567.


git-svn-id: https://develop.svn.wordpress.org/trunk@35231 602fd350-edb4-49c9-b593-d223f7449a82
2015-10-16 23:47:56 +00:00
Weston Ruter 78b73c8906 Customizer: Defer embedding widget controls to improve DOM performance and initial load time.
The Menu Customizer feature includes a performance technique whereby the controls for nav menu items are only embedded into the DOM once the containing menu section is expanded. This commit implements the same DOM deferral for widgets but goes a step further than just embedding the controls once the widget area's Customizer section is expanded: it also defers the embedding of the widget control's form until the widget is expanded, at which point the `widget-added` event also fires to allow any additional widget initialization to be done. The deferred DOM embedding can speed up initial load time by 10x or more. This DOM deferral also yields a reduction in overall memory usage in the browser process.

Includes changes to `wp_widget_control()` to facilitate separating out the widget form from the surrounding accordion container; also includes unit tests for this previously-untested function. Also included are initial QUnit tests (finally) for widgets in the Customizer.

Fixes #33901.


git-svn-id: https://develop.svn.wordpress.org/trunk@34563 602fd350-edb4-49c9-b593-d223f7449a82
2015-09-25 21:01:46 +00:00
Ella Iseulde Van Dorpe e30bd2f439 JSHint for [33528]: remove logging
See #32688.


git-svn-id: https://develop.svn.wordpress.org/trunk@33562 602fd350-edb4-49c9-b593-d223f7449a82
2015-08-03 21:57:04 +00:00
Weston Ruter 7857be9cf0 Customizer: Add QUnit tests for menus.
Props adamsilverstein, westonruter, jorbin.
Fixes #32688.


git-svn-id: https://develop.svn.wordpress.org/trunk@33528 602fd350-edb4-49c9-b593-d223f7449a82
2015-08-03 19:27:27 +00:00
Aaron Jorbin b5f505d3dd Add Initial JS Unit Tests for Menu Customizer
While these two tests will help ensure we don't repeat our mistakes, they mostly help lay the foundation for more tests that still need to be written.

See #32688
Props adamsilverstein, jorbin



git-svn-id: https://develop.svn.wordpress.org/trunk@33451 602fd350-edb4-49c9-b593-d223f7449a82
2015-07-27 22:07:27 +00:00
Ella Iseulde Van Dorpe aed9a8c5bc Editor: word count: better names for types.
Also fix it in wp_trim_words().

Fixes #30966.


git-svn-id: https://develop.svn.wordpress.org/trunk@33440 602fd350-edb4-49c9-b593-d223f7449a82
2015-07-27 11:18:55 +00:00
Ella Iseulde Van Dorpe e2fab60c51 Editor: word count: exclude HTML comments and entities
Also make sure `type` is one of the three allowed types and remove unnecessary regex flags.

See #30966.


git-svn-id: https://develop.svn.wordpress.org/trunk@33344 602fd350-edb4-49c9-b593-d223f7449a82
2015-07-21 15:23:45 +00:00
Ella Iseulde Van Dorpe 16e22cd0aa Editor: word count: count astrals as one character
This makes sure an emoji, for example, is counted as one character.

See #30966.


git-svn-id: https://develop.svn.wordpress.org/trunk@33320 602fd350-edb4-49c9-b593-d223f7449a82
2015-07-18 11:41:25 +00:00
Ella Iseulde Van Dorpe c2c5c5ac27 Editor: word count: exclude shortcodes
Props desaiuditd, adamsilverstein, azaozz and iseulde.
Fixes #27386. See #30966.


git-svn-id: https://develop.svn.wordpress.org/trunk@33299 602fd350-edb4-49c9-b593-d223f7449a82
2015-07-16 21:08:05 +00:00
Ella Iseulde Van Dorpe 129a3affe5 Editor: word count: exclude more characters
Also only exclude these characters for the `words` type. They should be counted for other types.
Add the ASCIIOnly option to the uglify config to preserve escaped unicode characters.

See #30966. Fixes #27391.



git-svn-id: https://develop.svn.wordpress.org/trunk@33292 602fd350-edb4-49c9-b593-d223f7449a82
2015-07-16 09:44:43 +00:00
iseulde e1242b6979 Editor: word count: add `all` type
This type will count all characters including spaces.

See #30966.


git-svn-id: https://develop.svn.wordpress.org/trunk@33290 602fd350-edb4-49c9-b593-d223f7449a82
2015-07-15 23:47:02 +00:00
Ella Iseulde Van Dorpe fa5ec5077b Editor: restructure word count
* The WordCounter should only do one thing: count words. This makes it also easier to test.
* Add some really basic unit tests.
* Instead of only refreshing the count on enter and delete, refresh the count when the user stops typing. Also look at paste and content changes in TinyMCE.
* Use `match` instead of `replace` when it is appropriate.
* More readable code.

See #30966. Fixes #26620.



git-svn-id: https://develop.svn.wordpress.org/trunk@32856 602fd350-edb4-49c9-b593-d223f7449a82
2015-06-19 10:34:59 +00:00
Dominik Schilling (ocean90) 5ae2271098 Customizer: Improve JS templates for Panels and Sections added in [32658].
* Always fall back to using the default template if no custom template exists.
* Provide a set of default params when constructing new `Section` and `Panel` objects.

Includes QUnit tests.

Props celloexpressions, westonruter, ocean90.
Fixes #30737.

git-svn-id: https://develop.svn.wordpress.org/trunk@32681 602fd350-edb4-49c9-b593-d223f7449a82
2015-06-01 22:46:56 +00:00
Weston Ruter cc19680774 Add JS templates for Customizer Panels and Sections.
This extends the approach taken for Customizer Controls in #29572.

Props celloexpressions, westonruter, ocean90.
See #30737.


git-svn-id: https://develop.svn.wordpress.org/trunk@32658 602fd350-edb4-49c9-b593-d223f7449a82
2015-05-30 00:02:13 +00:00
Dominik Schilling (ocean90) e7f2ebf414 Customizer: Add more QUnit tests to improve coverage on the new models.
Includes tests for the broken `activate()`/`deactivate()` methods, which were fixed in [30871].

props westonruter.
see #30701.

git-svn-id: https://develop.svn.wordpress.org/trunk@30919 602fd350-edb4-49c9-b593-d223f7449a82
2014-12-16 19:43:22 +00:00
Dominik Schilling (ocean90) abe2a7ae21 Customizer: Move private helper functions to `wp.customize.utils` so they can be unit tested.
Includes unit tests.

props ryankienstra, westonruter.
see #28709.

git-svn-id: https://develop.svn.wordpress.org/trunk@30716 602fd350-edb4-49c9-b593-d223f7449a82
2014-12-02 22:55:48 +00:00
Dominik Schilling (ocean90) 90182015e7 Improve/introduce Customizer JavaScript models for Controls, Sections, and Panels.
* Introduce models for panels and sections.
* Introduce API to expand and focus a control, section or panel.
* Allow deep-linking to panels, sections, and controls inside of the Customizer.
* Clean up `accordion.js`, removing all Customizer-specific logic.
* Add initial unit tests for `wp.customize.Class` in `customize-base.js`.

https://make.wordpress.org/core/2014/10/27/toward-a-complete-javascript-api-for-the-customizer/ provides an overview of how to use the JavaScript API.

props westonruter, celloexpressions, ryankienstra.
see #28032, #28579, #28580, #28650, #28709, #29758.
fixes #29529.



git-svn-id: https://develop.svn.wordpress.org/trunk@30102 602fd350-edb4-49c9-b593-d223f7449a82
2014-10-29 22:50:21 +00:00
Dominik Schilling (ocean90) a13b695fbd Customizer: Allow to skip cropping header images if image width is smaller than or equal to theme width.
Add tests.

see #27936 for trunk.

git-svn-id: https://develop.svn.wordpress.org/trunk@28219 602fd350-edb4-49c9-b593-d223f7449a82
2014-04-25 20:24:28 +00:00
Dominik Schilling (ocean90) fd26def119 Revert [28217].
Misfired commit for #27936.

git-svn-id: https://develop.svn.wordpress.org/trunk@28218 602fd350-edb4-49c9-b593-d223f7449a82
2014-04-25 20:17:59 +00:00
Dominik Schilling (ocean90) 5d8f69e0c5 Recent Posts Widget: Use `ob_end_flush()` instead of `ob_flush()`.
`ob_end_flush()` flushes the output buffer *and* turns output buffering off, same as `ob_get_flush()`.

props m_i_n.
see #28009 for trunk.


git-svn-id: https://develop.svn.wordpress.org/trunk@28217 602fd350-edb4-49c9-b593-d223f7449a82
2014-04-25 14:20:05 +00:00
Andrew Nacin e3171a42a3 Add PHP and JS unit tests for custom headers.
props mcsf, ehg.
see #21785.


git-svn-id: https://develop.svn.wordpress.org/trunk@27847 602fd350-edb4-49c9-b593-d223f7449a82
2014-03-29 10:05:22 +00:00
Andrew Nacin aacc286f7c Use only one var per scope in our password-strength-meter tests.
props kadamwhite.
see #25187.


git-svn-id: https://develop.svn.wordpress.org/trunk@26040 602fd350-edb4-49c9-b593-d223f7449a82
2013-11-07 20:40:12 +00:00
Andrew Nacin 5c63859ffb Add jshintrc to qunit.
props jorbin.
see #25187.


git-svn-id: https://develop.svn.wordpress.org/trunk@25992 602fd350-edb4-49c9-b593-d223f7449a82
2013-10-30 14:38:37 +00:00
Andrew Nacin 89febfe766 Expand the zxcvbn password meter blacklist, based on user input.
props iandunn.
see #25174.


git-svn-id: https://develop.svn.wordpress.org/trunk@25637 602fd350-edb4-49c9-b593-d223f7449a82
2013-09-28 06:46:29 +00:00
Sergey Biryukov 093a580656 Whitespace cleanup for password strength meter tests. props TobiasBg. fixes #25088.
git-svn-id: https://develop.svn.wordpress.org/trunk@25275 602fd350-edb4-49c9-b593-d223f7449a82
2013-09-06 10:56:01 +00:00
Jon Cave 94e03ce09f Test that passwords containing the username are penalised.
Tidy up some spelling, indentation and whitespace whilst we're at it.

Props iandunn. See #25088.


git-svn-id: https://develop.svn.wordpress.org/trunk@25175 602fd350-edb4-49c9-b593-d223f7449a82
2013-08-29 22:28:32 +00:00
Andrew Nacin dd78079286 Add QUnit tests for password-strength-meter.js.
props jorbin.
see #25088.


git-svn-id: https://develop.svn.wordpress.org/trunk@25167 602fd350-edb4-49c9-b593-d223f7449a82
2013-08-29 18:44:36 +00:00