WP_REST_Block_Pattern_Categories_Controller::get_items( WP_REST_Request $request ): WP_Error|WP_REST_Response

In this article

Retrieves all block pattern categories.

Parameters

$requestWP_REST_Requestrequired
Full details about the request.

Return

WP_Error|WP_REST_Response Response object on success, or WP_Error object on failure.

Source

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

Changelog

VersionDescription
6.0.0Introduced.

User Contributed Notes

You must log in before being able to contribute a note or feedback.