print_scripts_array
云策文档标注
概述
print_scripts_array 是一个 WordPress 过滤器,用于过滤待打印的脚本依赖数组。它允许开发者在脚本依赖被输出前修改依赖列表。
关键要点
- 这是一个过滤器 Hook,名称为 print_scripts_array,应用于 WP_Scripts 类中的 $this->to_do 属性。
- 参数 $to_do 是一个数组,包含脚本依赖的句柄(handles),开发者可以通过此过滤器动态调整依赖项。
- 该过滤器自 WordPress 2.3.0 版本引入,主要用于控制脚本加载顺序和依赖管理。
相关函数
- WP_Scripts::all_deps():用于确定脚本依赖关系,位于 wp-includes/class-wp-scripts.php 文件中。
原文内容
Filters the list of script dependencies left to print.
Parameters
$to_dostring[]-
An array of script dependency handles.
Source
$this->to_do = apply_filters( 'print_scripts_array', $this->to_do );
Changelog
| Version | Description |
|---|---|
| 2.3.0 | Introduced. |