From d98b1b3db4f7ea80b757113e833bac55b8a1e6b8 Mon Sep 17 00:00:00 2001 From: John Blackbourn Date: Fri, 16 Feb 2024 21:35:12 +0000 Subject: [PATCH] REST API: Clarify documentation for methods and filters relating to REST API search endpoints. See #59651 Built from https://develop.svn.wordpress.org/trunk@57643 git-svn-id: http://core.svn.wordpress.org/trunk@57144 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- ...ass-wp-rest-post-format-search-handler.php | 24 +++++++++++----- .../class-wp-rest-post-search-handler.php | 28 +++++++++++++------ .../class-wp-rest-term-search-handler.php | 21 +++++++++----- wp-includes/version.php | 2 +- 4 files changed, 51 insertions(+), 24 deletions(-) diff --git a/wp-includes/rest-api/search/class-wp-rest-post-format-search-handler.php b/wp-includes/rest-api/search/class-wp-rest-post-format-search-handler.php index b2192816c7..8d815b1491 100644 --- a/wp-includes/rest-api/search/class-wp-rest-post-format-search-handler.php +++ b/wp-includes/rest-api/search/class-wp-rest-post-format-search-handler.php @@ -26,14 +26,17 @@ class WP_REST_Post_Format_Search_Handler extends WP_REST_Search_Handler { } /** - * Searches the object type content for a given search request. + * Searches the post formats for a given search request. * * @since 5.6.0 * * @param WP_REST_Request $request Full REST request. - * @return array Associative array containing an `WP_REST_Search_Handler::RESULT_IDS` containing - * an array of found IDs and `WP_REST_Search_Handler::RESULT_TOTAL` containing the - * total count for the matching search results. + * @return array { + * Associative array containing found IDs and total count for the matching search results. + * + * @type string[] $ids Array containing slugs for the matching post formats. + * @type int $total Total count for the matching search results. + * } */ public function search_items( WP_REST_Request $request ) { $format_strings = get_post_format_strings(); @@ -46,7 +49,7 @@ class WP_REST_Post_Format_Search_Handler extends WP_REST_Search_Handler { } /** - * Filters the query arguments for a REST API search request. + * Filters the query arguments for a REST API post format search request. * * Enables adding extra arguments or setting defaults for a post format search request. * @@ -84,13 +87,20 @@ class WP_REST_Post_Format_Search_Handler extends WP_REST_Search_Handler { } /** - * Prepares the search result for a given ID. + * Prepares the search result for a given post format. * * @since 5.6.0 * * @param string $id Item ID, the post format slug. * @param array $fields Fields to include for the item. - * @return array Associative array containing all fields for the item. + * @return array { + * Associative array containing fields for the post format based on the `$fields` parameter. + * + * @type string $id Optional. Post format slug. + * @type string $title Optional. Post format name. + * @type string $url Optional. Post format permalink URL. + * @type string $type Optional. String 'post-format'. + *} */ public function prepare_item( $id, array $fields ) { $data = array(); diff --git a/wp-includes/rest-api/search/class-wp-rest-post-search-handler.php b/wp-includes/rest-api/search/class-wp-rest-post-search-handler.php index fb85fce2e2..1d47723b41 100644 --- a/wp-includes/rest-api/search/class-wp-rest-post-search-handler.php +++ b/wp-includes/rest-api/search/class-wp-rest-post-search-handler.php @@ -40,14 +40,17 @@ class WP_REST_Post_Search_Handler extends WP_REST_Search_Handler { } /** - * Searches the object type content for a given search request. + * Searches posts for a given search request. * * @since 5.0.0 * * @param WP_REST_Request $request Full REST request. - * @return array Associative array containing an `WP_REST_Search_Handler::RESULT_IDS` containing - * an array of found IDs and `WP_REST_Search_Handler::RESULT_TOTAL` containing the - * total count for the matching search results. + * @return array { + * Associative array containing found IDs and total count for the matching search results. + * + * @type int[] $ids Array containing the matching post IDs. + * @type int $total Total count for the matching search results. + * } */ public function search_items( WP_REST_Request $request ) { @@ -78,7 +81,7 @@ class WP_REST_Post_Search_Handler extends WP_REST_Search_Handler { } /** - * Filters the query arguments for a REST API search request. + * Filters the query arguments for a REST API post search request. * * Enables adding extra arguments or setting defaults for a post search request. * @@ -102,13 +105,20 @@ class WP_REST_Post_Search_Handler extends WP_REST_Search_Handler { } /** - * Prepares the search result for a given ID. + * Prepares the search result for a given post ID. * * @since 5.0.0 * - * @param int $id Item ID. - * @param array $fields Fields to include for the item. - * @return array Associative array containing all fields for the item. + * @param int $id Post ID. + * @param array $fields Fields to include for the post. + * @return array { + * Associative array containing fields for the post based on the `$fields` parameter. + * + * @type int $id Optional. Post ID. + * @type string $title Optional. Post title. + * @type string $url Optional. Post permalink URL. + * @type string $type Optional. Post type. + * } */ public function prepare_item( $id, array $fields ) { $post = get_post( $id ); diff --git a/wp-includes/rest-api/search/class-wp-rest-term-search-handler.php b/wp-includes/rest-api/search/class-wp-rest-term-search-handler.php index eed35e7470..6527697208 100644 --- a/wp-includes/rest-api/search/class-wp-rest-term-search-handler.php +++ b/wp-includes/rest-api/search/class-wp-rest-term-search-handler.php @@ -36,7 +36,7 @@ class WP_REST_Term_Search_Handler extends WP_REST_Search_Handler { } /** - * Searches the object type content for a given search request. + * Searches terms for a given search request. * * @since 5.6.0 * @@ -44,7 +44,7 @@ class WP_REST_Term_Search_Handler extends WP_REST_Search_Handler { * @return array { * Associative array containing found IDs and total count for the matching search results. * - * @type int[] $ids Found IDs. + * @type int[] $ids Found term IDs. * @type string|int|WP_Error $total Numeric string containing the number of terms in that * taxonomy, 0 if there are no results, or WP_Error if * the requested taxonomy does not exist. @@ -79,7 +79,7 @@ class WP_REST_Term_Search_Handler extends WP_REST_Search_Handler { } /** - * Filters the query arguments for a REST API search request. + * Filters the query arguments for a REST API term search request. * * Enables adding extra arguments or setting defaults for a term search request. * @@ -110,13 +110,20 @@ class WP_REST_Term_Search_Handler extends WP_REST_Search_Handler { } /** - * Prepares the search result for a given ID. + * Prepares the search result for a given term ID. * * @since 5.6.0 * - * @param int $id Item ID. - * @param array $fields Fields to include for the item. - * @return array Associative array containing all fields for the item. + * @param int $id Term ID. + * @param array $fields Fields to include for the term. + * @return array { + * Associative array containing fields for the term based on the `$fields` parameter. + * + * @type int $id Optional. Term ID. + * @type string $title Optional. Term name. + * @type string $url Optional. Term permalink URL. + * @type string $type Optional. Term taxonomy name. + * } */ public function prepare_item( $id, array $fields ) { $term = get_term( $id ); diff --git a/wp-includes/version.php b/wp-includes/version.php index e5ca2c5ae2..6c4c19ed61 100644 --- a/wp-includes/version.php +++ b/wp-includes/version.php @@ -16,7 +16,7 @@ * * @global string $wp_version */ -$wp_version = '6.5-beta1-57642'; +$wp_version = '6.5-beta1-57643'; /** * Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.