Make WordPress Core


Ignore:
Timestamp:
05/06/2020 04:25:09 PM (4 years ago)
Author:
SergeyBiryukov
Message:

Script Loader: Add the $group parameter to WP_Dependencies::do_item().

Previously, the method was called with two parameters in ::do_items(), while the method signature only included one parameter.

Technically, this was not an issue as WP_Dependencies::do_item() is a placeholder meant to be overwritten when extending the class. When handling scripts, WP_Dependencies is extended with WP_Scripts, and the $group parameter was only used in WP_Scripts::do_item(), which does expect a second argument.

However, officially adding the parameter to WP_Dependencies::do_item() signature prevents code misunderstanding and avoids a warning in PHP code inspection tools.

Props kaggdesign, soulseekah, azaozz, SergeyBiryukov.
Fixes #43627.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/class.wp-styles.php

    r47219 r47769  
    140140     *
    141141     * @since 2.6.0
     142     * @since 5.5.0 Added the `$group` parameter.
    142143     *
    143144     * @see WP_Dependencies::do_item()
    144145     *
    145      * @param string $handle The style's registered handle.
     146     * @param string    $handle The style's registered handle.
     147     * @param int|false $group  Optional. Group level: level (int), no groups (false).
     148     *                          Default false.
    146149     * @return bool True on success, false on failure.
    147150     */
    148     public function do_item( $handle ) {
     151    public function do_item( $handle, $group = false ) {
    149152        if ( ! parent::do_item( $handle ) ) {
    150153            return false;
Note: See TracChangeset for help on using the changeset viewer.