钩子文档

rest_prepare_font_collection

💡 云策文档标注

概述

rest_prepare_font_collection 是一个 WordPress REST API 钩子,用于过滤字体集合数据在 API 响应中的输出。它允许开发者在数据返回给客户端前进行修改或增强。

关键要点

  • 这是一个过滤器钩子,应用于 REST API 响应中的字体集合数据。
  • 钩子接收三个参数:$response(WP_REST_Response 对象)、$item(WP_Font_Collection 对象)和 $request(WP_REST_Request 对象)。
  • 主要用于 WP_REST_Font_Collections_Controller::prepare_item_for_response() 方法中,以准备单个字体集合的响应输出。
  • 自 WordPress 6.5.0 版本引入。

📄 原文内容

Filters the font collection data for a REST API response.

Parameters

$responseWP_REST_Response
The response object.
$itemWP_Font_Collection
The font collection object.
$requestWP_REST_Request
Request used to generate the response.

Source

return apply_filters( 'rest_prepare_font_collection', $response, $item, $request );

Changelog

Version Description
6.5.0 Introduced.