钩子文档

rest_prepare_block_type

💡 云策文档标注

概述

rest_prepare_block_type 是一个 WordPress REST API 过滤器,用于在返回块类型数据前进行修改。它允许开发者自定义从 REST API 获取的块类型响应。

关键要点

  • 过滤器名称:rest_prepare_block_type
  • 作用:修改 REST API 返回的块类型数据
  • 参数:$response(WP_REST_Response 对象)、$block_type(WP_Block_Type 对象)、$request(WP_REST_Request 对象)
  • 引入版本:WordPress 5.5.0
  • 相关函数:WP_REST_Block_Types_Controller::prepare_item_for_response()

📄 原文内容

Filters a block type returned from the REST API.

Description

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

Parameters

$responseWP_REST_Response
The response object.
$block_typeWP_Block_Type
The original block type object.
$requestWP_REST_Request
Request used to generate the response.

Source

return apply_filters( 'rest_prepare_block_type', $response, $block_type, $request );

Changelog

Version Description
5.5.0 Introduced.