mirror of
git://develop.git.wordpress.org/
synced 2025-04-05 12:42:35 +02:00
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. git-svn-id: https://develop.svn.wordpress.org/trunk@31887 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
parent
de328f1a88
commit
135be2826d
@ -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 );
|
||||
|
Loading…
x
Reference in New Issue
Block a user