wp_loading_optimization_force_header_contexts
云策文档标注
概述
wp_loading_optimization_force_header_contexts 是一个 WordPress 过滤器,用于控制页面头部特定上下文的元素加载优化。它允许开发者自定义哪些上下文被视为头部元素,以优化页面性能。
关键要点
- 这是一个过滤器,用于修改头部强制上下文的映射数组。
- 参数 $default_header_enforced_contexts 是一个数组,键为上下文名称,值为布尔值(通常为 true),表示该上下文是否应被视为头部元素。
- 在 WordPress 6.4.0 版本中引入,与 wp_get_loading_optimization_attributes() 函数相关。
代码示例
$header_enforced_contexts = apply_filters( 'wp_loading_optimization_force_header_contexts', $header_enforced_contexts );
原文内容
Filters the header-specific contexts.
Parameters
$default_header_enforced_contextsarray-
Map of contexts for which elements should be considered in the header of the page, as $context => $enabled pairs. The $enabled should always be true.
Source
$header_enforced_contexts = apply_filters( 'wp_loading_optimization_force_header_contexts', $header_enforced_contexts );
Changelog
| Version | Description |
|---|---|
| 6.4.0 | Introduced. |