rest_route_data
云策文档标注
概述
rest_route_data 过滤器用于修改 REST API 路由的公开可见数据,这些数据在索引中暴露,供客户端或开发者使用以了解站点信息和使用方式,起到自文档化作用。
关键要点
- 过滤器名称:rest_route_data
- 用途:过滤 REST API 路由的公开数据,影响索引中的路由信息展示
- 参数:$available(公开的路由数据数组,键为路由)、$routes(内部路由数据关联数组)
- 返回值:通过 apply_filters 返回过滤后的 $available 数据
- 相关函数:WP_REST_Server::get_data_for_routes() 用于获取路由的公开数据
- 引入版本:WordPress 4.4.0
原文内容
Filters the publicly-visible data for REST API routes.
Description
This data is exposed on indexes and can be used by clients or developers to investigate the site and find out how to use it. It acts as a form of self-documentation.
Parameters
$availablearray[]-
Route data to expose in indexes, keyed by route.
$routesarray-
Internal route data as an associative array.
Source
return apply_filters( 'rest_route_data', $available, $routes );
Changelog
| Version | Description |
|---|---|
| 4.4.0 | Introduced. |