rest_prepare_block_type хук-фильтрWP 5.5.0

Filters a block type returned from the REST API.

Allows modification of the block type data right before it is returned.

Использование

add_filter( 'rest_prepare_block_type', 'wp_kama_rest_prepare_block_type_filter', 10, 3 );

/**
 * Function for `rest_prepare_block_type` filter-hook.
 * 
 * @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.
 *
 * @return WP_REST_Response
 */
function wp_kama_rest_prepare_block_type_filter( $response, $block_type, $request ){

	// filter...
	return $response;
}
$response(WP_REST_Response)
The response object.
$block_type(WP_Block_Type)
The original block type object.
$request(WP_REST_Request)
Request used to generate the response.

Список изменений

С версии 5.5.0 Введена.

Где вызывается хук

WP_REST_Block_Types_Controller::prepare_item_for_response()
rest_prepare_block_type
wp-includes/rest-api/endpoints/class-wp-rest-block-types-controller.php 345
return apply_filters( 'rest_prepare_block_type', $response, $block_type, $request );

Где используется хук в WordPress

Использование не найдено.