Commit Graph

375 Commits

Author SHA1 Message Date
K. Adam White
b78819c3fa REST API: Reuse previously-generated embedded objects when building collection response.
Store each generated embedded object in a temporary cache when querying for linked resources so that repeated links to the same resource do not trigger repeated queries or processing.

Props TimothyBlynJacobs.
Fixes #48838.


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


git-svn-id: http://core.svn.wordpress.org/trunk@46938 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2020-01-30 20:22:07 +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
2900bb8ea7 Docs: Update links to https://secure.php.net/, they now redirect to https://www.php.net/.
See #48303.
Built from https://develop.svn.wordpress.org/trunk@47088


git-svn-id: http://core.svn.wordpress.org/trunk@46888 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2020-01-20 03:14:06 +00:00
Sergey Biryukov
dd4d98a368 Docs: In various @return tags, list the expected type first, instead of false.
Follow-up to [46696].

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


git-svn-id: http://core.svn.wordpress.org/trunk@46860 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2020-01-11 18:32:05 +00:00
Sergey Biryukov
ea6e0cc3ca Coding Standards: Use Yoda conditions in wp-includes/rest-api/endpoints/class-wp-rest-users-controller.php.
Props jenilk.
Fixes #49150.
Built from https://develop.svn.wordpress.org/trunk@47050


git-svn-id: http://core.svn.wordpress.org/trunk@46850 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2020-01-08 11:32:02 +00:00
Sergey Biryukov
ce48d7502c REST API: Display the actual conflicting value in addition to the taxonomy name in the _doing_it_wrong() message for a conflicting rest_base or name property.
Follow-up to [47037] and [47045].

Props TimothyBlynJacobs.
See #48401.
Built from https://develop.svn.wordpress.org/trunk@47046


git-svn-id: http://core.svn.wordpress.org/trunk@46846 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2020-01-06 17:09:04 +00:00
Sergey Biryukov
a540d748d3 REST API: Display the taxonomy name in the _doing_it_wrong() message for a conflicting rest_base or name property, to match the translator comment.
Follow-up to [47037].

See #48401.
Built from https://develop.svn.wordpress.org/trunk@47045


git-svn-id: http://core.svn.wordpress.org/trunk@46845 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2020-01-06 16:47:02 +00:00
Sergey Biryukov
28639fc8d5 I18N: Replace rest_authentication_errors filter name with a placeholder in a translatable string.
Follow-up to [38947] and [40038].

See #38446.
Built from https://develop.svn.wordpress.org/trunk@47044


git-svn-id: http://core.svn.wordpress.org/trunk@46844 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2020-01-06 16:21:04 +00:00
K. Adam White
08f53ef906 REST API: Issue doing_it_wrong if a taxonomy's specified rest_base is already in use by a different resource.
Props fgiannar, TimothyBlynJacobs, kingkool68, SergeyBiryukov.
Fixes #48401.


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


git-svn-id: http://core.svn.wordpress.org/trunk@46837 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2020-01-03 19:24:03 +00:00
K. Adam White
7660fcda61 REST API: Short-circuit comment controller permissions check if commented-upon post type does not exist.
Props imani3011, dragosh635, subrataemfluence, timothyblynjacobs.
Fixes #42238.


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


git-svn-id: http://core.svn.wordpress.org/trunk@46836 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2020-01-03 18:44:03 +00:00
Sergey Biryukov
9bec6f1e54 REST API: Synchronize permission checks in ::get_items_permissions_check() methods for post types, post statuses, and users:
* Only query post types with `'show_in_rest' => true` instead of looping over all post types and checking the `show_in_rest` property separately.
* Return from the `foreach()` loop as soon as the permission check succeeded.

Props pbiron, TimothyBlynJacobs, SergeyBiryukov.
Fixes #49118.
Built from https://develop.svn.wordpress.org/trunk@47034


git-svn-id: http://core.svn.wordpress.org/trunk@46834 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2020-01-03 02:28:03 +00:00
whyisjake
9e87c5b7b4 Ensure that a user can publish_posts before making a post sticky.
Props: danielbachhuber, whyisjake, peterwilson, xknown.


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


git-svn-id: http://core.svn.wordpress.org/trunk@46693 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2019-12-12 17:52:02 +00:00
John Blackbourn
f93ee2ca76 Docs: Increase the specificity of various docblock parameter types and return types.
See #48303
Built from https://develop.svn.wordpress.org/trunk@46823


git-svn-id: http://core.svn.wordpress.org/trunk@46623 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2019-12-06 22:43:04 +00:00
John Blackbourn
aa1fdcbd52 Docs: Correct various docblocks documentation.
See #48303
Built from https://develop.svn.wordpress.org/trunk@46821


git-svn-id: http://core.svn.wordpress.org/trunk@46621 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2019-12-06 22:23:04 +00:00
Sergey Biryukov
1d1c74385f REST API: Use strict in_array() checks for the list of usernames blacklisted via illegal_user_logins filter.
See #48839.
Built from https://develop.svn.wordpress.org/trunk@46804


git-svn-id: http://core.svn.wordpress.org/trunk@46604 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2019-11-29 22:04:02 +00:00
Sergey Biryukov
86c441140b REST API: Use a strict in_array() check in WP_REST_Request::get_parameter_order().
See #48839.
Built from https://develop.svn.wordpress.org/trunk@46803


git-svn-id: http://core.svn.wordpress.org/trunk@46603 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2019-11-29 22:01:03 +00:00
Sergey Biryukov
d33571f7d5 REST API: Use a strict in_array() check in WP_REST_Meta_Fields::get_registered_fields().
Props dkarfa.
Fixes #48839.
Built from https://develop.svn.wordpress.org/trunk@46802


git-svn-id: http://core.svn.wordpress.org/trunk@46602 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2019-11-29 21:59:03 +00:00
Sergey Biryukov
04ba6a1d8f Docs: Correct parameter type for $item in WP_REST_Terms_Controller::prepare_item_for_response().
Props diddledan, TimothyBlynJacobs.
Fixes #48616.
Built from https://develop.svn.wordpress.org/trunk@46731


git-svn-id: http://core.svn.wordpress.org/trunk@46531 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2019-11-14 08:55:02 +00:00
John Blackbourn
3def77672d Docs: Correct some invalid hook docblocks.
See #48303

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


git-svn-id: http://core.svn.wordpress.org/trunk@46529 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2019-11-12 22:42:02 +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
Sergey Biryukov
1f816ad18d Docs: Use the {@see ...} tag for the replacement in @deprecated tags, so that Developer Reference could automatically link to the replacement.
Props jrf.
See #48255.
Built from https://develop.svn.wordpress.org/trunk@46685


git-svn-id: http://core.svn.wordpress.org/trunk@46485 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2019-11-09 13:05:02 +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
whyisjake
5b4fe55ee8 REST API: Fix for Yoda condition.
Little coding standards fix for the REST API.

Props mukesh27, spenserhale.

Fixes #48337.

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


git-svn-id: http://core.svn.wordpress.org/trunk@46454 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2019-11-05 17:38:03 +00:00
TimothyBlynJacobs
5124c542e1 REST API: Add tax relation parameter to posts collection.
The REST API supports filtering by terms across multiple taxonomies using an AND relation. This adds support for an OR relation by adding "tax_relation=OR" as a query parameter.

Props earnjam.
Fixes #44326.

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


git-svn-id: http://core.svn.wordpress.org/trunk@46446 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2019-11-03 23:14:02 +00:00
Sergey Biryukov
2651ff3ae8 Docs: Update URLs in some @link tags and switch them to HTTPS.
Props tsuyoring.
Fixes #48479.
Built from https://develop.svn.wordpress.org/trunk@46626


git-svn-id: http://core.svn.wordpress.org/trunk@46423 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2019-11-01 14:57:02 +00:00
John Blackbourn
c08dbe5236 Docs: Coding standards fix after [46608].
See #48303

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


git-svn-id: http://core.svn.wordpress.org/trunk@46406 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2019-10-28 19:35:07 +00:00
John Blackbourn
817807e5be Docs: Remove some funky nested filters.
See #48303

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


git-svn-id: http://core.svn.wordpress.org/trunk@46405 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2019-10-28 19:04:05 +00:00
K. Adam White
cfec48cc31 REST API: Cast empty meta values to correct scalar types in REST response.
Introducing complex meta value handling in [45807] unintentionally removed value casting for empty scalar meta values.

Props TimothyBlynJacobs, chrisvanpatten, rmccue, kadamwhite.
Fixes #48363.


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


git-svn-id: http://core.svn.wordpress.org/trunk@46360 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2019-10-21 19:10:06 +00:00
Sergey Biryukov
e8fcc3fbe7 Docs: Fix typo in a comment in WP_REST_Settings_Controller::prepare_value().
Convert the comment to a multi-line format per the documentation standards.

Props itowhid06.
See #48296.
Built from https://develop.svn.wordpress.org/trunk@46471


git-svn-id: http://core.svn.wordpress.org/trunk@46269 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2019-10-13 10:02:04 +00:00
Peter Wilson
8730eb34e3 Docs: Correct comment typo in WP_REST_Terms_Controller::update_item().
Props manikmist09.
Fixes #48295. See #47110.

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


git-svn-id: http://core.svn.wordpress.org/trunk@46267 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2019-10-13 02:42:01 +00:00
K. Adam White
55560a708f REST API: Do not addslash when receiving meta arrays of non-string values.
Slashing non-string data caused PUT requests containing unmodified meta arrays of integers to fail the check against the existing stored meta value, causing a 500 when posting an unmodified response body back to the server.

Props TimothyBlynJacobs, augustuswm.
Fixes #48264.

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


git-svn-id: http://core.svn.wordpress.org/trunk@46252 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2019-10-09 17:36:01 +00:00
K. Adam White
ed11103f39 REST API: Ensure rest_controller instantiates the post type's declared REST controller class.
Ensures that the ::get_rest_controller() method will always return an instanceof the expected controller class, or null.
Removes unused private static property $post_type_controllers.

Props dlh, TimothyBlynJacobs.
Fixes #45677.


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


git-svn-id: http://core.svn.wordpress.org/trunk@46233 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2019-10-08 13:43:02 +00:00
K. Adam White
5815551dfe REST API: Permit embedding of the 'self' link relation in the /search endpoint.
Removes a special-case prohibition against embedding 'self' which prevented ?_embed from being used with the /wp/v2/search endpoint.

Props TimothyBlynJacobs, chrisvanpatten, kadamwhite.
Fixes #47684.


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


git-svn-id: http://core.svn.wordpress.org/trunk@46232 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2019-10-08 04:45:02 +00:00
K. Adam White
de6d164870 REST API: Ensure users with "moderate_comments" capability may edit comments.
Props meloniq.
Fixes #47024.


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


git-svn-id: http://core.svn.wordpress.org/trunk@46231 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2019-10-08 04:02:02 +00:00
Andrew Ozz
67b2ff7bc3 REST API: Add support for continuing the post-processing of images after upload. Flow:
1. `POST /wp/v2/media`.
2. If the upload failed (HTTP 500 error), look for a response header with `X-WP-Upload-Attachment-ID` header that contains the newly created attachment ID.
3. `POST /wp/v2/media/{id}/post-process` with `{ "action": "create-image-subsizes" }`. This request may still fail, but it will save its progress.
4. On continued failure, `DELETE /wp/v2/media/{id}` to give up on the upload and instruct the user to resize their image before uploading.

Props TimothyBlynJacobs.
Fixes #47987.
Built from https://develop.svn.wordpress.org/trunk@46422


git-svn-id: http://core.svn.wordpress.org/trunk@46220 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2019-10-07 17:06:03 +00:00
Sergey Biryukov
736403a26e REST API: Combine array and object cases in WP_REST_Meta_Fields::get_default_for_type() to remove duplicated line.
Add missing description for `$type` parameter.

Props itowhid06, dkarfa.
Fixes #48169.
Built from https://develop.svn.wordpress.org/trunk@46346


git-svn-id: http://core.svn.wordpress.org/trunk@46145 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2019-09-29 22:34:57 +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
ef86b03619 REST API: Introduce date_floating property on status endpoint response objects.
Expose a date_floating property on all status objects to permit clients (including the block editor) to make correct decisions about date handling for posts of varying status.

Props mnelson4, earnjam, kadamwhite, jnylen0, nerrad, pento.
See #39953.


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


git-svn-id: http://core.svn.wordpress.org/trunk@46064 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2019-09-23 17:40:58 +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
desrosj
3cf6276ed0 Code Modernization: Remove JSON extension workarounds for PHP < 5.6.
The PHP native JSON extension has been bundled and compiled with PHP by default since version 5.2.0. Because the minimum version of PHP required by WordPress is now 5.6.20 (see #46594 and [45058]), JSON extension related polyfills and backwards compatibility code can now be removed.

This change removes code that supported JSON related functionality on older versions of PHP. This includes (but is not limited to) checks that `json_last_error()` exists, checking and setting the `JSON_UNESCAPED_SLASHES` and `JSON_PRETTY_PRINT` constants if not previously defined, and deprecating the `_wp_json_prepare_data()` function (which was 100% workaround code).

Follow up of [46205].

See #47699.
Props jrf, Clorith, pento.
Built from https://develop.svn.wordpress.org/trunk@46206


git-svn-id: http://core.svn.wordpress.org/trunk@46018 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2019-09-20 20:08:57 +00:00
K. Adam White
6c931ed61a REST API: Revert [45687].
This change may not be needed and further investigation is required before we accept it into a release.

See #46907.


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


git-svn-id: http://core.svn.wordpress.org/trunk@46003 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2019-09-19 15:50:59 +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
Aaron Jorbin
dd3ad3ac51 GENERAL: Remove magic quote functions
The path to magic quote sanity took a fun and exciting turn: PHP core removed it and WordPress updated the minimum version.

For the formally external pclzip, the code is commented out to make investigating easier and in case we ever need to merge upstream (if that still exists) changes.

Props ayeshrajans, jrf, jorbin.
See #47783.
Fixes #18322.

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


git-svn-id: http://core.svn.wordpress.org/trunk@45917 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2019-09-13 22:21:01 +00:00
K. Adam White
742ab2d68b REST API: Return term resources in "edit" context after PUT or POST request.
Props westonruter, dlh.
Fixes #41411.


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


git-svn-id: http://core.svn.wordpress.org/trunk@45910 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2019-09-12 21:29:57 +00:00
Sergey Biryukov
dcb08f0637 Docs: Fix placement of some duplicate hook references.
Hook documentation should be on the line directly above the line containing the `do_action()` or `apply_filters()` call. 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 duplicate hook references.

Includes minor code layout fixes.

See #47110.
Built from https://develop.svn.wordpress.org/trunk@46088


git-svn-id: http://core.svn.wordpress.org/trunk@45900 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2019-09-10 19:23:55 +00:00
Sergey Biryukov
6cab9557fb REST API: Mark WP_REST_Users_Controller::update_current_item() and ::delete_current_item() as public.
Props dkarfa.
Fixes #47967.
Built from https://develop.svn.wordpress.org/trunk@46070


git-svn-id: http://core.svn.wordpress.org/trunk@45882 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2019-09-05 23:18:55 +00:00
Sergey Biryukov
65747e3c91 Docs: Remove extra spaces in various REST API DocBlocks.
See #47110.
Built from https://develop.svn.wordpress.org/trunk@46069


git-svn-id: http://core.svn.wordpress.org/trunk@45881 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2019-09-05 23:05:55 +00:00
Sergey Biryukov
7fb9cba55a Docs: Correct DocBlocks for WP_REST_Posts_Controller::get_available_actions() and WP_REST_Revisions_Controller::get_parent().
Props dkarfa.
Fixes #47966.
Built from https://develop.svn.wordpress.org/trunk@46068


git-svn-id: http://core.svn.wordpress.org/trunk@45880 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2019-09-05 22:59:54 +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