Commit Graph

191 Commits

Author SHA1 Message Date
Andrea Fercia e2aa3c5efe Accessibility: Improve the "Alt text" description.
Moves the word "Describe" within the link.

Amends [44900].
See #41612.


git-svn-id: https://develop.svn.wordpress.org/trunk@45038 602fd350-edb4-49c9-b593-d223f7449a82
2019-03-27 18:46:12 +00:00
Andrea Fercia 7834856fcb Accessibility: Ensure embed iframes have a title attribute.
Screen reader users rely on the iframe title attribute to describe the contents of iframes. A meaningful title attribute allows to quickly identify the iframe content, so users can determine which iframe to enter and explore in detail or skip if desired.
Note: this is the only case where a title attribute is required for compliance with the W3C Web Content Accessibility Guidelines (WCAG).

- checks for oEmbed response of type `video` or `rich`
- checks if they use an iframe
- fetches the title (if any) from the oEmbed response
- adds the title to the embed iframe

Props bamadesigner, TomHarrigan, swissspidy, jrf, afercia.
Fixes #40245.


git-svn-id: https://develop.svn.wordpress.org/trunk@44942 602fd350-edb4-49c9-b593-d223f7449a82
2019-03-20 17:21:56 +00:00
Andrea Fercia 026abd4bc6 Accessibility: improve the "URL" and "Alt text" fields in the media modals.
Many users found the attachment URL field confusing: it says "URL" so it may appear like a field meant to paste a URL into.
Also, the Alt text field is the most important one in terms of content, while the Title field needs to be de-emphasized.

- changes the URL field label to "Copy link"
- moves the alt text field to the top as first field 
- avoids to set initial focus on the alt text field 
- adds an explanatory text with a link pointing to the W3C "alt decision tree" tutorial 
- adds `aria-describedby` to target the explanatory text
- adjusts the CSS accordingly
- updates the QUnit index.html file

Props melchoyce, audrasjb, afercia.
Fixes #41612.


git-svn-id: https://develop.svn.wordpress.org/trunk@44900 602fd350-edb4-49c9-b593-d223f7449a82
2019-03-15 10:42:35 +00:00
Riad Benguella ccfb76d26f Block Editor: Fix unit tests after new blocks addition.
- Regenerate the REST API fixtures.
 - Remove the block registration hooks in the unit tests.

Refs #46429.


git-svn-id: https://develop.svn.wordpress.org/trunk@44812 602fd350-edb4-49c9-b593-d223f7449a82
2019-03-07 11:53:15 +00:00
Andrea Fercia 951b462ea2 Accessibility: Replace media placeholder clickable divs with buttons.
`<button>` elements are natively interactive, supported by any assistive technology, and must be used instead of non-semantic, non-accessible `<div>` elements.

Also, this change aligns the Media Widgets and the Customizer site icon and site logo controls with the design pattern used in the new Block Editor for similar controls.

Props ramonopoly, welcher, afercia.
Fixes #43151.


git-svn-id: https://develop.svn.wordpress.org/trunk@44796 602fd350-edb4-49c9-b593-d223f7449a82
2019-03-05 17:49:00 +00:00
Andrea Fercia 6dde7cd74f Build/Test Tools: Update QUnit index file after [43174].
Updates the last occurrence of "(opens in a new window)" to "(opens in a new tab)".

See #43803.


git-svn-id: https://develop.svn.wordpress.org/trunk@44655 602fd350-edb4-49c9-b593-d223f7449a82
2019-01-19 15:27:11 +00:00
Gary Pendergast 09dd371fc0 REST API: Remove `permalink_structure` from the REST API settings endpoint.
This was ultimately fixed in #45017, so is redunant.

Reverts [42142,42359,42540].
See #41014.



git-svn-id: https://develop.svn.wordpress.org/trunk@44446 602fd350-edb4-49c9-b593-d223f7449a82
2019-01-08 02:50:05 +00:00
Jonathan Desrosiers 2ae5bb324d REST API: Preserve unknown, respect `null` in server-side block rendering.
- Skips validation where there is no attribute definition, but keeps the attribute value. Previously, the attribute would be omitted from the attributes passed to `render_callback`. Notably, this resolves an issue where `render_callback` cannot receive a block's `align` and `customClassName` attribute values, since these are defined as a client-side filter.
- Validates `null` as a proper value in its own right. Previously, a client implementation of a block could track `{“attribute":null}` as an explicitly empty value, and the server would wrongly initiate defaulting behavior. The new behavior will now only populate a default value if the attribute is not defined at all, including when unset in its being invalid per the attribute schema. 

Props aduth, noisysocks, youknowriad, danielbachhuber.

Merges [43918] to trunk.

See #45145 for the patch, #45098 for the original ticket.

git-svn-id: https://develop.svn.wordpress.org/trunk@44269 602fd350-edb4-49c9-b593-d223f7449a82
2018-12-17 17:59:44 +00:00
Sergey Biryukov c2390f96a2 REST API: Avoid using 'parent' as path argument name for autosaves.
When 'parent' is set as the path argument name, it gets passed down through to the `create_item()` method and can erroneously reset the 'parent' value on the post itself. Instead, we rename the argument to 'id' and replicate the revision controller's `get_items_permissions_check()` to instead reference 'id'.

Also ensures revision query params (of which there are many) aren't exposed as the query params for autosaves (of which there are two).

Props TimothyBlynJacobs.
Merges [43897] to trunk.
See #43316.

git-svn-id: https://develop.svn.wordpress.org/trunk@44250 602fd350-edb4-49c9-b593-d223f7449a82
2018-12-17 00:23:55 +00:00
Jeremy Felt de92919e02 REST API: Regenerate fixure schema after introduction of new endpoints.
This fixture schema ensures `wp-api-generated.js` doesn't change when running tests in local dev environments.

Merges [43851] from the 5.0 branch to trunk. `wp-api-generated.js` generated based on current trunk.
Props danielbachhuber.
Fixes #45196.


git-svn-id: https://develop.svn.wordpress.org/trunk@44217 602fd350-edb4-49c9-b593-d223f7449a82
2018-12-16 01:37:56 +00:00
Jonathan Desrosiers 89d76b9884 PHP7.3 compatibility: Fix compact throwing notices.
In PHP 7.3, the `compact()` function has been changed to issue an `E_NOTICE` level error if a passed string refers to an unset variable. In previous versions of PHP, this notice was silently skipped. The full RFC can be viewed here: https://wiki.php.net/rfc/compact.

Props jorbin, desrosj.

Merges [43819] and [43832] to trunk.

Fixes #44416.

git-svn-id: https://develop.svn.wordpress.org/trunk@44166 602fd350-edb4-49c9-b593-d223f7449a82
2018-12-14 05:12:12 +00:00
Gary Pendergast f61cfa648c Embeds: Filter HTML response in oEmbed proxy controller.
Adapts the response from `WP_oEmbed_Controller::get_proxy_item()` so that the response is correctly filtered and embeds work properly in JavaSccript editors. Introduces new `get_oembed_response_data_for_url()` function for preparing internal oEmbed responses.

Merges [43810] from the 5.0 branch to trunk.

Props danielbachhuber, imath, swissspidy.
Fixes #45142.



git-svn-id: https://develop.svn.wordpress.org/trunk@44154 602fd350-edb4-49c9-b593-d223f7449a82
2018-12-14 03:19:48 +00:00
Jeremy Felt 7702b535be REST API: Add endpoints for blocks.
`WP_REST_Block_Renderer_Controller` allows rendering of server-side rendered blocks, whilst `WP_REST_Blocks_Controller` allows retrieving of reusable blocks.

Merges [43805] and [43806] from the 5.0 branch to trunk.

Props desrosj, danielbachhuber, pento, Presskopp, swissspidy.
See #45065, #45098.


git-svn-id: https://develop.svn.wordpress.org/trunk@44150 602fd350-edb4-49c9-b593-d223f7449a82
2018-12-14 02:34:28 +00:00
Gary Pendergast 63d9540fd8 REST API: Include `block_version` on Post `content` object.
The `block_version` denotes which version of Blocks the `post_content` contains. Introduces new `block_version()` function for versioning Blocks.

Merges [43770] from the 5.0 branch to trunk.

Props danielbachhuber, birgire.
Fixes #43887.


git-svn-id: https://develop.svn.wordpress.org/trunk@44127 602fd350-edb4-49c9-b593-d223f7449a82
2018-12-14 00:54:51 +00:00
Jonathan Desrosiers 225f191f32 REST API: Introduce Autosaves controller and endpoint.
- Adds `WP_REST_Autosaves_Controller` which extends `WP_REST_Revisions_Controller`.
- Autosaves endpoint is registered for all post types except attachment because even post types without revisions enabled are expected to autosave.
- Because setting the `DOING_AUTOSAVE` constant pollutes the test suite, autosaves tests are run last. We may want to improve upon this later. 

Also, use a truly impossibly high number in User Controller tests. The number `100`, (or `7777` in `trunk`), could be valid in certain test run configurations. The `REST_TESTS_IMPOSSIBLY_HIGH_NUMBER` constant is impossibly high for this very reason.

Finally, Skip Autosaves controller test for multisite. There's a PHP 5.2 edge case where paths calculated differently, possibly caused by differing version of PHPUnit.

Props adamsilverstein, aduth, azaozz, danielbachhuber, rmccue, danielbachhuber.

Merges [43767], [43768], [43769] to trunk.

See #45132, #45131.
Fixes #45128, #43316.

git-svn-id: https://develop.svn.wordpress.org/trunk@44126 602fd350-edb4-49c9-b593-d223f7449a82
2018-12-13 22:41:47 +00:00
Gary Pendergast 5c9c54239d REST API: Introduce controller for searching across post types.
Introduces a `WP_REST_Search_Controller` class which registers a `/wp/v2/search` endpoint. Search types are handled by extending `WP_REST_Search_Handler`. The default search type is `WP_REST_Post_Search_Handler` but can be filtered by plugins or a theme.

Merges [43739,43741] from the 5.0 branch to trunk.

Props danielbachhuber, flixos90, pento, rmccue, joehoyle.
Fixes #39965.



git-svn-id: https://develop.svn.wordpress.org/trunk@44107 602fd350-edb4-49c9-b593-d223f7449a82
2018-12-13 09:37:05 +00:00
Jeremy Felt 140a95cf08 REST API: Introduce themes endpoint to expose theme-supports values for the active theme.
In order to correctly render parts of its UI, the new editor needs to be aware of the active theme's post-formats and post-thumbnails support. This data is exposed by querying for the active theme on a new /wp/v2/themes endpoint for sufficiently privileged users.

Merges [43734], [43735] to trunk.

props desrosj.
Fixes #45016.


git-svn-id: https://develop.svn.wordpress.org/trunk@43985 602fd350-edb4-49c9-b593-d223f7449a82
2018-12-12 03:32:21 +00:00
Aaron Jorbin 891394af73 REST API: Persist attributes for attachment links
In [43437], the link definition implementation caused attachment links to be unexpectedly nested under an attributes key. This changeset restores the prior behavior.

Merges [43681] to trunk.

Props TimothyBlynJacobs, danielbachhuber.
Fixes #44750.


git-svn-id: https://develop.svn.wordpress.org/trunk@43973 602fd350-edb4-49c9-b593-d223f7449a82
2018-12-11 04:00:37 +00:00
Felix Arntz aa5b179247 REST API: Fix failing tests after [43584] and [43585].
See #40510.


git-svn-id: https://develop.svn.wordpress.org/trunk@43586 602fd350-edb4-49c9-b593-d223f7449a82
2018-08-28 13:04:07 +00:00
Felix Arntz e5d6ddfeee REST API: Support pagination, order, search and other common query parameters for revisions.
The original REST API revisions controller relied on `wp_get_post_revisions()`, getting all revisions of a post without any possibility to restrict the result. This changeset replaces that function call with a proper `WP_Query` setup, replicating how `wp_get_post_revisions()` works while offering parameters to alter the default behavior.

Props adamsilverstein, birgire, flixos90.
Fixes #40510.


git-svn-id: https://develop.svn.wordpress.org/trunk@43584 602fd350-edb4-49c9-b593-d223f7449a82
2018-08-28 12:22:48 +00:00
Gary Pendergast 63acd3caaa Tests: Revert `wp-api-generated.js` change added in [43571].
The fixtures file was accidentally included in [43571], but that caused other tests to fail.

See #39122.



git-svn-id: https://develop.svn.wordpress.org/trunk@43572 602fd350-edb4-49c9-b593-d223f7449a82
2018-08-17 04:11:48 +00:00
Gary Pendergast a75d153eee Coding Standards: Upgrade WPCS to 1.0.0
WPCS 1.0.0 includes a bunch of new auto-fixers, which drops the number of coding standards issues across WordPress significantly. Prior to running the auto-fixers, there were 15,312 issues detected. With this commit, we now drop to 4,769 issues.

This change includes three notable additions:
- Multiline function calls must now put each parameter on a new line.
- Auto-formatting files is now part of the `grunt precommit` script. 
- Auto-fixable coding standards issues will now cause Travis failures.

Fixes #44600.



git-svn-id: https://develop.svn.wordpress.org/trunk@43571 602fd350-edb4-49c9-b593-d223f7449a82
2018-08-17 01:50:26 +00:00
Gary Pendergast 4c8daa87bd REST API: Update the test fixture generator following [43439]
As [43439] added data that contains object IDs, it can cause `wp-api-generated.js` to be unnecessarily regenerated.

Regenerating our list of fixtures that need normalising rectifies this.

See #44321.



git-svn-id: https://develop.svn.wordpress.org/trunk@43441 602fd350-edb4-49c9-b593-d223f7449a82
2018-07-13 04:45:35 +00:00
Gary Pendergast 585c862faf REST API: Expose revision count and last revision ID on Post response
So that REST API clients can show appropriate UI for a post's revisions, it needs to know how many revisions the post has, and what the latest revision ID is.

Props kadamwhite, danielbachhuber, birgire, TimothyBlynJacobs.
Fixes #44321.



git-svn-id: https://develop.svn.wordpress.org/trunk@43439 602fd350-edb4-49c9-b593-d223f7449a82
2018-07-13 04:06:23 +00:00
John Blackbourn 5aa5e5c131 I18N: Introduce unit tests for the Japanese language in order to facilitate future improvements.
Props ryotsun

Fixes #43829


git-svn-id: https://develop.svn.wordpress.org/trunk@43359 602fd350-edb4-49c9-b593-d223f7449a82
2018-06-16 12:44:46 +00:00
Gary Pendergast ef37f002ee Once upon a midnight dreary, while I coded, weak and weary,
In many a strange and curious file of forgotten lore—
While I pondered, blaming Nacin, my notifications suddenly awakened,
As of someone quietly DMing;—DMing me, I can’t ignore.
“’Tis some contributor,” I muttered, “DMing me an idea or four—
            Only this and nothing more.”

Ah, distinctly I remember, at WordCamp US, last December;
A mad proposal nearly laid me—down out cold—upon the floor.
Curious, I listened closely;—to a plan I agreed with, mostly—
A way to make our JavaScript—JavaScript which was a chore—
Maintainable, extendable, for the future, is what I saw.
            Guten-ready for evermore.

Open here I switch to Slack, when, with many a patch and hack,
In there stepped Omar, a JavaScript developer hardcore;
Pronouncing all the changes fit; ready now to be commit;
“There’s nothing else for us to do,” DMing me, “It’s done!” he swore—
“No longer random guessing at which file need next be explored—
            Let’s move on, we’re all aboard.”

Moved all together, grouped and managed, in folders all is packaged,
The code had all been cleaned and tidied, important parts moved to the fore,
“Though this change be useful here,” I said, “it is too large, I fear,
We couldn’t manage such a patch, we’ve done nothing like this before—
Tell me where doth go this change, change to make our codebase soar!”
            Quoth Omar, “In WordPress Core.”

Props omarreis for shepherding this significant change.
Props adamsilverstein, aduth, atimmer, dingo_bastard, frank-klein, gziolo, herregroen, jaswrks, jeremyfelt, jipmoors, jorbin, netweb, ocean90, pento, tjnowell, and youknowriad for testing, feedback, discussion, encouragement, commiserations, etc.
I make no apologies for this commit message.
Fixes #43055.



git-svn-id: https://develop.svn.wordpress.org/trunk@43309 602fd350-edb4-49c9-b593-d223f7449a82
2018-05-23 10:04:22 +00:00
Gary Pendergast 50e9639f22 REST API: Add `who=authors` as a query parameter for `GET wp/v2/users`.
Any WordPress user who can `edit_posts` of a post type with `show_in_rest=true` can query for authors. This maps to current WordPress behavior where a WordPress user who can view the Manage Posts view for a post type can see any WordPress user assigned to a post (whether published or draft).

This implementation, over restricting `who=authors` to users with `list_users`, gives us future flexibility in displaying lists of posts. It still respects more restrictive permissions for `context=edit`.

Props danielbachhuber.
Fixes #42202.



git-svn-id: https://develop.svn.wordpress.org/trunk@43001 602fd350-edb4-49c9-b593-d223f7449a82
2018-04-25 13:05:48 +00:00
Gary Pendergast f9e4467b3d REST API: Remove `permalink_structure` from the index.
This was originally added to allow Gutenberg to do permalink editing, but is no longer required. It's also superceded by #41014.

Reverts [42142].
Fixes #42465.



git-svn-id: https://develop.svn.wordpress.org/trunk@42997 602fd350-edb4-49c9-b593-d223f7449a82
2018-04-23 04:11:42 +00:00
Gary Pendergast 30354e5a9b Tests: Update the REST API fixtures.
[42967] included new post statii, but didn't add them to the REST API tests.

See #43481.



git-svn-id: https://develop.svn.wordpress.org/trunk@42972 602fd350-edb4-49c9-b593-d223f7449a82
2018-04-13 00:53:31 +00:00
Adam Silverstein 495ac15555 REST API: Handle api-request query parameters with plain permalinks.
When constructing the request URL, ensure that  `?` is replaced with `&` when the API root  already contains a `?`. Fixes an issue where requests were broken when sites had permalinks set to plain.

Props aduth.
Fixes #42382.



git-svn-id: https://develop.svn.wordpress.org/trunk@42965 602fd350-edb4-49c9-b593-d223f7449a82
2018-04-09 13:09:41 +00:00
Peter Wilson ec8734bc2e REST API: Update the fixture data for `wp-api.js` tests following [42359].
Props danielbachhuber.
See #41014.



git-svn-id: https://develop.svn.wordpress.org/trunk@42540 602fd350-edb4-49c9-b593-d223f7449a82
2018-01-22 06:33:02 +00:00
Gary Pendergast 58fad5bf57 REST API: Add `permalink_structure` to the index endpoint.
This allows Gutenberg to implement permalink editing.

Props schlessera.
Fixes #42465.



git-svn-id: https://develop.svn.wordpress.org/trunk@42142 602fd350-edb4-49c9-b593-d223f7449a82
2017-11-10 06:10:23 +00:00
Weston Ruter 8f661ef667 Customize: Allow 0:00-0:59 in date/time control when 24-hour time used.
* Let min hour be 0 and max be 23 in 24-hour time; let min hour be 1 and max be 12 in 12-hour time.
* Show error notification when an invalid date value is provided, not just when not a future date.
* Fix translation of custom validity message.
* Start checking for validity after all inputs have been initially populated.
* Remove support for being able to enter 24:00.
* Cease forcing date input elements from being casted to integers, to allow for invalid inputs to be detected.

Props westonruter, Presskopp, peterwilsoncc, atachibana for testing.
See #39896, #28721.
Fixes #42373.


git-svn-id: https://develop.svn.wordpress.org/trunk@42042 602fd350-edb4-49c9-b593-d223f7449a82
2017-10-30 16:39:06 +00:00
Weston Ruter a9405baf66 Tests: Remove references to deleted JS files in QUnit tests.
Amends [41570], [40584].
See #41755, #40690.


git-svn-id: https://develop.svn.wordpress.org/trunk@42041 602fd350-edb4-49c9-b593-d223f7449a82
2017-10-30 04:05:20 +00:00
Weston Ruter 01bb1fd6cb Customize: Deprecate nav menu classes that are no longer used, instead of removing them immediately.
* Deprecate PHP classes `WP_Customize_New_Menu_Section` and `WP_Customize_New_Menu_Control`.
* Deprecate JS class `wp.customize.Menus.NewMenuControl`.
* Also introduce `wp.customize.Menus.createNavMenu()` for logic to create nav menus separately from the logic for handling UI interactions.

Amends [41768].
See #40104, #42364.
Fixes #42357.


git-svn-id: https://develop.svn.wordpress.org/trunk@42034 602fd350-edb4-49c9-b593-d223f7449a82
2017-10-28 05:47:06 +00:00
Gary Pendergast 698747975a Tests: Update `wp-api-generated.js`.
[41979] caused a change in `wp-api-generated.js`, so it needs to be updated.

See #39996.



git-svn-id: https://develop.svn.wordpress.org/trunk@42032 602fd350-edb4-49c9-b593-d223f7449a82
2017-10-28 01:56:00 +00:00
Konstantin Obenland 043609bca4 Customize: Allow menu creation in locations pane
Adds a link to the menu creation workflow from the locations selector in the nav menu control.

Props bpayton, westonruter, Travel_girl, melchoyce, celloexpressions.
Fixes #36279.


git-svn-id: https://develop.svn.wordpress.org/trunk@41899 602fd350-edb4-49c9-b593-d223f7449a82
2017-10-18 14:50:34 +00:00
Weston Ruter bb63758be8 Customize: Add changeset locking in Customizer to prevent users from overriding each other's changes.
* Customization locking is checked when changesets are saved and when heartbeat ticks.
* Lock is lifted immediately upon a user closing the Customizer.
* Heartbeat is introduced into Customizer.
* Changes made to user after it was locked by another user are stored as an autosave revision for restoration.
* Lock notification displays link to preview the other user's changes on the frontend.
* A user loading a locked Customizer changeset will be presented with an option to take over.
* Autosave revisions attached to a published changeset are converted into auto-drafts so that they will be presented to users for restoration.
* Focus constraining is improved in overlay notifications.
* Escape key is stopped from propagating in overlay notifications, and it dismisses dismissible overlay notifications.
* Introduces `changesetLocked` state which is used to disable the Save button and suppress the AYS dialog when leaving the Customizer.
* Fixes bug where users could be presented with each other's autosave revisions.

Props sayedwp, westonruter, melchoyce.
See #31436, #31897, #39896.
Fixes #42024.


git-svn-id: https://develop.svn.wordpress.org/trunk@41839 602fd350-edb4-49c9-b593-d223f7449a82
2017-10-12 04:00:15 +00:00
Weston Ruter a0b6749534 Customize: Fix QUnit tests after failures introduced in [41768].
Props bpayton.
Fixes #40104.


git-svn-id: https://develop.svn.wordpress.org/trunk@41773 602fd350-edb4-49c9-b593-d223f7449a82
2017-10-05 04:22:09 +00:00
Weston Ruter fb28cd4663 Customize: Improve the menu creation flow.
Often, folks run into two issues when they create new menus: they click "Add a Menu" thinking it will add a new page to their menu, or they forget to assign their new menu to a location, and then wonder why it doesn't show up on their site.

This commit rearranges the order of items in the menu panel, and updates the flow for creating a menu by breaking it up into steps. Additionally, more help text has been added to guide people through the process of creating a menu.

Also adds default `type` lookups for Panel and Section instances. See #30741.

Props bpayton, obenland, westonruter, celloexpessions, afercia, melchoyce, zoonini, michelleweber.
Fixes #40104.


git-svn-id: https://develop.svn.wordpress.org/trunk@41768 602fd350-edb4-49c9-b593-d223f7449a82
2017-10-05 02:21:22 +00:00
K. Adam White 8cda3a2f55 REST API: Support ordering response collection by listed slugs.
Adds an "include_slug" orderby value for REST API collections to permit returning a collection filtered by slugs in the same order in which those slugs are specified.
Previously, the order of slugs provided with the ?slug query parameter had no effect on the order of the returned records.

Props wonderboymusic, ocean90, boonebgorges.
Fixes #40826.



git-svn-id: https://develop.svn.wordpress.org/trunk@41760 602fd350-edb4-49c9-b593-d223f7449a82
2017-10-05 00:36:43 +00:00
Konstantin Obenland 75ce48ef70 Widgets: Allow oEmbeds in video widget.
Opens up video embeds to all supported video oEmbed providers.

Props westonruter.
See #42039.


git-svn-id: https://develop.svn.wordpress.org/trunk@41759 602fd350-edb4-49c9-b593-d223f7449a82
2017-10-05 00:21:27 +00:00
Adam Silverstein a500586603 Revert "Add `wp.hooks` - JavaScript actions and filters."
Revert `wp.hooks` for now as we continue to refine and test. 

Reverts [41375].


git-svn-id: https://develop.svn.wordpress.org/trunk@41751 602fd350-edb4-49c9-b593-d223f7449a82
2017-10-04 20:24:52 +00:00
westonruter 0cc238c7c7 Customize: Allow controls to be created with pre-instantiated `Setting` object(s), or even with plain `Value` object(s).
* Allow passing settings in keyed object (e.g. `settings: { default: 'id' }  ), or as an array (e.g. `settings: [ 'id' ]`) with first being default; again, `Setting`/`Value` objects may be supplied instead of IDs.
* Allow a single setting to be supplied with just a single `setting` param, either a string or a `Setting`/`Value` object.
* Update `changeset_status` and `scheduled_changeset_date` to be added dynamically with JS and simply passing of `api.state()` instances as `setting`.
* Introduce a `data-customize-setting-key-link` attribute which, unlike `data-customize-setting-link`, allows passing the setting key (e.g. `default`) as opposed to the setting ID.
* Allow `WP_Customize_Control::get_link()` to return `data-customize-setting-key-link` when setting is not registered.
* Eliminate `default_value` from `WP_Customize_Date_Time_Control` since now comes from supplied `Value`.
* Export status choices as `wp.customize.settings.changeset.statusChoices`.
* Export date and time formats as `wp.customize.settings.dateFormat` and `wp.customize.settings.timeFormat` respectively.

Props westonruter, sayedwp.
See #39896, #30738, #30741, #42083.
Fixes #37964, #36167.


git-svn-id: https://develop.svn.wordpress.org/trunk@41750 602fd350-edb4-49c9-b593-d223f7449a82
2017-10-04 20:01:12 +00:00
Weston Ruter 3f1de03834 Customize: Improve usability of Customize JS API.
* Eliminate need to pass both ID and instance in calls to `Values#add()` for panels, sections, controls, settings, partials, and notifications.
* Eliminate need to supply `content` param when constructing a `Control`.
* Unwrap the `options.params` object passed in constructors to just pass a flat `options`. (Back-compat is maintained.)
* Add support for `templateId` param for `Control` to override which template is used for the content.
* Remove unused `previewer` being supplied in `Control` instances.
* Rename `classes` to `containerClasses` on `Notification`.
* Automatically supply `instanceNumber` to improve stable sorting.
* Use `api.Notifications` for notifications in settings instead of `api.Value`.

See #30741.
Fixes #42083.


git-svn-id: https://develop.svn.wordpress.org/trunk@41726 602fd350-edb4-49c9-b593-d223f7449a82
2017-10-04 06:47:37 +00:00
Adam Silverstein 10488d5fdc WP-API JS Client: Improve support for meta.
* Add/fix `getMeta`, `getMetas`, `setMeta` and `setMetas` helpers for models that support meta.
* Add tests for new helpers, verify meta support for `Posts`, `Comments`, `Tags` and `Users`.
* Include meta data in fixture generation and fixture file driving tests.

Fixes #41055.


git-svn-id: https://develop.svn.wordpress.org/trunk@41678 602fd350-edb4-49c9-b593-d223f7449a82
2017-10-02 18:39:30 +00:00
Adam Silverstein f2eb141e77 Menus: Increase timeout for QUnit wpNavMenu trigger tests.
Fix an (intermittent) issue where the final assertion verifying all hooks have been triggered ran too early, resulting in the test failing. 

Fixes #31218.


git-svn-id: https://develop.svn.wordpress.org/trunk@41675 602fd350-edb4-49c9-b593-d223f7449a82
2017-10-02 18:34:53 +00:00
Weston Ruter ef14cd1952 Customize: Fix `WP_Customize_Date_Time_Control` to be re-usable for plugins and custom settings.
* Allow time fields to be omitted by constructing with `timeIncluded` as `false`.
* Ensure `reportValidity` is only called on a control when it is in an expanded section.
* Rename "ampm" to "meridian".
* Improve accessibility and fix HTML validation and style issues for both the date/time control and the preview link control.
* Fix styling of dropdowns and clean CSS.
* Improve accessibility of nav menus component.

Props westonruter, afercia, sayedwp, melchoyce.
Amends [41626].
See #39896.
Fixes #42022.


git-svn-id: https://develop.svn.wordpress.org/trunk@41670 602fd350-edb4-49c9-b593-d223f7449a82
2017-10-02 04:11:50 +00:00
Adam Silverstein 625773bd8b REST API JavaScript Client: improve support for model deletion/trash.
Update the way and location the JavaScript client determines which models/endpoints require the `force=true` parameter when being deleted to avoid a `rest_trash_not_supported` error. Identify models with endpoints that support DELETE, excluding those that support the trash (posts and pages by default). Also, move the check into the default `wp.api.WPApiBaseModel.initialize()` function.

Props caercam, euthelup.
Fixes #40672.



git-svn-id: https://develop.svn.wordpress.org/trunk@41657 602fd350-edb4-49c9-b593-d223f7449a82
2017-10-01 13:06:43 +00:00
Weston Ruter a92bb89f4f Customize: Introduce drafting and scheduling for Customizer changesets.
* Incorporates code from the Customize Snapshots and Customize Posts feature plugins.
* Adds a new Publish Settings section for managing the changeset status, scheduled date, and frontend preview link.
* Updates Publish button to reflect the status selected in the Publish Settings (including Save Draft and Schedule).
* Deactivates the Themes section when a non-publish status selected, and deactivates the Publish Settings section when previewing a theme switch.
* Introduces an `outer` section type (`wp.customize.OuterSection` in JS) for the Publish Settings section to use and for available widgets and available nav menu panels to use in the future. These sections can be expanded while other sections are expanded.
* Introduces `WP_Customize_Date_Time_Control` in PHP and `wp.customize.DateTimeControl` in JS for managing a date/time value.
* Keeps track of scheduled time and proactively publish from the client when the time arrives, as opposed to waiting for WP Cron.
* Auto-publishes a scheduled changeset when attempting to access one that missed its schedule.
* Starts a new changeset if attempting to save a changeset that was previously publish.
* Adds `force` arg to `requestChangesetUpdate()` to force an update request even when there are no pending changes.
* Adds utils methods for `getCurrentTimestamp` and `getRemainingTime`.
* Adds new state values for `selectedChangesetStatus`, `changesetDate`, `selectedChangesetDate`.
* Fixes logic for when to short-circuit check to close Customizer when there are unsaved changes.
* Adds getter methods for `autosaved` and `branching` parameters, with the latter applying the `customize_changeset_branching` filter.
* Call to `establish_loaded_changeset` on the fly when `changeset_uuid()` is called if no changeset UUID was specififed.
* De-duplicates logic for dismissing auto-draft changesets.
* Includes unit tests.

Builds on [41597].
Props sayedwp, westonruter, melchoyce, JoshuaWold, folletto, stubgo, karmatosed, dlh, paaljoachim, afercia, johnregan3, utkarshpatel, valendesigns.
See #30937.
Fixes #39896, #28721, #39275.


git-svn-id: https://develop.svn.wordpress.org/trunk@41626 602fd350-edb4-49c9-b593-d223f7449a82
2017-09-27 22:24:37 +00:00