Advertisements

wp_print_scripts

Definition:
function wp_print_scripts( $handles = false ) {}

Prints script tags in document head.
Called by admin-header.php and by 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. Does make use of already instantiated $wp_scripts if present. Use provided wp_print_scripts hook to register/enqueue new scripts.

Parameters

  • $handles

Defined actions

  • wp_print_scripts
    do_action( 'wp_print_scripts' );

Source code

function wp_print_scripts( $handles = false ) {

	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>init</code>' ), '3.3' );



		if ( !$handles )

			return array(); // No need to instantiate if nothing is there.

		else

			$wp_scripts = new WP_Scripts();

	}



	return $wp_scripts->do_items( $handles );

}

4001

Advertisements

No comments yet... Be the first to leave a reply!

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: