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
This commit is contained in:
John Blackbourn 2024-02-16 21:35:12 +00:00
parent a3e9476a21
commit d98b1b3db4
4 changed files with 51 additions and 24 deletions

View File

@ -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();

View File

@ -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 );

View File

@ -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 );

View File

@ -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.