Switch language
wpseek on Twitter

A WordPress-centric search engine for devs and theme authors

wp_print_scripts [ ]

wp_print_scripts ( $handles = false )
  • (array|bool) $handles Optional. Scripts to be printed. Default 'false'.
  • WP_Scripts::do_items()
  • (array) On success, a processed array of WP_Dependencies items; otherwise, an empty array.
Defined at:

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

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.


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;

	global $wp_scripts;
	if ( ! is_a( $wp_scripts, 'WP_Scripts' ) ) {
		if ( ! did_action( 'init' ) )
			_doing_it_wrong( __FUNCTION__, sprintf( __( 'Scripts and styles should not be registered or enqueued until the %1$s, %2$s, or %3$s hooks.' ),
				'<code>wp_enqueue_scripts</code>', '<code>admin_enqueue_scripts</code>', '<code>login_enqueue_scripts</code>' ), '3.3' );

		if ( !$handles )
			return array(); // No need to instantiate if nothing is there.
			$wp_scripts = new WP_Scripts();

	return $wp_scripts->do_items( $handles );

Top Google Search Results

More ...

User Note(s)