wp_print_scripts
云策文档标注
概述
wp_print_scripts 是一个 WordPress 动作钩子,在 $handles 队列中的脚本被打印前触发。自 WordPress 3.3 起,不应使用它来入队样式或脚本。
关键要点
- wp_print_scripts 钩子在脚本队列打印前执行,用于在文档头部添加自定义脚本或操作。
- 从 WordPress 3.3 开始,推荐使用 wp_enqueue_scripts 钩子来入队前端脚本和样式,而非 wp_print_scripts。
- 相关函数包括 wp_print_scripts()、print_head_scripts() 和 wp_print_head_scripts(),分别用于打印脚本队列。
注意事项
避免使用 wp_print_scripts 来入队资源,应改用 wp_enqueue_scripts 以确保兼容性和最佳实践。
原文内容
Fires before scripts in the $handles queue are printed.
Source
do_action( 'wp_print_scripts' );
Changelog
| Version | Description |
|---|---|
| 2.1.0 | Introduced. |
Skip to note 2 content
Shorifpatwary
Add inline script to the head section