diff -r 34716fd837a4 -r be944660c56a wp/wp-includes/rest-api/endpoints/class-wp-rest-terms-controller.php --- a/wp/wp-includes/rest-api/endpoints/class-wp-rest-terms-controller.php Tue Dec 15 15:52:01 2020 +0100 +++ b/wp/wp-includes/rest-api/endpoints/class-wp-rest-terms-controller.php Wed Sep 21 18:19:35 2022 +0200 @@ -65,7 +65,7 @@ } /** - * Registers the routes for the objects of the controller. + * Registers the routes for terms. * * @since 4.7.0 * @@ -140,7 +140,7 @@ * @since 4.7.0 * * @param WP_REST_Request $request Full details about the request. - * @return bool|WP_Error True if the request has read access, otherwise false or WP_Error object. + * @return true|WP_Error True if the request has read access, otherwise false or WP_Error object. */ public function get_items_permissions_check( $request ) { $tax_obj = get_taxonomy( $this->taxonomy ); @@ -233,10 +233,15 @@ } /** - * Filters the query arguments before passing them to get_terms(). + * Filters get_terms() arguments when querying terms via the REST API. * * The dynamic portion of the hook name, `$this->taxonomy`, refers to the taxonomy slug. * + * Possible hook names include: + * + * - `rest_category_query` + * - `rest_post_tag_query` + * * Enables adding extra arguments or setting defaults for a terms * collection request. * @@ -244,9 +249,8 @@ * * @link https://developer.wordpress.org/reference/functions/get_terms/ * - * @param array $prepared_args Array of arguments to be - * passed to get_terms(). - * @param WP_REST_Request $request The current request. + * @param array $prepared_args Array of arguments for get_terms(). + * @param WP_REST_Request $request The REST API request. */ $prepared_args = apply_filters( "rest_{$this->taxonomy}_query", $prepared_args, $request ); @@ -263,7 +267,7 @@ unset( $count_args['number'], $count_args['offset'] ); - $total_terms = wp_count_terms( $this->taxonomy, $count_args ); + $total_terms = wp_count_terms( $count_args ); // wp_count_terms() can return a falsey value when the term has no children. if ( ! $total_terms ) { @@ -347,7 +351,7 @@ * @since 4.7.0 * * @param WP_REST_Request $request Full details about the request. - * @return bool|WP_Error True if the request has read access for the item, otherwise false or WP_Error object. + * @return true|WP_Error True if the request has read access for the item, otherwise false or WP_Error object. */ public function get_item_permissions_check( $request ) { $term = $this->get_term( $request['id'] ); @@ -392,7 +396,7 @@ * @since 4.7.0 * * @param WP_REST_Request $request Full details about the request. - * @return bool|WP_Error True if the request has access to create items, false or WP_Error object otherwise. + * @return true|WP_Error True if the request has access to create items, false or WP_Error object otherwise. */ public function create_item_permissions_check( $request ) { @@ -475,6 +479,11 @@ * * The dynamic portion of the hook name, `$this->taxonomy`, refers to the taxonomy slug. * + * Possible hook names include: + * + * - `rest_insert_category` + * - `rest_insert_post_tag` + * * @since 4.7.0 * * @param WP_Term $term Inserted or updated term object. @@ -505,6 +514,11 @@ * * The dynamic portion of the hook name, `$this->taxonomy`, refers to the taxonomy slug. * + * Possible hook names include: + * + * - `rest_after_insert_category` + * - `rest_after_insert_post_tag` + * * @since 5.0.0 * * @param WP_Term $term Inserted or updated term object. @@ -528,7 +542,7 @@ * @since 4.7.0 * * @param WP_REST_Request $request Full details about the request. - * @return bool|WP_Error True if the request has access to update the item, false or WP_Error object otherwise. + * @return true|WP_Error True if the request has access to update the item, false or WP_Error object otherwise. */ public function update_item_permissions_check( $request ) { $term = $this->get_term( $request['id'] ); @@ -629,7 +643,7 @@ * @since 4.7.0 * * @param WP_REST_Request $request Full details about the request. - * @return bool|WP_Error True if the request has access to delete the item, otherwise false or WP_Error object. + * @return true|WP_Error True if the request has access to delete the item, otherwise false or WP_Error object. */ public function delete_item_permissions_check( $request ) { $term = $this->get_term( $request['id'] ); @@ -702,6 +716,11 @@ * * The dynamic portion of the hook name, `$this->taxonomy`, refers to the taxonomy slug. * + * Possible hook names include: + * + * - `rest_delete_category` + * - `rest_delete_post_tag` + * * @since 4.7.0 * * @param WP_Term $term The deleted term. @@ -761,6 +780,11 @@ * * The dynamic portion of the hook name, `$this->taxonomy`, refers to the taxonomy slug. * + * Possible hook names include: + * + * - `rest_pre_insert_category` + * - `rest_pre_insert_post_tag` + * * @since 4.7.0 * * @param object $prepared_term Term object. @@ -828,10 +852,15 @@ $response->add_links( $this->prepare_links( $item ) ); /** - * Filters a term item returned from the API. + * Filters the term data for a REST API response. * * The dynamic portion of the hook name, `$this->taxonomy`, refers to the taxonomy slug. * + * Possible hook names include: + * + * - `rest_prepare_category` + * - `rest_prepare_post_tag` + * * Allows modification of the term data right before it is returned. * * @since 4.7.0 @@ -965,7 +994,7 @@ 'taxonomy' => array( 'description' => __( 'Type attribution for the term.' ), 'type' => 'string', - 'enum' => array_keys( get_taxonomies() ), + 'enum' => array( $this->taxonomy ), 'context' => array( 'view', 'embed', 'edit' ), 'readonly' => true, ), @@ -1081,7 +1110,7 @@ ); /** - * Filter collection parameters for the terms controller. + * Filters collection parameters for the terms controller. * * The dynamic part of the filter `$this->taxonomy` refers to the taxonomy * slug for the controller.