wp_print_scripts
Prints scripts in document head that are in the $handles queue.
Description
(array) wp_print_scripts( (bool) $handles = false );
Called by admin-header.php and 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 $
global if present. Use provided hook to register/enqueue new scripts.wp_scripts
Returns (array)
On success, a processed array of WP_Dependencies items; otherwise, an empty array.
Parameters (1)
- 0. $handles — Optional. (bool) =>
false
- Scripts to be printed. Default false..
Usage
if ( !function_exists( 'wp_print_scripts' ) ) { require_once ABSPATH . WPINC . '/functions.wp-scripts.php'; } // Optional. Scripts to be printed. Default 'false'. $handles = false; // NOTICE! Understand what this does before running. $result = wp_print_scripts($handles);
Defined (1)
The function is defined in the following location(s).
- /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
- */
- 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.
- }
- }
- returnwp_scripts)->do_items( $handles );
- }