返回介绍

wp_print_scripts()

发布于 2017-09-11 12:36:58 字数 2357 浏览 1096 评论 0 收藏 0

wp_print_scripts( string|bool|array $handles = false )

Prints scripts in document head that are in the $handles queue.


description

Called by admin-header.php and ‘wp_head’ hook. Since it is called by wp_head on every page load, the function does not instantiate the WP_Scripts object unless script names are explicitly passed. Makes use of already-instantiated $wp_scripts global if present. Use provided ‘wp_print_scripts’ hook to register/enqueue new scripts.


参数

$handles

(string|bool|array) (Optional) Scripts to be printed. Default 'false'.

Default value: false


返回值

(array) On success, a processed array of WP_Dependencies items; otherwise, an empty array.


源代码

File: wp-includes/functions.wp-scripts.php

function wp_print_scripts( $handles = false ) {
	/**
	 * 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__ );

	global $wp_scripts;
	if ( ! ( $wp_scripts instanceof WP_Scripts ) ) {
		if ( ! $handles ) {
			return array(); // No need to instantiate if nothing is there.
		}
	}

	return wp_scripts()->do_items( $handles );
}

更新日志

Versiondescription
2.1.0Introduced.

相关函数

Uses

  • wp-includes/functions.wp-scripts.php: wp_scripts()
  • wp-includes/functions.wp-scripts.php: wp_print_scripts
  • wp-includes/plugin.php: do_action()

Used By

  • wp-admin/includes/ajax-actions.php: wp_ajax_parse_embed()
  • wp-admin/includes/ajax-actions.php: wp_ajax_parse_media_shortcode()
  • wp-includes/class-wp-customize-manager.php: WP_Customize_Manager::wp_die()

User Contributed Notes

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
    我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
    原文