wp_print_scripts [ WordPress Functions ]
| See: |
|
| Defined at: |
|
| Codex |
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.
Source
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>login_enqueue_scripts</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 );
}Examples [ wp-snippets.com ]
Top Google Search Results
- Plugin API/Action Reference/wp print scripts « WordPress Codex
Note. wp_print_scripts should not be used to enqueue styles or scripts on the front page. Use wp_enqueue_scripts instead.
codex.wordpress.org - wp_print_scripts places jquery function above jquery src - WordPress
Hi, I'm trying to add some jQuery script (a simple alert at this point) to my header, but when I use wp_print_scripts it places it above the code that links the jQuery ...
wordpress.org - wp_enqueue_script in action hook wp_print_scripts - Stack Overflow
Yeah, I been there lots of times. The short answer is all those guys that print script requests are all wrong or as some folks suggest it is faster not to ...
stackoverflow.com - wp_enqueue_scripts, wp_register_scripts, wp_print_scripts: i'm ...
Dec 17, 2011 ... Can someone explain to me in short what's the exact difference between wp_enqueue_scripts , wp_register_scripts and wp_print_scripts ?
wordpress.stackexchange.com
