WordPress.org

Make WordPress Core

Changeset 31887


Ignore:
Timestamp:
03/25/2015 05:54:50 PM (6 years ago)
Author:
ocean90
Message:

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.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/functions.wp-scripts.php

    r31223 r31887  
    210210 *
    211211 * @since 2.6.0
    212 
     212 *
    213213 * @param string      $handle    Name of the script.
    214214 * @param string|bool $src       Path to the script from the root directory of WordPress. Example: '/js/myscript.js'.
     
    225225    _wp_scripts_maybe_doing_it_wrong( __FUNCTION__ );
    226226
    227     $_handle = explode( '?', $handle );
    228 
    229     if ( $src ) {
    230         $wp_scripts->add( $_handle[0], $src, $deps, $ver );
    231     }
    232 
    233     if ( $in_footer ) {
    234         $wp_scripts->add_data( $_handle[0], 'group', 1 );
     227
     228    if ( $src || $in_footer ) {
     229        $_handle = explode( '?', $handle );
     230
     231        if ( $src ) {
     232            $wp_scripts->add( $_handle[0], $src, $deps, $ver );
     233        }
     234
     235        if ( $in_footer ) {
     236            $wp_scripts->add_data( $_handle[0], 'group', 1 );
     237        }
    235238    }
    236239
Note: See TracChangeset for help on using the changeset viewer.