WordPress at a glance
function is not described

WP_REST_Block_Types_Controller::get_items() public WP 5.5.0

Retrieves all post block types, depending on user context.

{} It's a method of the class: WP_REST_Block_Types_Controller{}

No Hooks.

Return

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

Usage

$WP_REST_Block_Types_Controller = new WP_REST_Block_Types_Controller();
$WP_REST_Block_Types_Controller->get_items( $request );
$request(WP_REST_Request) (required)
Full details about the request.

Changelog

Since 5.5.0 Introduced.

Code of WP_REST_Block_Types_Controller::get_items() WP 5.5.2

<?php
public function get_items( $request ) {
	$data        = array();
	$block_types = $this->block_registry->get_all_registered();

	// Retrieve the list of registered collection query parameters.
	$registered = $this->get_collection_params();
	$namespace  = '';
	if ( isset( $registered['namespace'] ) && ! empty( $request['namespace'] ) ) {
		$namespace = $request['namespace'];
	}

	foreach ( $block_types as $slug => $obj ) {
		if ( $namespace ) {
			list ( $block_namespace ) = explode( '/', $obj->name );

			if ( $namespace !== $block_namespace ) {
				continue;
			}
		}
		$block_type = $this->prepare_item_for_response( $obj, $request );
		$data[]     = $this->prepare_response_for_collection( $block_type );
	}

	return rest_ensure_response( $data );
}