Avoid a PHP notice in wp_enqueue_script() if $handle is an array.

Calling `wp_enqueue_script()` with an array as the first argument is a "hidden feature" and should be avoided. Use dependencies instead.

props sorich87 for initial patch.
fixes #31636.
see #14488.
Built from https://develop.svn.wordpress.org/trunk@31887


git-svn-id: http://core.svn.wordpress.org/trunk@31866 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
Dominik Schilling 2015-03-25 17:55:27 +00:00
parent 29907e5f8b
commit 4fbba16960
2 changed files with 11 additions and 8 deletions

View File

@ -209,7 +209,7 @@ function wp_deregister_script( $handle ) {
* @global WP_Scripts $wp_scripts The WP_Scripts object for printing scripts.
*
* @since 2.6.0
*
* @param string $handle Name of the script.
* @param string|bool $src Path to the script from the root directory of WordPress. Example: '/js/myscript.js'.
* @param array $deps An array of registered handles this script depends on. Default empty array.
@ -224,14 +224,17 @@ function wp_enqueue_script( $handle, $src = false, $deps = array(), $ver = false
_wp_scripts_maybe_doing_it_wrong( __FUNCTION__ );
$_handle = explode( '?', $handle );
if ( $src ) {
$wp_scripts->add( $_handle[0], $src, $deps, $ver );
}
if ( $src || $in_footer ) {
$_handle = explode( '?', $handle );
if ( $in_footer ) {
$wp_scripts->add_data( $_handle[0], 'group', 1 );
if ( $src ) {
$wp_scripts->add( $_handle[0], $src, $deps, $ver );
}
if ( $in_footer ) {
$wp_scripts->add_data( $_handle[0], 'group', 1 );
}
}
$wp_scripts->enqueue( $handle );

View File

@ -4,7 +4,7 @@
*
* @global string $wp_version
*/
$wp_version = '4.2-beta2-31886';
$wp_version = '4.2-beta2-31887';
/**
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.