wp_enqueue_script

Enqueue a script.

Description

wp_enqueue_script( $handle, (constant) $src = false, (array) $deps = array(), (constant) $ver = false, (bool) $in_footer = false ); 

Registers the script if src provided (does NOT overwrite) and enqueues.

Parameters (5)

0. $handle
The handle.
1. $src — Optional. (constant) => false
The src.
2. $deps — Optional. (array) => array()
The deps.
3. $ver — Optional. (constant) => false
The ver.
4. $in_footer — Optional. (bool) => false
The in footer.

Usage

  1. if ( !function_exists( 'wp_enqueue_script' ) ) { 
  2. require_once ABSPATH . PLUGINDIR . 'buddypress/bp-forums/bbpress/bb-includes/backpress/functions.wp-scripts.php'; 
  3.  
  4. // The handle. 
  5. $handle = null; 
  6.  
  7. // The src. 
  8. $src = false; 
  9.  
  10. // The deps. 
  11. $deps = array(); 
  12.  
  13. // The ver. 
  14. $ver = false; 
  15.  
  16. // The in footer. 
  17. $in_footer = false; 
  18.  
  19. // NOTICE! Understand what this does before running. 
  20. $result = wp_enqueue_script($handle, $src, $deps, $ver, $in_footer); 
  21.  

Defined (1)

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

/bp-forums/bbpress/bb-includes/backpress/functions.wp-scripts.php  
  1. function wp_enqueue_script( $handle, $src = false, $deps = array(), $ver = false, $in_footer = false ) { 
  2. global $wp_scripts; 
  3. if ( !is_a($wp_scripts, 'WP_Scripts') ) 
  4. $wp_scripts = new WP_Scripts(); 
  5.  
  6. if ( $src ) { 
  7. $_handle = explode('?', $handle); 
  8. $wp_scripts->add( $_handle[0], $src, $deps, $ver ); 
  9. if ( $in_footer ) 
  10. $wp_scripts->add_data( $_handle[0], 'group', 1 ); 
  11. $wp_scripts->enqueue( $handle );