Commit Graph

101 Commits

Author SHA1 Message Date
Sergey Biryukov
a576a13246 Docs: Remove an empty line between @param and @return tags, per the documentation standards.
See #49572.
Built from https://develop.svn.wordpress.org/trunk@48102


git-svn-id: http://core.svn.wordpress.org/trunk@47871 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2020-06-20 11:18:09 +00:00
TimothyBlynJacobs
5efaf888a5 REST API: Support the (min|max)Items JSON Schema keywords.
A future commit will add support for the uniqueItems keyword.

Props sorenbronsted.
See #48821.

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


git-svn-id: http://core.svn.wordpress.org/trunk@47697 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2020-06-07 22:42:13 +00:00
Dominik Schilling
aaeab2f3f5 Rest API: Ensure rest_ensure_response() upgrades WP_HTTP_Response to WP_REST_Response.
An instance of `WP_HTTP_Response` doesn't ensure that the required methods used in `WP_REST_Server::dispatch()` exist, currently causing a fatal error.

Props ali11007, TimothyBlynJacobs, ocean90.
Fixes #49495.
Built from https://develop.svn.wordpress.org/trunk@47849


git-svn-id: http://core.svn.wordpress.org/trunk@47625 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2020-05-23 14:36:09 +00:00
whyisjake
e7150ae5c7 REST API: Ensure proper namespacing when registering routes.
The PR will corerce routes that have a leading slash and throwing a `_doing_it_wrong` notice while ensuring a proper namespace.

Fixes #49749.
Props TimothyBlynJacobs, skarabeq, afercia.


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


git-svn-id: http://core.svn.wordpress.org/trunk@47618 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2020-05-22 20:48:08 +00:00
TimothyBlynJacobs
cf0bfa3856 Coding Standards: Correct docblock indentation.
Fixes PHPCS failure introduced in r47811.

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


git-svn-id: http://core.svn.wordpress.org/trunk@47588 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2020-05-16 19:56:09 +00:00
TimothyBlynJacobs
1e524e7322 REST API: Add @since entries for rest_validate_value_from_schema().
See #49572, #48818, #44949, #50053, #48820, #49720, #42961, #44975, #43392, #38583.

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


git-svn-id: http://core.svn.wordpress.org/trunk@47587 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2020-05-16 19:33:09 +00:00
TimothyBlynJacobs
fe00d7f7bf REST API: Support the JSON Schema pattern keyword.
Props jason_the_adams, birgire, sorenbronsted.
Fixes #44949.

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


git-svn-id: http://core.svn.wordpress.org/trunk@47586 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2020-05-16 19:03:08 +00:00
TimothyBlynJacobs
26bda18a23 REST API: Check required properties are provided when validating an object.
Previously, the WP_REST_Request object validated that top-level properties were defined, but this did not extend to those object's required properties. This adds validation to rest_validate_value_from_schema() directly.

Both the v3 and v4 JSON Schema syntax for required properties is supported.

Props sorenbronsted.
Fixes #48818.

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


git-svn-id: http://core.svn.wordpress.org/trunk@47585 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2020-05-16 18:44:09 +00:00
TimothyBlynJacobs
46854d7322 REST API: Support more JSON Schemas when filtering a response by context.
The array type, multi-types, and the additional properties keyword are now supported. Additionally, the filter recurses to an infinite depth.

Fixes #48819.

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


git-svn-id: http://core.svn.wordpress.org/trunk@47534 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2020-05-04 02:46:05 +00:00
TimothyBlynJacobs
ac3c2fe60a REST API: Support the uuid JSON Schema format.
This accepts a uuid of any version. A future commit could add support for restricting uuids to a specific version.

Props johnwatkins0.
Fixes #50053.

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


git-svn-id: http://core.svn.wordpress.org/trunk@47529 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2020-05-03 19:20:09 +00:00
TimothyBlynJacobs
352cb55cca REST API: Support the (min|max)Length JSON Schema keywords.
Props sorenbronsted.
Fixes #48820.

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


git-svn-id: http://core.svn.wordpress.org/trunk@47402 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2020-04-27 02:29:07 +00:00
Sergey Biryukov
38676936ba Coding Standards: Use strict type check for in_array() and array_search() where strings are involved.
This reduces the number of `WordPress.PHP.StrictInArray.MissingTrueStrict` issues from 486 to 50.

Includes minor code layout fixes for better readability.

See #49542.
Built from https://develop.svn.wordpress.org/trunk@47550


git-svn-id: http://core.svn.wordpress.org/trunk@47325 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2020-04-05 03:02:11 +00:00
TimothyBlynJacobs
1367b1175f REST API: Introduce "hex-color" JSON Schema format.
Props spacedmonkey, chrisvanpatten.
Fixes #49270.

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


git-svn-id: http://core.svn.wordpress.org/trunk@47237 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2020-03-12 02:42:08 +00:00
K. Adam White
44e1bbef85 REST API: Correctly infer empty objects passed via query parameters.
Permit passing an empty object as the string "?obj=". The type of the passed empty argument is inferred from the registered schema.

Props TimothyBlynJacobs, steffanhalv, schlessera, dd32.
Fixes #42961.

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


git-svn-id: http://core.svn.wordpress.org/trunk@47149 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2020-02-25 15:34:07 +00:00
TimothyBlynJacobs
5ecd61023a REST API: Introduce selective link embedding.
Previously the _embed flag would embed all embeddable links in a response even if only a subset of the links were necessary. Now, a list of link relations can be passed in the _embed parameter to restrict the list of embedded objects.

Props rheinardkorf, adamsilverstein, jnylen0, cklosows, chrisvanpatten, TimothyBlynJacobs.
Fixes #39696.

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


git-svn-id: http://core.svn.wordpress.org/trunk@47024 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2020-02-09 20:54:05 +00:00
Sergey Biryukov
641c632b0c Coding Standards: Use Yoda conditions where appropriate.
See #49222.
Built from https://develop.svn.wordpress.org/trunk@47219


git-svn-id: http://core.svn.wordpress.org/trunk@47019 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2020-02-09 16:55:09 +00:00
Sergey Biryukov
001ffe81fb Docs: Improve inline comments per the documentation standards.
Includes minor code layout fixes for better readability.

See #48303.
Built from https://develop.svn.wordpress.org/trunk@47122


git-svn-id: http://core.svn.wordpress.org/trunk@46922 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2020-01-29 00:45:18 +00:00
Sergey Biryukov
cf249b07ed I18N: Merge duplicate %1$s is not of type %2$s strings in rest_validate_value_from_schema().
Props ramiy.
Fixes #49244.
Built from https://develop.svn.wordpress.org/trunk@47091


git-svn-id: http://core.svn.wordpress.org/trunk@46891 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2020-01-20 14:44:06 +00:00
Sergey Biryukov
3d623995a8 Docs: In various @return tags, list the expected type first, instead of WP_Error.
See #48303.
Built from https://develop.svn.wordpress.org/trunk@46696


git-svn-id: http://core.svn.wordpress.org/trunk@46496 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2019-11-11 02:43:03 +00:00
John Blackbourn
f545bb3f63 Docs: Improve documentation of known return types, plus other docs fixes.
See #48303

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


git-svn-id: http://core.svn.wordpress.org/trunk@46460 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2019-11-05 21:23:02 +00:00
John Blackbourn
b3d6acd6a4 Docs: Fix some incorrect return tags in docblocks.
See #48303

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


git-svn-id: http://core.svn.wordpress.org/trunk@46444 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2019-11-03 22:23:01 +00:00
whyisjake
6c3a387d77 REST API: Allow for multiple Vary: Origin headers in GET responses.
Simple fix, we pass `false` as the second parameter to the header function.

This is something that we added downstream of the 5.2.4 release, but we missed in 5.2/trunk.

Fixes #48309.
Props xknown, whyisjake.

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


git-svn-id: http://core.svn.wordpress.org/trunk@46341 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2019-10-15 15:47:03 +00:00
whyisjake
89468bfb89 REST API: Ensure that we don't generate warnings from sending extra headers after headers have been sent.
Fixes issues stemming from [46478].


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


git-svn-id: http://core.svn.wordpress.org/trunk@46281 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2019-10-14 16:25:04 +00:00
whyisjake
b224c251ad REST API: Send a Vary: Origin header on GET requests.
Add this header on all GET requests to prevent cached requests.

Props darthhexx, davidbinda, nickdaugherty, whyisjake.

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


git-svn-id: http://core.svn.wordpress.org/trunk@46276 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2019-10-14 15:43:04 +00:00
K. Adam White
1a8aba96e7 REST API: Fix error in _fields filtering logic where only one of several requested sibling properties would be included.
Props kadamwhite, TimothyBlynJacobs.
Fixes #48266.

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


git-svn-id: http://core.svn.wordpress.org/trunk@46254 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2019-10-10 17:18:03 +00:00
K. Adam White
10772e8499 REST API: Introduce WP_Post_Type::get_rest_controller() caching method to prevent unnecessary REST controller construction.
Cache REST controller references on their associated post type object to prevent unnecessary controller re-instantiation, which previously caused "rest_prepare_{$post_type}" and "rest_{$post_type}_query" to run twice per request.

Props TimothyBlynJacobs, patrelentlesstechnologycom.
Fixes #45677.

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


git-svn-id: http://core.svn.wordpress.org/trunk@46084 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2019-09-23 20:25:57 +00:00
K. Adam White
b15c0d410e REST API: Pass "null" as the post date property to reset post to initial "floating" date value.
Props TimothyBlynJacobs, adamsilverstein, jnylen0, mnelson4.
Fixes #44975.


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


git-svn-id: http://core.svn.wordpress.org/trunk@46061 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2019-09-23 17:25:57 +00:00
K. Adam White
6da9c88729 REST API: Consistently default URL scheme to "rest", not "json".
The "json" scheme is a holdover from the pre-merge plugin version of the REST API, and was corrected elsewhere in core in [34300]. Only "rest" is officially supported in `set_url_scheme()`.

Props DrewAPicture, rmccue.
Fixes #45169.

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


git-svn-id: http://core.svn.wordpress.org/trunk@46045 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2019-09-22 19:15:57 +00:00
K. Adam White
66f907b2eb REST API: Support dot.nested hierarchical properties in _fields query parameter.
Enable clients to opt-in to receipt of one or more specific sub-properties within a response, and not other sub-properties.
Skip potentially expensive filtering and processing for post resources which were explicitly not requested.

Props kadamwhite, TimothyBlynJacobs, dlh.
Fixes #42094.

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


git-svn-id: http://core.svn.wordpress.org/trunk@45996 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2019-09-19 14:05:55 +00:00
Sergey Biryukov
55378bd295 REST API: Use correct parameter name in rest_validate_value_from_schema() error messages.
Props manzoorwanijk.
Fixes #47905.
Built from https://develop.svn.wordpress.org/trunk@46101


git-svn-id: http://core.svn.wordpress.org/trunk@45913 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2019-09-13 03:06:55 +00:00
K. Adam White
c148f0aa55 REST API: Accept string path in rest_ensure_request.
Update `rest_ensure_request()` to accept a string path, permitting a string path to be passed to `rest_do_request()` as is indicated (previously inaccurately) in that method's PHPDoc.

Props TimothyBlynJacobs, kadamwhite.
Fixes #40614.

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


git-svn-id: http://core.svn.wordpress.org/trunk@45911 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2019-09-12 21:47:57 +00:00
Sergey Biryukov
e199663322 I18N: Capitalize translator comments consistently, add trailing punctuation.
Includes minor code layout fixes.

See #44360.
Built from https://develop.svn.wordpress.org/trunk@45932


git-svn-id: http://core.svn.wordpress.org/trunk@45743 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2019-09-03 00:41:05 +00:00
Sergey Biryukov
16b8d91baa I18N: Improve translator comments.
* Add missing translator comments.
* Fix placement of some translator comments. Translator comments should be on the line directly above the line containing the translation function call for optimal compatibility with various `.pot` file generation tools. The CS auto-fixing, which changed some inconsistent function calls to multi-line function calls, is part of the reason why this was no longer the case for a select group of translator comments.

Includes minor code layout fixes.

Polyglots, rejoice! All WordPress core files now have translator comments for all strings with placeholders!

Props jrf, subrataemfluence, GaryJ, webdados, Dency, swissspidy, alvarogois, marcomartins, mihaiiceyro, vladwtz, niq1982, flipkeijzer, michielatyoast, chandrapatel, thrijith, joshuanoyce, FesoVik, tessak22, bhaktirajdev, cleancoded, dhavalkasvala, garrett-eclipse, bibliofille, socalchristina, priyankkpatel, 5hel2l2y, adamsilverstein, JeffPaul, pierlo, SergeyBiryukov.
Fixes #44360.
Built from https://develop.svn.wordpress.org/trunk@45926


git-svn-id: http://core.svn.wordpress.org/trunk@45737 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2019-09-01 17:13:59 +00:00
K. Adam White
dbfa0c7ed4 REST API: Clarify arguments passed to rest route get & update callbacks.
Update doc block argument definitions to clarify that the REST API always passes an array to the `get_callback` and always passes an entity object to the `update_callback`.

Props TimothyBlynJacobs, salzano.
Fixes #44432.


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


git-svn-id: http://core.svn.wordpress.org/trunk@45621 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2019-08-15 20:04:55 +00:00
K. Adam White
5b318f1dda REST API: Support 'object' and 'array' types in register_meta() schemas.
Extends meta registration to support complex schema values, mirroring the functionality in the settings controller.
Error when trying to modify a meta key containing schema-nonconformant data.

Props @TimothyBlynJacobs, @birgire, @mnelson4, @flixos90.
Fixes #43392.


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


git-svn-id: http://core.svn.wordpress.org/trunk@45618 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2019-08-15 17:17:55 +00:00
Sergey Biryukov
2aa8ce5bc5 REST API: In get_rest_url(), check if $_SERVER['SERVER_NAME'] is set to avoid a PHP warning in CLI context.
Props paulschreiber.
Fixes #47854.
Built from https://develop.svn.wordpress.org/trunk@45771


git-svn-id: http://core.svn.wordpress.org/trunk@45582 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2019-08-08 20:20:55 +00:00
Sergey Biryukov
ea606165a5 Docs: Add missing description for $wp global.
See #45604, #47110.
Built from https://develop.svn.wordpress.org/trunk@45736


git-svn-id: http://core.svn.wordpress.org/trunk@45547 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2019-08-04 01:28:55 +00:00
Sergey Biryukov
b1e34ccc1f Docs: Add missing description for $wp_rewrite global.
See #45604, #47110.
Built from https://develop.svn.wordpress.org/trunk@45735


git-svn-id: http://core.svn.wordpress.org/trunk@45546 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2019-08-04 01:19:56 +00:00
Sergey Biryukov
e85a5c64a3 REST API: Allow rest_get_avatar_urls() to accept full user, post, or comment objects, rather than just an email address, to provide better flexibility for alternative avatar data.
Since the function uses `get_avatar_url()` internally, which already supports it, this should not have any backward compatibility concerns.

Props donmhico, dshanske, pputzer, joehoyle, TimothyBlynJacobs.
Fixes #40030.
Built from https://develop.svn.wordpress.org/trunk@45632


git-svn-id: http://core.svn.wordpress.org/trunk@45443 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2019-07-14 14:35:56 +00:00
Sergey Biryukov
e23ce44744 REST API: Call WP_REST_Server::get_compact_response_links() and ::get_raw_data() static methods the right way.
Props andizer, TimothyBlynJacobs.
Fixes #47578.
Built from https://develop.svn.wordpress.org/trunk@45566


git-svn-id: http://core.svn.wordpress.org/trunk@45377 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2019-06-26 18:07:54 +00:00
Sergey Biryukov
c77e771c84 Date/Time: Replace all instances of date() with gmdate().
Use of `date()` in core depends on PHP timezone set to UTC and not changed by third party code (which cannot be guaranteed).

`gmdate()` is functionally equivalent, but is not affected by PHP timezone setting: it's always UTC, which is the exact behavior the core needs.

Props nielsdeblaauw, Rarst.
Fixes #46438. See #44491.
Built from https://develop.svn.wordpress.org/trunk@45424


git-svn-id: http://core.svn.wordpress.org/trunk@45235 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2019-05-26 00:12:54 +00:00
K. Adam White
391d481fe1 REST API: Ensure "Allow" header is returned for OPTIONS requests.
This changeset ensures `$request->set_url_params()` is called while fulfilling OPTIONS requests, where previously it was skipped because OPTIONS requests short-circuit the logic in `dispatch` which handles this setup for other request methods. Omitting the URL parameters prevented the Allow header from being set.

Props killua99, noisysocks.
Fixes #45753.

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


git-svn-id: http://core.svn.wordpress.org/trunk@44764 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2019-03-19 03:22:51 +00:00
Dominik Schilling
fe73f310d4 REST API: Prevent translating the hook name in a _doing_it_wrong() message by using a placeholder.
See #45265.
Built from https://develop.svn.wordpress.org/trunk@44698


git-svn-id: http://core.svn.wordpress.org/trunk@44529 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2019-01-26 12:29:54 +00:00
desrosj
2785313bf2 REST API: Encourage proper usage of register_rest_route().
Calling `register_rest_route()` too early in the loading process has the potential to cause some unintentional problems and pitfalls. Because `register_rest_route()` calls `rest_get_server()` (which creates the `WP_REST_Server` instance), calling the function directly and/or before `rest_api_init` should be discouraged.

For example, if `register_rest_route ()` is called on `init`, the REST API server instance is set up (and all functions added to `rest_api_init` and other related hooks are invoked), even though the current request may not be a REST request. Also, if `register_rest_route()` is called even earlier (say, in an `mu-plugin` file), required endpoints may be missing since normal plugins have not yet been loaded and have not had a chance to register their own action hooks.

This adds a `_doing_it_wrong()` notice the first time `register_rest_route()` is called before `rest_api_init` in a request to encourage best practices for registering REST API routes.

Props kraftbj, desrosj, timothyblynjacobs.
Fixes #45265.
Built from https://develop.svn.wordpress.org/trunk@44568


git-svn-id: http://core.svn.wordpress.org/trunk@44399 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2019-01-11 18:19:49 +00:00
Felix Arntz
a71d208785 General: Fix problematic string to array parsing.
WordPress has historically often used code like `preg_split( '/[\s,]+/', $var )` to parse a string of comma-separated values into an array. However, this approach was causing an empty string to not be parsed into an empty array as expected, but rather into an array with the empty string as its sole element.

This was among other areas causing problems in the REST API where passing an empty request parameter could cause that request to fail because, instead of it being ignored, that parameter would be compared against the valid values for it, which typically do not include an empty string.

Props david.binda, sstoqnov.
Fixes #43977.

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


git-svn-id: http://core.svn.wordpress.org/trunk@44377 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2019-01-10 21:06:49 +00:00
Gary Pendergast
d2782aabc5 REST API: Improve performance by avoiding call_user_func().
The `get_compact_response_links()` method was introduced in WP 4.5, and this conditional is no longer necessary.

Merges [43834] from the 5.0 branch to trunk.

Props schlessera, timothyblynjacobs.
Fixes #45189.

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


git-svn-id: http://core.svn.wordpress.org/trunk@44003 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2018-12-14 06:04:55 +00:00
Gary Pendergast
d8863244cb Block Editor: Preload wp/v2/media with OPTIONS for caps check.
Also introduces a `block_editor_preload_paths` filter for plugins and themes to preload additional data.

Merges [43833] from the 5.0 branch to trunk.

Props imath, mattheu, danielbachhuber.
Fixes #45194.


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


git-svn-id: http://core.svn.wordpress.org/trunk@44002 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2018-12-14 06:02:52 +00:00
Jeremy Felt
c3e927d2c8 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.

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


git-svn-id: http://core.svn.wordpress.org/trunk@43980 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2018-12-14 02:35:38 +00:00
desrosj
d4d16ec083 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.
Built from https://develop.svn.wordpress.org/trunk@44126


git-svn-id: http://core.svn.wordpress.org/trunk@43956 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2018-12-13 22:42:38 +00:00
desrosj
d16e6740d5 REST API: Introduce the rest_preload_api_request() function.
This function helps perform multiple REST API requests, for the purpose of preloading data into a page.

Props pento.

Merges [43763] to trunk.

See #45110.
Built from https://develop.svn.wordpress.org/trunk@44123


git-svn-id: http://core.svn.wordpress.org/trunk@43953 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2018-12-13 22:25:49 +00:00