From 4fbba169600b5f8c0fbc86b35b3dbeccd945d830 Mon Sep 17 00:00:00 2001 From: Dominik Schilling Date: Wed, 25 Mar 2015 17:55:27 +0000 Subject: [PATCH] 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 --- wp-includes/functions.wp-scripts.php | 17 ++++++++++------- wp-includes/version.php | 2 +- 2 files changed, 11 insertions(+), 8 deletions(-) diff --git a/wp-includes/functions.wp-scripts.php b/wp-includes/functions.wp-scripts.php index 9fd5d87d80..aacf9d15af 100644 --- a/wp-includes/functions.wp-scripts.php +++ b/wp-includes/functions.wp-scripts.php @@ -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 ); diff --git a/wp-includes/version.php b/wp-includes/version.php index 5c0b884c1f..a06543787c 100644 --- a/wp-includes/version.php +++ b/wp-includes/version.php @@ -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.