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 $wp_scripts global if present. Use provided hook to register/enqueue new 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

  1. if ( !function_exists( 'wp_print_scripts' ) ) { 
  2. require_once ABSPATH . WPINC . '/functions.wp-scripts.php'; 
  3.  
  4. // Optional. Scripts to be printed. Default 'false'. 
  5. $handles = false; 
  6.  
  7. // NOTICE! Understand what this does before running. 
  8. $result = wp_print_scripts($handles); 
  9.  

Defined (1)

The function is defined in the following location(s).

/wp-includes/functions.wp-scripts.php  
  1. function wp_print_scripts( $handles = false ) { 
  2. /** 
  3. * Fires before scripts in the $handles queue are printed. 
  4. * @since 2.1.0 
  5. */ 
  6. if ( '' === $handles ) { // for wp_head 
  7. $handles = false; 
  8.  
  9.  
  10. global $wp_scripts; 
  11. if ( ! ( $wp_scripts instanceof WP_Scripts ) ) { 
  12. if ( ! $handles ) { 
  13. return array(); // No need to instantiate if nothing is there. 
  14.  
  15. returnwp_scripts)->do_items( $handles );