rest_enabled
云策文档标注
概述
rest_enabled 是一个已弃用的过滤器,用于控制 REST API 的启用状态。自 WordPress 4.7.0 起,建议使用 rest_authentication_errors 过滤器来限制 API 访问。
关键要点
- rest_enabled 过滤器已弃用,不应在新代码中使用。
- 参数 $rest_enabled 为布尔值,默认 true,表示 REST API 是否启用。
- 替代方案:使用 rest_authentication_errors 过滤器来限制对 REST API 的访问。
- 引入版本:4.4.0,弃用版本:4.7.0。
注意事项
由于 REST API 无法完全禁用,开发者应迁移到 rest_authentication_errors 过滤器以实现访问控制。
原文内容
Filters whether the REST API is enabled.
Parameters
$rest_enabledbool-
Whether the REST API is enabled. Default true.
Source
apply_filters_deprecated(
'rest_enabled',
array( true ),
'4.7.0',
'rest_authentication_errors',
sprintf(
/* translators: %s: rest_authentication_errors */
__( 'The REST API can no longer be completely disabled, the %s filter can be used to restrict access to the API, instead.' ),
'rest_authentication_errors'
)
);
Changelog
| Version | Description |
|---|---|
| 4.7.0 | Deprecated. Use the ‘rest_authentication_errors’ filter to restrict access to the REST API. |
| 4.4.0 | Introduced. |