Commit Graph

142 Commits

Author SHA1 Message Date
Sergey Biryukov 6a8f9bf499 Docs: Add missing full stop for a comment in `create_initial_rest_routes()`.
Follow-up to [49154].

Props david.binda.
Fixes #51788.
Built from https://develop.svn.wordpress.org/trunk@49611


git-svn-id: http://core.svn.wordpress.org/trunk@49349 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2020-11-16 16:48:12 +00:00
John Blackbourn 753ae723ad Docs: Corrections and improvements to inline docs relating to the REST API.
See #50768

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


git-svn-id: http://core.svn.wordpress.org/trunk@49348 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2020-11-16 11:04:12 +00:00
Sergey Biryukov c66edd0439 REST API: Use `_n()` in some error messages for proper plural forms support.
Follow-up to [47923], [49053].

Props audrasjb, tobifjellner, TimothyBlynJacobs, SergeyBiryukov.
Fixes #51727.
Built from https://develop.svn.wordpress.org/trunk@49536


git-svn-id: http://core.svn.wordpress.org/trunk@49274 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2020-11-07 21:59:11 +00:00
TimothyBlynJacobs 7fe78e2f18 REST API: Make sure all supported JSON Schema keywords are output in the index.
Previously, only a small subset of keywords were exposed which limited the utility of `OPTIONS` requests.

Props raubvogel, TimothyBlynJacobs.
Fixes #51020.

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


git-svn-id: http://core.svn.wordpress.org/trunk@49019 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2020-10-20 20:19:09 +00:00
TimothyBlynJacobs c9f737619a REST API: Add support for the oneOf and anyOf keywords.
This allows for REST API routes to define more complex validation requirements as JSON Schema instead of procedural validation.

The error code returned from `rest_validate_value_from_schema` for invalid parameter types has been changed from the generic `rest_invalid_param` to the more specific `rest_invalid_type`.

Props yakimun, johnbillion, TimothyBlynJacobs.
Fixes #51025.

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


git-svn-id: http://core.svn.wordpress.org/trunk@49008 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2020-10-20 18:24:09 +00:00
desrosj d40c365a30 Coding Standards: Correct some minor coding standards issues.
Introduced in [49154], [49212], [49223], and [49224].
Built from https://develop.svn.wordpress.org/trunk@49225


git-svn-id: http://core.svn.wordpress.org/trunk@48987 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2020-10-20 13:29:08 +00:00
Sergey Biryukov 1faa241fb6 Code Modernization: Use `instanceof` instead of a comparison with `get_class()`.
Includes adjusting external libraries which are no longer maintained externally.

Props jrf.
See #50767.
Built from https://develop.svn.wordpress.org/trunk@49194


git-svn-id: http://core.svn.wordpress.org/trunk@48956 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2020-10-18 17:33:07 +00:00
TimothyBlynJacobs 039ce3f16f Site Health, REST API: Move async tests to REST API endpoints.
This provides more flexibility when writing tests and benefits from running in a front-end context which is necessary for some tests like checking that updates are supported. Additionally, this provides a more robust interface for developers who want to integrate with Site Health tests.

Because the `wp/v2` endpoint is reserved for modeling core entities, site health is registered in its own `wp-site-health/v1` namespace.

The existing ajax actions have been maintained for backward compatibility.

Props Clorith, chrisvanpatten, afragen, pokhriyal, TimothyBlynJacobs.
Fixes #48105.

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


git-svn-id: http://core.svn.wordpress.org/trunk@48916 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2020-10-15 02:00:08 +00:00
TimothyBlynJacobs 49a399db05 REST API: Introduce search post format handler.
This allows for clients to search the used post formats via the /wp/v2/search endpoint by using a type=post-format query parameter.
Fixes #51459.
Props andraganescu, zieladam, noisysocks, TimothyBlynJacobs.

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


git-svn-id: http://core.svn.wordpress.org/trunk@48894 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2020-10-12 19:54:05 +00:00
John Blackbourn 905460bd5e Docs: Standardise the type name for booleans and integers.
This brings these docs inline with the documentation standards.

Props ravipatel, justinahinon

Fixes #51426

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


git-svn-id: http://core.svn.wordpress.org/trunk@48882 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2020-10-10 20:02:05 +00:00
TimothyBlynJacobs d5ebe12f11 REST API: Introduce Application Passwords for API authentication.
In WordPress 4.4 the REST API was first introduced. A few releases later in WordPress 4.7, the Content API endpoints were added, paving the way for Gutenberg and countless in-site experiences. In the intervening years, numerous plugins have built on top of the REST API. Many developers shared a common frustration, the lack of external authentication to the REST API.

This commit introduces Application Passwords to allow users to connect to external applications to their WordPress website. Users can generate individual passwords for each application, allowing for easy revocation and activity monitoring. An authorization flow is introduced to make the connection flow simple for users and application developers.

Application Passwords uses Basic Authentication, and by default is only available over an SSL connection.

Props georgestephanis, kasparsd, timothyblynjacobs, afercia, akkspro, andraganescu, arippberger, aristath, austyfrosty, ayesh, batmoo, bradyvercher, brianhenryie, helen, ipstenu, jeffmatson, jeffpaul, joostdevalk, joshlevinson, kadamwhite, kjbenk, koke, michael-arestad, Otto42, pekz0r, salzano, spacedmonkey, valendesigns.
Fixes #42790.

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


git-svn-id: http://core.svn.wordpress.org/trunk@48871 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2020-10-08 22:14:06 +00:00
Sergey Biryukov 897f004a9c General: Replace older-style PHP type conversion functions with type casts.
This improves performance, readability, and consistency throughout core.

* `intval()` → `(int)`
* `strval()` → `(string)`
* `floatval()` → `(float)`

Props ayeshrajans.
Fixes #42918.
Built from https://develop.svn.wordpress.org/trunk@49108


git-svn-id: http://core.svn.wordpress.org/trunk@48870 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2020-10-08 21:15:13 +00:00
TimothyBlynJacobs f5c67c386f REST API: Introduce search term handler.
This allows for clients to search the available terms via the `/wp/v2/search` endpoint by using a `type=term` query parameter.

Fixes #51458.
Props andraganescu, zieladam, noisysocks, TimothyBlynJacobs.

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


git-svn-id: http://core.svn.wordpress.org/trunk@48865 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2020-10-08 01:32:05 +00:00
TimothyBlynJacobs 69b9b23c49 REST API: Support the patternProperties JSON Schema keyword.
Props yakimun.
Fixes #51024.

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


git-svn-id: http://core.svn.wordpress.org/trunk@48844 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2020-10-01 02:49:12 +00:00
TimothyBlynJacobs bed5797cf6 REST API: Support the multipleOf JSON Schema keyword.
Props yakimun.
Fixes #51022.

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


git-svn-id: http://core.svn.wordpress.org/trunk@48825 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2020-09-27 19:03:05 +00:00
TimothyBlynJacobs bf397c8d89 REST API: Correct @since version after [49053].
See #51023.

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


git-svn-id: http://core.svn.wordpress.org/trunk@48816 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2020-09-26 18:56:04 +00:00
TimothyBlynJacobs 9951662ebb REST API: Support the minProperties and maxProperties JSON Schema keywords.
Props yakimun.
Fixes #51023.

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


git-svn-id: http://core.svn.wordpress.org/trunk@48815 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2020-09-26 18:20:07 +00:00
TimothyBlynJacobs 55c21acc9f REST API: Extract `WP_REST_Controller::get_endpoint_args_for_item_schema()` to a standalone function.
This method is useful whenever a JSON Schema needs to be converted to a format suitable for argument validation with `WP_REST_Request`. Moving the logic into a standalone function allows developers to use it outside of the `WP_REST_Controller` context.

Props pentatonicfunk.
Fixes #50876. 

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


git-svn-id: http://core.svn.wordpress.org/trunk@48713 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2020-09-07 02:37:07 +00:00
TimothyBlynJacobs ae5fb83507 REST API: Fix multi-type schemas with integer fields.
In [48306] support for multi-typed schemas was improved to first detect the data type of the value before applying further validation. The `integer` data type was detected using the new `rest_is_integer` function. This function used logic, however, that assumed that the value had already passed an `is_numeric` check. This meant that if `integer` and `string` were both acceptable types, the value would always be considered an `integer` causing the later accurate type validation to fail.

This commit fixes the `rest_is_integer` logic to include an `is_numeric` check.

Props rtagliento.
Fixes #51146.

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


git-svn-id: http://core.svn.wordpress.org/trunk@48643 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2020-08-27 02:57:03 +00:00
Sergey Biryukov 2326c8196d Docs: Add a `@since` note to `register_rest_route()` about the `_doing_it_wrong()` notice when the required `permission_callback` argument is not set.
Follow-up to [48526].

Props psykro.
Fixes #51060.
Built from https://develop.svn.wordpress.org/trunk@48827


git-svn-id: http://core.svn.wordpress.org/trunk@48589 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2020-08-19 12:31:08 +00:00
Sergey Biryukov 1f85e7484f Docs: Consistently use third-person singular verbs for various filter descriptions, per the documentation standards.
See #50768.
Built from https://develop.svn.wordpress.org/trunk@48782


git-svn-id: http://core.svn.wordpress.org/trunk@48544 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2020-08-11 00:34:08 +00:00
Sergey Biryukov 18cd7519e1 I18N: Fix typo in a string in `rest_validate_value_from_schema()`.
Props pedromendonca.
Fixes #50879.
Built from https://develop.svn.wordpress.org/trunk@48767


git-svn-id: http://core.svn.wordpress.org/trunk@48529 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2020-08-09 02:00:04 +00:00
Sergey Biryukov 350ad6141e Coding Standards: Use consistent formatting for translator comments in `wp-includes/rest-api.php`.
See #50767.
Built from https://develop.svn.wordpress.org/trunk@48765


git-svn-id: http://core.svn.wordpress.org/trunk@48527 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2020-08-09 01:46:07 +00:00
John Blackbourn 9bc7d0a776 Docs: Another pass at some inline docs fixes mostly made by PHPCBF.
See #49572, #50744
Built from https://develop.svn.wordpress.org/trunk@48590


git-svn-id: http://core.svn.wordpress.org/trunk@48352 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2020-07-23 21:11:05 +00:00
TimothyBlynJacobs 51154cd1df REST API: Remove textdomain from doing it wrong message.
See #50075.
Props dlh.

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


git-svn-id: http://core.svn.wordpress.org/trunk@48333 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2020-07-22 22:31:04 +00:00
TimothyBlynJacobs 16784a5ea7 REST API: Optimize rest_filter_response_by_context performance.
In [47758] a new function `rest_filter_response_by_context` was introduced to expand the JSON schema features supported by the context filtering mechanism.

This commit improves the performance of that function by eliminating repetitive comparisons and loops. Additionally, it improves multi-type support for object + array types.

Fixes #50700.
Props dlh.

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


git-svn-id: http://core.svn.wordpress.org/trunk@48317 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2020-07-21 21:22:03 +00:00
TimothyBlynJacobs b8d5e161eb REST API: Issue a _doing_it_wrong when registering a route without a permission callback.
The REST API treats routes without a permission_callback as public. Because this happens without any warning to the user, if the permission callback is unintentionally omitted or misspelled, the endpoint can end up being available to the public. Such a scenario has happened multiple times in the wild, and the results can be catostrophic when it occurs.

For REST API routes that are intended to be public, it is recommended to set the permission callback to the `__return_true` built in function.

Fixes #50075.
Props rmccue, sorenbronsted, whyisjake, SergeyBiryukov, TimothyBlynJacobs.

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


git-svn-id: http://core.svn.wordpress.org/trunk@48288 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2020-07-21 12:03:05 +00:00
Sergey Biryukov 24ed3a9a30 REST API: Correct the check for `$version` argument in `rest_handle_doing_it_wrong()`.
Move `WP_REST_Response` and `WP_Error` class names out of the translatable string.

Follow-up to [48327], [48361].

See #36271.
Built from https://develop.svn.wordpress.org/trunk@48367


git-svn-id: http://core.svn.wordpress.org/trunk@48136 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2020-07-07 09:56:02 +00:00
whyisjake ad1c6c9586 REST API: Trigger `_doing_it_wrong()` if `wp_send_json()` is used on a REST API request
In addition to triggering the `_doing_it_wrong()` logging, also adds a `X-WP-DoingItWrong` header.

Fixes #36271.

Props rmccue, TimothyBlynJacobs.


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


git-svn-id: http://core.svn.wordpress.org/trunk@48130 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2020-07-07 05:01:07 +00:00
TimothyBlynJacobs d76e635459 REST API: Add support for the uniqueItems keyword.
Props sorenbronsted.
Fixes #48821.

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


git-svn-id: http://core.svn.wordpress.org/trunk@48126 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2020-07-07 03:22:03 +00:00
TimothyBlynJacobs e6f620570d REST API: Correct the return type of `rest_sanitize_value_from_schema`.
Fixes #45486.
Props birgire, Jean-David, mukesh27, priyankkpatel.

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


git-svn-id: http://core.svn.wordpress.org/trunk@48076 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2020-07-05 00:19:02 +00:00
TimothyBlynJacobs 77b474c905 REST API: Make multi-typed schemas more robust.
A multi-type schema is a schema where the `type` keyword is an array of possible types instead of a single type. For instance, `[ 'object', 'string' ]` would allow objects or string values.

In [46249] basic support for these schemas was introduced. The validator would loop over each schema type trying to find a version that matched. This worked for valid values, but for invalid values it provided unhelpful error messages. The sanitizer also had its utility restricted.

In this commit, the validators and sanitizers will first determine the best type of the passed value and then apply the schema with that set type. In the case that a value could match multiple types, the schema of the first matching type will be used.

To maintain backward compatibility, if unsupported schema types are used, the value will always pass validation. A doing it wrong notice is issued in this case.

Fixes #50300.
Props pentatonicfunk, dlh, TimothyBlynJacobs.

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


git-svn-id: http://core.svn.wordpress.org/trunk@48075 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2020-07-05 00:15:05 +00:00
Sergey Biryukov 6adad022e2 Docs: Correct spelling of "backward compatibility" per the Core Contributor Handbook glossary.
Follow-up to [45232].

See #49572.
Built from https://develop.svn.wordpress.org/trunk@48302


git-svn-id: http://core.svn.wordpress.org/trunk@48071 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2020-07-04 20:42:06 +00:00
TimothyBlynJacobs 5ffac7cab7 REST API: Only validate the format keyword if the type is a string.
This allows for using multi-type support with a string that has a format. For backwards compatibility support, the format validation will still apply if the type is not specified, or it is invalid.

Two new doing it wrong notices are issued when omitting a type, or using an invalid type.

Props ryotsun.
Fixes #50189.

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


git-svn-id: http://core.svn.wordpress.org/trunk@48069 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2020-07-04 19:53:03 +00:00
TimothyBlynJacobs 8d11801c86 REST API: Link to the REST route for the currently queried resource.
This allows for programatically determining the REST version of the current page. The links also aid human discovery of the REST API in general.

Props dshanske, tfrommen, TimothyBlynJacobs.
Fixes #49116.

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


git-svn-id: http://core.svn.wordpress.org/trunk@48042 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2020-07-02 05:57:01 +00:00
TimothyBlynJacobs 083134f694 REST API: Introduce plugin management and block directory endpoints.
These endpoints facilitate the Block Directory Inserter feature in Gutenberg. Users can now install, activate, deactivate, and delete plugins over the REST API. The block directoryendpoint allows searching for available blocks from the WordPress.org block directory.

Props cklee, talldanwp, noisysocks, joen, soean, youknowriad, dufresnesteven, gziolo, dd32, tellyworth, ryelle, spacedmonkey, TimothyBlynJacobs.
Fixes #50321.


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


git-svn-id: http://core.svn.wordpress.org/trunk@48011 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2020-07-01 04:24:03 +00:00
Sergey Biryukov c892c420b7 Docs: Miscellaneous DocBlock corrections.
See #49572.
Built from https://develop.svn.wordpress.org/trunk@48198


git-svn-id: http://core.svn.wordpress.org/trunk@47967 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2020-06-28 11:53:04 +00:00
TimothyBlynJacobs 9f14967ff0 REST API: Introduce Block Types endpoint.
This endpoint allows a user to retrieve the block type definition for all server-side registered block types.

Props spacedmonkey, aduth, gziolo, ocean90, TimothyBlynJacobs.
Fixes #47620.

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


git-svn-id: http://core.svn.wordpress.org/trunk@47942 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2020-06-26 00:46:07 +00:00
TimothyBlynJacobs 9dc7058be9 Themes: Introduce register_theme_feature API.
Currently themes can declare support for a given feature by using add_theme_support(). This commit adds a register_theme_feature() API that allows plugins and WordPress Core to declare a list of available features that themes can support.

The REST API uses this to expose a theme's supported features if the feature has been registered with "show_in_rest" set to true.

Props kadamwhite, spacedmonkey, williampatton, desrosj, TimothyBlynJacobs.
Fixes #49406.

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


git-svn-id: http://core.svn.wordpress.org/trunk@47940 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2020-06-25 22:13:10 +00:00
whyisjake d4f243d9a0 REST API: Ensure depracation errors are called while preloading data with the REST API.
Fixes #50318.

Props dlh, TimothyBlynJacobs.


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


git-svn-id: http://core.svn.wordpress.org/trunk@47919 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2020-06-23 23:04:07 +00:00
Sergey Biryukov be16bb9fba Docs: Remove extra spaces from `@param` tags.
Per the documentation standards, `@param` tags should be aligned with each other, but not with the `@return` tag.

See #49572.
Built from https://develop.svn.wordpress.org/trunk@48110


git-svn-id: http://core.svn.wordpress.org/trunk@47879 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2020-06-20 12:58:10 +00:00
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