extra_{$context}_headers
云策文档标注
概述
此文档介绍 WordPress 中的 extra_{$context}_headers 过滤器,用于根据上下文动态过滤文件头信息。开发者可通过此 Hook 添加或修改特定上下文下的额外文件头数据。
关键要点
- extra_{$context}_headers 是一个动态命名的过滤器,$context 参数指定加载额外文件头的上下文。
- 参数 $extra_context_headers 默认为空数组,开发者可在此过滤器中返回自定义的数组来添加额外文件头。
- 此过滤器在 get_file_data() 函数中被调用,用于从文件中检索元数据,自 WordPress 2.9.0 版本引入。
代码示例
$extra_headers = $context ? apply_filters( "extra_{$context}_headers", array() ) : array();
原文内容
Filters extra file headers by context.
Description
The dynamic portion of the hook name, $context, refers to the context where extra headers might be loaded.
Parameters
$extra_context_headersarray-
Empty array by default.
Source
$extra_headers = $context ? apply_filters( "extra_{$context}_headers", array() ) : array();
Changelog
| Version | Description |
|---|---|
| 2.9.0 | Introduced. |