Created
May 15, 2012 16:13
-
-
Save brandwaffle/2702967 to your computer and use it in GitHub Desktop.
Add an array check to wp_enqueue_script and convert a single $deps passed as a string to an array with one element
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
function wp_enqueue_script( $handle, $src = false, $deps = array(), $ver = false, $in_footer = false ) { | |
global $wp_scripts; | |
if ( !is_a($wp_scripts, 'WP_Scripts') ) | |
$wp_scripts = new WP_Scripts(); | |
if ( $src ) { | |
$_handle = explode('?', $handle); | |
$wp_scripts->add( $_handle[0], $src, $deps, $ver ); | |
if ( $in_footer ) | |
$wp_scripts->add_data( $_handle[0], 'group', 1 ); | |
} | |
$wp_scripts->enqueue( $handle ); | |
} | |
function wp_enqueue_script( $handle, $src = false, $deps = array(), $ver = false, $in_footer = false ) { | |
global $wp_scripts; | |
if ( !is_a($wp_scripts, 'WP_Scripts') ) | |
$wp_scripts = new WP_Scripts(); | |
//if a single param is passed as the dependency, convert to an array so WP_Dependencies won't convert | |
//it to an empty array | |
if( !is_array( $deps ) ) | |
$deps = (array) $deps; | |
if ( $src ) { | |
$_handle = explode('?', $handle); | |
$wp_scripts->add( $_handle[0], $src, $deps, $ver ); | |
if ( $in_footer ) | |
$wp_scripts->add_data( $_handle[0], 'group', 1 ); | |
} | |
$wp_scripts->enqueue( $handle ); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment