You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit e29e51d
Browse filesBrowse the repository at this point in the historyBrowse files
Abilities API: Replace the author_slug filter of core/content-query with an author object.
The `core/content-query` ability filtered posts by author through a `where.author_slug` string, while each post returns its author as an `author` object with `id`, `name`, and `slug`. The REST API posts collection filters by author ID, which the ability did not take.
Replace the filter with a `where.author` object that takes the `id` or the `slug` the `author` field returns, so a result's author can be given back as a filter.
Developed in #14673.
Follow-up to [64388].
Props jorgefilipecosta, gziolo.
See #66268.
git-svn-id: https://develop.svn.wordpress.org/trunk@64680 602fd350-edb4-49c9-b593-d223f7449a82
* Returns a post type exposed through the Abilities API.
794
808
*
@@ -1063,15 +1077,15 @@ private function get_post_properties(): array {
1063
1077
'properties' => array(
1064
1078
'id' => array(
1065
1079
'type' => 'integer',
1066
-
'description' => __( 'The user ID of the author.' ),
1080
+
'description' => __( 'The user ID of the author, as the `author.id` filter takes it.' ),
1067
1081
),
1068
1082
'name' => array(
1069
1083
'type' => array( 'string', 'null' ),
1070
1084
'description' => __( "The author's display name, as the REST API users endpoint returns it in `name`. Null when the author no longer exists." ),
1071
1085
),
1072
1086
'slug' => array(
1073
1087
'type' => array( 'string', 'null' ),
1074
-
'description' => __( "The author's user slug (nicename), as the REST API users endpoint returns it in `slug`, and as the `author_slug` filter takes it. Null when the author no longer exists." ),
1088
+
'description' => __( "The author's user slug (nicename), as the REST API users endpoint returns it in `slug`, and as the `author.slug` filter takes it. Null when the author no longer exists." ),
1075
1089
),
1076
1090
),
1077
1091
'description' => __( 'The post author. Present when the post type supports authors.' ),
@@ -1137,7 +1151,7 @@ private function get_fields_input_schema(): array {
1137
1151
* The input has three members: `where` selects the posts, `fields` selects the fields
1138
1152
* returned for each post, and `pagination` selects the page of results. `where` holds
1139
1153
* the post type to query in `type`, and any of the filters `ids`, `slugs`, `status`,
1140
-
* `author_slug`, and `parent`, which all combine. Every object sets
1154
+
* `author`, and `parent`, which all combine. Every object sets
1141
1155
* `additionalProperties: false`, so an unknown key, such as a misspelled filter, fails
'description' => __( 'Limit the query to these post IDs. The order of the IDs does not affect the order of the results. If `pagination.per_page` is omitted, every matching post is returned on the first page.' ),
'description' => __( 'Limit the query to posts with these slugs. Each slug is sanitized as a post slug is, so `Hello-World` matches `hello-world`. A slug can match several posts, such as pages under different parents, and every match is returned. The order of the slugs does not affect the order of the results. If `pagination.per_page` is omitted, every matching post is returned on the first page, up to the `per_page` maximum.' ),
'description' => __( 'Filter readable posts by one or more post statuses. Defaults to publish, or, when `ids` or `slugs` is given, to every status the current user may query. Statuses that are not publicly viewable, other than private, require edit access.' ),
1197
1211
),
1198
-
'author_slug' => array(
1199
-
'type' => 'string',
1200
-
'minLength' => 1,
1201
-
'description' => __( "Filter by the author's user slug (nicename), as the REST API users endpoint returns it in `slug`. Only supported for post types that support authors." ),
1212
+
'author' => array(
1213
+
'type' => 'object',
1214
+
'additionalProperties' => false,
1215
+
'minProperties' => 1,
1216
+
'properties' => array(
1217
+
'id' => array(
1218
+
'type' => 'integer',
1219
+
'minimum' => 1,
1220
+
'description' => __( 'The user ID of the author, as `author.id` is returned.' ),
1221
+
),
1222
+
'slug' => array(
1223
+
'type' => 'string',
1224
+
'minLength' => 1,
1225
+
'description' => __( "The author's user slug (nicename), as `author.slug` is returned and as the REST API users endpoint returns it in `slug`." ),
1226
+
),
1227
+
),
1228
+
'description' => __( 'Filter by the post author, given as the `id` or the `slug` the `author` field of a post returns. An `id` matches the author ID stored on the post, even when that user no longer exists. A `slug` that names no user, or an `id` and a `slug` that name different users, match no post. Only supported for post types that support authors.' ),
1202
1229
),
1203
-
'parent'=> array(
1230
+
'parent' => array(
1204
1231
'type' => 'integer',
1205
1232
'minimum' => 0,
1206
1233
'description' => __( 'Filter by parent post ID. Only supported for hierarchical post types. Use 0 for top-level posts.' ),
1207
1234
),
1208
1235
),
1209
-
'description' => __( 'Selects the posts to return: the readable posts of a `type`, filtered by any of `ids`, `slugs`, `status`, `author_slug`, and `parent`. A post must match every given filter.' ),
1236
+
'description' => __( 'Selects the posts to return: the readable posts of a `type`, filtered by any of `ids`, `slugs`, `status`, `author`, and `parent`. A post must match every given filter.' ),
0 commit comments