wp_print_scripts
函数
wp_print_scripts ( $handles = false )
- 参数
-
-
(string|bool|array)
$handles
Optional. Scripts to be printed. Default ‘false’.- Required: 否
- Default: false
-
(string|bool|array)
- 返回值
-
- (string[]) On success, an array of handles of processed WP_Dependencies items; otherwise, an empty array.
- 相关
-
- WP_Scripts::do_item()
- 定义位置
-
-
wp-includes/functions.wp-scripts.php
, line 87
-
wp-includes/functions.wp-scripts.php
- 引入
- 2.1.0
- 弃用
- –
打印文档头部的$handles队列中的脚本。
由admin-header.php和{@see ‘wp_head’}挂钩调用。由于它在每次加载页面时都会被wp_head调用,因此除非明确传递脚本名称,否则该函数不会实例化WP_Scripts对象。如果存在的话,会使用已经实例化的$wp_scripts全局。使用提供的{@see ‘wp_print_scripts’}钩子来注册/获取新的脚本。
function wp_print_scripts( $handles = false ) { global $wp_scripts; /** * Fires before scripts in the $handles queue are printed. * * @since 2.1.0 */ do_action( 'wp_print_scripts' ); if ( '' === $handles ) { // For 'wp_head'. $handles = false; } _wp_scripts_maybe_doing_it_wrong( __FUNCTION__ ); if ( ! ( $wp_scripts instanceof WP_Scripts ) ) { if ( ! $handles ) { return array(); // No need to instantiate if nothing is there. } } return wp_scripts()->do_items( $handles ); }
声明:本站所有文章,如无特殊说明或标注,均为本站原创发布。任何个人或组织,在未征得本站同意时,禁止复制、盗用、采集、发布本站内容到任何网站、书籍等各类媒体平台。如若本站内容侵犯了原著者的合法权益,可联系我们进行处理。