Commit Graph

362 Commits

Author SHA1 Message Date
Sergey Biryukov
aa22457754 REST API: Use a consistent description for the textdomain schema property between plugins and themes controllers.
Follow-up to [48242], [48627].

Props audrasjb.
Fixes #50776. See #50321.
Built from https://develop.svn.wordpress.org/trunk@48628


git-svn-id: http://core.svn.wordpress.org/trunk@48390 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2020-07-26 21:54:03 +00:00
Sergey Biryukov
e7eaaa97b1 REST API: Use a consistent name for the textdomain schema property between plugins, themes, and block directory controllers.
Follow-up to [48242].

See #50321, #50776.
Built from https://develop.svn.wordpress.org/trunk@48627


git-svn-id: http://core.svn.wordpress.org/trunk@48389 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2020-07-26 21:49:03 +00:00
Sergey Biryukov
61b2cb7761 Docs: Correct @since version for WP_REST_Plugins_Controller::get_item_schema().
Follow-up to [48242].

See #50321.
Built from https://develop.svn.wordpress.org/trunk@48626


git-svn-id: http://core.svn.wordpress.org/trunk@48388 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2020-07-26 21:42:03 +00:00
Sergey Biryukov
ebfe7ca39a I18N: Remove <code> tags in an error message in WP_REST_Posts_Controller::get_item_schema() for consistency with other strings.
Follow-up to [48610].

See #50759.
Built from https://develop.svn.wordpress.org/trunk@48613


git-svn-id: http://core.svn.wordpress.org/trunk@48375 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2020-07-25 16:41:02 +00:00
Sergey Biryukov
29b0a259df I18N: Move code out of a translatable string in WP_REST_Posts_Controller::get_item_schema().
Props ramiy.
Fixes #50759.
Built from https://develop.svn.wordpress.org/trunk@48610


git-svn-id: http://core.svn.wordpress.org/trunk@48372 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2020-07-25 16:28:04 +00:00
Sergey Biryukov
5323fa05e5 REST API: Use consistent error messages when managing network plugins.
Props ramiy.
Fixes #50729.
Built from https://develop.svn.wordpress.org/trunk@48556


git-svn-id: http://core.svn.wordpress.org/trunk@48318 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2020-07-21 22:01:03 +00:00
Sergey Biryukov
3061a680a9 Media: Pass the attachment ID to the wp_image_file_matches_image_meta filter.
Props spacedmonkey.
Fixes #50722.
Built from https://develop.svn.wordpress.org/trunk@48547


git-svn-id: http://core.svn.wordpress.org/trunk@48309 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2020-07-21 16:55:08 +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
Andrew Ozz
562a59f553 REST API, Media: Add X-WP-Upload-Attachment-ID HTTP header to enable retrying of post-processing of edited images if the server runs out of resources. This is the same as after uploading a new image, will do up to five additional requests to let the server create all image sub-sizes.
Fixes #50711.
Built from https://develop.svn.wordpress.org/trunk@48525


git-svn-id: http://core.svn.wordpress.org/trunk@48287 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2020-07-21 03:00:04 +00:00
Andrew Ozz
c2639c74ff REST API, Media: Fix/improve the inline docs and name of the new wp_edited_image_metadata filter.
Props desrosj, azaozz.

See #44405.
Built from https://develop.svn.wordpress.org/trunk@48518


git-svn-id: http://core.svn.wordpress.org/trunk@48280 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2020-07-20 21:04:03 +00:00
Andrew Ozz
689c224476 Media: Migrate the data from the attachment post of the parent image when saving an edited image. Copy:
- `post_title`,
- `post_content` (image description),
- `post_excerpt` (image caption as saved in the DB),
- `_wp_attachment_image_alt` meta (alt text for the img tag as saved in the DB).

Props spacedmonkey, joedolson, TimothyBlynJacobs, azaozz.
Fixes #50675.
Built from https://develop.svn.wordpress.org/trunk@48510


git-svn-id: http://core.svn.wordpress.org/trunk@48272 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2020-07-19 21:19:04 +00:00
Andrew Ozz
2d728713ac REST API: Prevent attachment ID/image source mismatch when editing an image.
Fixes #50565.
Built from https://develop.svn.wordpress.org/trunk@48498


git-svn-id: http://core.svn.wordpress.org/trunk@48260 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2020-07-16 21:56:08 +00:00
TimothyBlynJacobs
a59fb4e50f REST API: Sanitize block renderer attributes.
In [48069] the Block Renderer was changed to register a single route for all dynamic blocks. Validation was dynamically applied based on the requested block, but sanitization was not. This commit adds the same sanitization back to the block attributes.

Props manooweb.
Fixes #50620. See #48079.

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


git-svn-id: http://core.svn.wordpress.org/trunk@48206 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2020-07-11 20:34:05 +00:00
Sergey Biryukov
6bf6bc451f Docs: Miscellaneous DocBlock corrections.
See #49572.
Built from https://develop.svn.wordpress.org/trunk@48408


git-svn-id: http://core.svn.wordpress.org/trunk@48177 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2020-07-08 13:15:03 +00:00
Andrew Ozz
d1dc207128 Media, REST API: Allow media edit endpoint to find remote files.
Props jonsurrell.
Fixes #50595.
Built from https://develop.svn.wordpress.org/trunk@48386


git-svn-id: http://core.svn.wordpress.org/trunk@48155 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2020-07-07 16:51:04 +00:00
TimothyBlynJacobs
0386c0ae6c REST API: Remove specific multi-type schema handling from the themes controller.
Multi-type schema handling was improved in [48306]. In particular, it now allows for sanitizing a multi-typed value that wouldn't validate. Removing this handling will make 3rd party registered theme features more robust.

Fixes #50562.

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


git-svn-id: http://core.svn.wordpress.org/trunk@48077 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2020-07-05 01:06:02 +00:00
TimothyBlynJacobs
5af864369c REST API: Introduce endpoint for editing images.
To facilitate inline image editing in Gutenberg, a new endpoint at wp/v2/media/<id>/edit has been introduced. This is functionally similar to the existing ajax image editor, however the REST API editor creates a new attachment record instead of updating an existing attachment.

Fixes #44405.
Props ajlende, ellatrix, spacedmonkey, azaozz.


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


git-svn-id: http://core.svn.wordpress.org/trunk@48060 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2020-07-04 04:15:05 +00:00
Sergey Biryukov
ec571bdcf6 Docs: Spell "falsey" in a consistent way.
See #49572.
Built from https://develop.svn.wordpress.org/trunk@48275


git-svn-id: http://core.svn.wordpress.org/trunk@48044 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2020-07-02 11:30:02 +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
f5942603c0 Comments: Make wp_update_comment() return a WP_Error object for a canceled update, if $wp_error parameter is true.
Remove redundant checks for `wp_update_comment()` results being `false`, as the function always returns a `WP_Error` object now if `$wp_error` is true.

Follow-up to [48154], [48215], [48216].

See #39732.
Built from https://develop.svn.wordpress.org/trunk@48218


git-svn-id: http://core.svn.wordpress.org/trunk@47987 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2020-06-29 23:42:03 +00:00
Sergey Biryukov
37d48e2f2e Users: Merge two similar error messages about usernames with invalid characters.
Props ramiy, garrett-eclipse, chetan200891.
Fixes #47003.
Built from https://develop.svn.wordpress.org/trunk@48195


git-svn-id: http://core.svn.wordpress.org/trunk@47964 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2020-06-27 23:44:09 +00:00
Sergey Biryukov
5aa7f46a4f Docs: Improve DocBlocks in wp-includes/theme.php per the documentation standards.
See #49572.
Built from https://develop.svn.wordpress.org/trunk@48189


git-svn-id: http://core.svn.wordpress.org/trunk@47958 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2020-06-27 12:02:03 +00:00
Sergey Biryukov
40c389c95e Docs: Standardize on "Returning a value from the filter" vs. "Passing a value to the filter".
The filter is the callback function added with `add_filter()`, therefore the hook passes a value to the filter, and the filter returns a value to change its behaviour.

The documentation is referring to the latter.

Props johnbillion.
See #49572, #16557.
Built from https://develop.svn.wordpress.org/trunk@48185


git-svn-id: http://core.svn.wordpress.org/trunk@47954 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2020-06-26 18:49:09 +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
bb7601f6d0 Comments: Allow wp_update_comment() to return WP_Error().
The `wp_update_comment_data` filter introduced in 4.7 allows comment data to be filtered before it is updated in the database.

The patch aims to handle `WP_Error` as the filter above return value in a similar manner as is done for `wp_new_comment()`.


Fixes #39732.

Props: enricosorcinelli, swissspidy, gkloveweb, jnylen0, jbpaul17, afercia, SergeyBiryukov, audrasjb, imath, davidbaumwald.

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


git-svn-id: http://core.svn.wordpress.org/trunk@47923 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2020-06-24 00:05:12 +00:00
desrosj
4b60af1a6a General: Remove “whitelist” and “blacklist” in favor of more clear and inclusive language.
“The WordPress open source community cares about diversity. We strive to maintain a welcoming environment where everyone can feel included.”

With this commit, all occurrences of “whitelist” and “blacklist” (with the single exception of the `$new_whitelist_options` global variable) are removed. A new ticket has been opened to explore renaming the `$new_whitelist_options` variable (#50434).

Changing to more specific names or rewording sentences containing these terms not only makes the code more inclusive, but also helps provide clarity. These terms are often ambiguous. What is being blocked or allowed is not always immediately clear. This can make it more difficult for non-native English speakers to read through the codebase.

Words matter. If one contributor feels more welcome because these terms are removed, this was worth the effort.

Props strangerstudios, jorbin, desrosj, joemcgill, timothyblynjacobs, ocean90, ayeshrajans, davidbaumwald, earnjam.
See #48900, #50434.
Fixes #50413.
Built from https://develop.svn.wordpress.org/trunk@48121


git-svn-id: http://core.svn.wordpress.org/trunk@47890 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2020-06-22 17:26:13 +00:00
Sergey Biryukov
e13c363b17 Docs: Capitalize "ID", when referring to a post ID, term ID, etc. in a more consistent way.
See #49572.
Built from https://develop.svn.wordpress.org/trunk@48104


git-svn-id: http://core.svn.wordpress.org/trunk@47873 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2020-06-20 12:02:12 +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
John Blackbourn
1a77bb81d8 Docs: Remove unnecessary variables names from @return tags.
See #49572.
Built from https://develop.svn.wordpress.org/trunk@48100


git-svn-id: http://core.svn.wordpress.org/trunk@47869 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2020-06-19 22:55:12 +00:00
TimothyBlynJacobs
41f70ae5f8 REST API: Only register one block renderer route.
Every block has a different set of attributes. These attributes are specified as a JSON Schema object. Previously, every block registered its own block renderer route using its attributes for the schema. This allowed for the attributes to be validated using the built in endpoint validation rules. It had the unfortunate side effect, however, of creating a large number of nearly identical REST API routes, one for each dynamic block. Each registered route has a performance impact. As the number of server side blocks goes up, this becomes more and more of an issue.

Now, we register a single block renderer route and dynamically validate the attributes based on the selected block.

Fixes #48079.
Props gziolo, TimothyBlynJacobs.

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


git-svn-id: http://core.svn.wordpress.org/trunk@47836 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2020-06-17 03:22:12 +00:00
desrosj
784908ae5f Coding Standards: PHP short ternary operator syntax is not allowed.
WPCS 2.2.0 added a sniff for detecting short ternary operator syntax, which is not allowed per the Core handbook.

Follow up of [47927].
Fixes #50258.
Built from https://develop.svn.wordpress.org/trunk@47929


git-svn-id: http://core.svn.wordpress.org/trunk@47702 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2020-06-08 21:27:10 +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
TimothyBlynJacobs
171356a890 REST API: Add additional fields to the themes controller.
When the themes controller was introduced it only returned a theme's supported features. This adds the majority of a theme's header information to the response.

Props ockham, spacedmonkey.
Fixes #49906.

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


git-svn-id: http://core.svn.wordpress.org/trunk@47695 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2020-06-07 06:46:10 +00:00
whyisjake
00df557404 REST API: Ensure that all properties of get_endpoint_args_for_item_schema are listed.
* Add new var $valid_schema_properties to match rest_validate_value_from_schema()
* Unit test to ensure all valid properties exists, and non-valid properties are ignored

Fixes: #50301.
Props: pentatonicfunk, TimothyBlynJacobs.


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


git-svn-id: http://core.svn.wordpress.org/trunk@47685 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2020-06-04 16:43:08 +00:00
Dominik Schilling
ed71319421 Role/Capability: Use meta caps edit_post, read_post, and delete_post directly.
Rather than consulting the post type object, let `map_meta_cap()` handle that for us.

Props peterwilsoncc, ocean90.
Fixes #50128.
See #23226.
Built from https://develop.svn.wordpress.org/trunk@47850


git-svn-id: http://core.svn.wordpress.org/trunk@47626 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2020-05-23 15:24:07 +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
7023be21f5 REST API: Accept POST requests in the block renderer endpoint.
Rendering a block is idempotent, so a GET is the most natural request method. However, the maximum length of URLs prevented blocks with large attributes from being rendered.

Props ryankienstra.
Fixes #49680.

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


git-svn-id: http://core.svn.wordpress.org/trunk@47532 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2020-05-03 22:58:05 +00:00
Sergey Biryukov
61a2f62ffd Comments: Use comment instead of an empty string for the comment_type DB field value in comments table.
This is the first step to bring support for custom comment types into WordPress.

Add a scheduled upgrade routine to update the type value for existing comments, in batches of 100 at a time.

Props imath, aaroncampbell, jeremyfelt, dshanske.
Fixes #49236.
Built from https://develop.svn.wordpress.org/trunk@47597


git-svn-id: http://core.svn.wordpress.org/trunk@47372 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2020-04-17 19:35:06 +00:00
K. Adam White
51619c00a4 REST API: Fix revisions controller get_item permission check.
r45812 incorrectly introduced a delete_post permissions check into the get_item method, breaking some plugins which requested revisions when generating previews.

Props sorenbronsted, yohannp, TimothyBlynJacobs.
Fixes #49645.

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


git-svn-id: http://core.svn.wordpress.org/trunk@47322 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2020-04-03 19:40:08 +00:00
K. Adam White
58d5aad2a3 REST API: Fix _fields filtering of registered rest fields.
Use rest_is_field_included when determining which additional fields to include to permit filtering by nested field properties.

Props Dudo, kadamwhite, TimothyBlynJacobs.
Fixes #49648.

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


git-svn-id: http://core.svn.wordpress.org/trunk@47286 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2020-03-26 17:52:16 +00:00
Sergey Biryukov
d6178e1dcf REST API: Fix typo in disable-custom-gradients theme feature description.
Props Ipstenu, tobifjellner, pixelverbieger.
Reviewed by ocean90, johnbillion, SergeyBiryukov.
Fixes #49585.
Built from https://develop.svn.wordpress.org/trunk@47432


git-svn-id: http://core.svn.wordpress.org/trunk@47219 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2020-03-06 00:17:05 +00:00
John Blackbourn
056dad9c2c Docs: Use more specific types in parameter descriptions in place of mixed.
See #48303.
Built from https://develop.svn.wordpress.org/trunk@47397


git-svn-id: http://core.svn.wordpress.org/trunk@47184 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2020-03-01 10:38:07 +00:00
Sergey Biryukov
cbe5f9963a Docs: Improve documentation for WP_REST_Attachments_Controller.
This adds a missing DocBlock for `::register_routes()` and parameter descriptions for `::post_process_item()`.

Includes minor documenation fixes in other REST API classes for consistency.

Props dkarfa, mukesh27, SergeyBiryukov.
Fixes #48841.
Built from https://develop.svn.wordpress.org/trunk@47391


git-svn-id: http://core.svn.wordpress.org/trunk@47178 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2020-02-28 12:31:08 +00:00
Sergey Biryukov
3a333ef030 Coding Standards: Use strict comparison for normalize_whitespace() checks when comparing revisions or autosaves.
Props dkarfa, itowhid06, TimothyBlynJacobs.
Fixes #47965.
Built from https://develop.svn.wordpress.org/trunk@47372


git-svn-id: http://core.svn.wordpress.org/trunk@47159 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2020-02-25 19:35:09 +00:00
K. Adam White
a5f16272dd REST API: Permit access to the themes controller if user can edit any post type.
Check a more exhaustive list of post type editing caps beyond "edit_post" to ensure custom user roles with access to to specific post types may still use block editor functionality depending on theme features.

Props miyauchi, TimothyBlynJacobs.
Fixes #46723.

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


git-svn-id: http://core.svn.wordpress.org/trunk@47148 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2020-02-25 15:20:08 +00:00
K. Adam White
8faf366ab9 REST API: Apply all relevant block rendering filters when rendering block previews.
Several filters were introduced to the render_block method since the initial implementation of the block-renderer/ endpoints, causing the output of those endpoints to diverge from the rendered content of blocks on the frontend.

Props kadamwhite, TimothyBlynJacobs, miinasikk.
Fixes #49387.

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


git-svn-id: http://core.svn.wordpress.org/trunk@47147 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2020-02-25 15:05:06 +00:00
TimothyBlynJacobs
5031baa32b REST API: Don't assume all item schemas have properties.
All schema types, not just objects, are permitted as the base type of a resource. A future patch could add validation support for those types, but this fix only prevents a PHP warning from being issued.

Props dhavalkasvala, johnwatkins0, birgire.
Fixes #48785.

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


git-svn-id: http://core.svn.wordpress.org/trunk@47122 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2020-02-20 16:58:06 +00:00
Sergey Biryukov
61986acde9 Users: Limit the scope of admin files required in WP_REST_Users_Controller.
This requires only `wp-admin/includes/user.php` for `get_editable_roles()`, instead of `wp-admin/includes/admin.php`.

Follow-up to [43589].

Props johnwatkins0.
Fixes #49450.
Built from https://develop.svn.wordpress.org/trunk@47299


git-svn-id: http://core.svn.wordpress.org/trunk@47099 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2020-02-17 05:33:06 +00:00
Sergey Biryukov
8f877dc875 Docs: Improve inline comments for require_once calls in WP_REST_Users_Controller per the documentation standards.
Follow-up to [47295].

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


git-svn-id: http://core.svn.wordpress.org/trunk@47098 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2020-02-17 03:56:06 +00:00
Sergey Biryukov
97380ec1ce Docs: Fix typo in a comment in WP_REST_Attachments_Controller::create_item().
See #48303.
Built from https://develop.svn.wordpress.org/trunk@47297


git-svn-id: http://core.svn.wordpress.org/trunk@47097 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2020-02-17 03:30:04 +00:00
Sergey Biryukov
1d5d5b3e87 REST API: Restore wp-admin/includes/image.php requirement in WP_REST_Attachments_Controller::create_item().
Although the file is already included via the `::insert_attachment()` method, this addresses an inconsistency and corrects a misleading comment.

It also reduces the possibility of a future error in case `::insert_attachment()` is no longer called earlier in `::create_item()` at some point.

Follow-up to [43850] and [44206].

Props luisrivera.
Fixes #49449.
Built from https://develop.svn.wordpress.org/trunk@47296


git-svn-id: http://core.svn.wordpress.org/trunk@47096 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2020-02-17 03:24:07 +00:00
Sergey Biryukov
445e2859ab Docs: Improve inline comments for require_once() calls in WP_REST_Attachments_Controller.
See #49449, #48303.
Built from https://develop.svn.wordpress.org/trunk@47295


git-svn-id: http://core.svn.wordpress.org/trunk@47095 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2020-02-17 03:13:05 +00:00
K. Adam White
c85c8f5235 REST API: Introduce rest_{$this->post_type}_item_schema filter to enable manipulation of schema values.
register_rest_field can be used to add properties to a schema, but no mechanism existed to alter existing properties like "content".
Running the schema through this filter lets plugins append additional sub-properties to existing schema definitions.

Props luisherranz, TimothyBlynJacobs, swissspidy, westonruter, kadamwhite.
Fixes #47779.


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


git-svn-id: http://core.svn.wordpress.org/trunk@47065 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2020-02-11 16:28:06 +00:00
K. Adam White
12709269c1 REST API: Allow meta to be set when creating a new media record via REST.
Props TimothyBlynJacobs, apermo.
Fixes #44567.

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


git-svn-id: http://core.svn.wordpress.org/trunk@47061 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2020-02-11 03:39:06 +00:00
K. Adam White
25d8f7240e REST API: List all core theme feature support details in /themes endpoint response.
Fully list which first-party core theme features are supported in the /themes endpoint response. This brings the REST API themes controller's response more in line with the output of get_theme_support().

Props adamboro, apieschel, koke, spacedmonkey, TimothyBlynJacobs.
See #49037.

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


git-svn-id: http://core.svn.wordpress.org/trunk@47058 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2020-02-11 02:00:07 +00:00
Sergey Biryukov
a6949956d1 Administration: Capitalize Trash consistently in various messages and comments.
When used as a noun referring to the "virtual" place, `Trash` should be capitalized.

Props garrett-eclipse, aandrewdixon, Presskopp.
Fixes #45317.
Built from https://develop.svn.wordpress.org/trunk@47233


git-svn-id: http://core.svn.wordpress.org/trunk@47033 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2020-02-10 04:12:07 +00:00
Sergey Biryukov
e79f7f71aa REST API: Merge "not allowed to create new terms" permission error message with an existing string.
Follow-up to [39309], [39313].

See #38857.
Built from https://develop.svn.wordpress.org/trunk@47166


git-svn-id: http://core.svn.wordpress.org/trunk@46966 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2020-02-02 05:41:03 +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
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
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
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
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
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
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
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
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
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
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
K. Adam White
7eed5eff61 REST API: Always return post types list in taxonomies endpoint response as an array.
Prevents a non-sequential post type array such as [ 0 => 'post', 2 => 'page' ] from being improperly converted to an object in the taxonomy endpoint's response JSON.

Props TimothyBlynJacobs, birgire, spectacula.
Fixes #42209.

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


git-svn-id: http://core.svn.wordpress.org/trunk@45624 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2019-08-15 22:12:55 +00:00
K. Adam White
00cb4c7dbd REST API: Prevent deletion of post revisions.
Allowing the client to delete revisions breaks the "audit trail" functionality. This is not allowed in WordPress and shouldn't be allowed through the API.
While not recommended, a plugin may opt-in to the previous behavior by setting a custom 'delete_post' capability for the revisions post type.

Props dlh, danielbachhuber, TimothyBlynJacobs, azaozz, kadamwhite.
Fixes #43709.


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


git-svn-id: http://core.svn.wordpress.org/trunk@45623 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2019-08-15 22:01:55 +00:00
K. Adam White
5dbb64d0dd REST API: Cache results of get_item_schema on controller instances for performance.
Caches the output of get_item_schema() to avoid redundant recomputation of translatable strings and other computed values. This method is called many times per item in each REST request, and the results of the method should not vary between calls.
Additional schema fields are not cached.

Props kadamwhite, joehoyle, TimothyBlynJacobs.
Fixes #47871.

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


git-svn-id: http://core.svn.wordpress.org/trunk@45622 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2019-08-15 21:09:55 +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
Sergey Biryukov
c26f1c5d90 Taxonomy: Fix deprecated calls to get_terms().
The taxonomy should be passed as part of `$args`, rather than as its own argument.

Props sgastard, mukesh27, SergeyBiryukov.
Fixes #47819.
Built from https://develop.svn.wordpress.org/trunk@45723


git-svn-id: http://core.svn.wordpress.org/trunk@45534 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2019-08-03 03:35:56 +00:00
K. Adam White
5f9ba92af4 REST API: Skip processing fields which are not present in the selected context.
In `WP_REST_Controller::get_fields_for_response()`, exclude fields which are not registered to appear in the request's context.

In conjunction with r45705 this prevents the unnecessary computation of the sample permalink when making a request that is not context=edit.

Props dlh.
Fixes #45605.

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


git-svn-id: http://core.svn.wordpress.org/trunk@45517 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2019-07-31 20:21:56 +00:00
K. Adam White
d296736b75 REST API: Generate sample permalink only when a dependent field is requested.
The sample permalink will now only be generated if the derivative `permalink_template` or `generated_slug` fields are to be included in the response, preventing an unnecessary database request for each post (via `wp_unique_post_slug()`) when those fields are not requested.

Props dlh.
See #45605.

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


git-svn-id: http://core.svn.wordpress.org/trunk@45516 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2019-07-31 20:00:57 +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