Filter hook 'rest_prepare_block_type'

in WP Core File wp-includes/rest-api/endpoints/class-wp-rest-block-types-controller.php at line 360

View Source

rest_prepare_block_type

Filter Hook
Description
Filters a block type returned from the REST API. Allows modification of the block type data right before it is returned.

Hook Information

File Location wp-includes/rest-api/endpoints/class-wp-rest-block-types-controller.php View on GitHub
Hook Type Filter
Line Number 360

Hook Parameters

Type Name Description
WP_REST_Response $response The response object.
WP_Block_Type $block_type The original block type object.
WP_REST_Request $request Request used to generate the response.

Usage Examples

Basic Usage
<?php
// Hook into rest_prepare_block_type
add_filter('rest_prepare_block_type', 'my_custom_filter', 10, 3);

function my_custom_filter($response, $block_type, $request) {
    // Your custom filtering logic here
    return $response;
}

Source Code Context

wp-includes/rest-api/endpoints/class-wp-rest-block-types-controller.php:360 - How this hook is used in WordPress core
<?php
 355  		 *
 356  		 * @param WP_REST_Response $response   The response object.
 357  		 * @param WP_Block_Type    $block_type The original block type object.
 358  		 * @param WP_REST_Request  $request    Request used to generate the response.
 359  		 */
 360  		return apply_filters( 'rest_prepare_block_type', $response, $block_type, $request );
 361  	}
 362  
 363  	/**
 364  	 * Prepares links for the request.
 365  	 *

PHP Documentation

<?php
/**
		 * Filters a block type returned from the REST API.
		 *
		 * Allows modification of the block type data right before it is returned.
		 *
		 * @since 5.5.0
		 *
		 * @param WP_REST_Response $response   The response object.
		 * @param WP_Block_Type    $block_type The original block type object.
		 * @param WP_REST_Request  $request    Request used to generate the response.
		 */
Quick Info
  • Hook Type: Filter
  • Parameters: 3
  • File: wp-includes/rest-api/endpoints/class-wp-rest-block-types-controller.php
Related Hooks

Related hooks will be displayed here in future updates.