WP_REST_Block_Pattern_Categories_Controller::get_items() WordPress Method
The WP_REST_Block_Pattern_Categories_Controller::get_items() method is used to get a list of block pattern categories. This is useful for displaying a list of categories in a UI.
WP_REST_Block_Pattern_Categories_Controller::get_items( WP_REST_Request $request ) #
Retrieves all block pattern categories.
Parameters
- $request
(WP_REST_Request)(Required)Full details about the request.
Return
(WP_Error|WP_REST_Response) Response object on success, or WP_Error object on failure.
Source
File: wp-includes/rest-api/endpoints/class-wp-rest-block-pattern-categories-controller.php
public function get_items( $request ) { $response = array(); $categories = WP_Block_Pattern_Categories_Registry::get_instance()->get_all_registered(); foreach ( $categories as $category ) { $prepared_category = $this->prepare_item_for_response( $category, $request ); $response[] = $this->prepare_response_for_collection( $prepared_category ); } return rest_ensure_response( $response ); }
Expand full source codeCollapse full source codeView on TracView on GitHub
Changelog
Version | Description |
---|---|
6.0.0 | Introduced. |