Make WordPress Core

Changeset 47769


Ignore:
Timestamp:
05/06/2020 04:25:09 PM (5 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.

Location:
trunk/src/wp-includes
Files:
2 edited

Legend:

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

    r47502 r47769  
    129129     *
    130130     * @since 2.6.0
    131      *
    132      * @param string $handle Name of the item. Should be unique.
     131     * @since 5.5.0 Added the `$group` parameter.
     132     *
     133     * @param string    $handle Name of the item. Should be unique.
     134     * @param int|false $group  Optional. Group level: level (int), no groups (false).
     135     *                          Default false.
    133136     * @return bool True on success, false if not set.
    134137     */
    135     public function do_item( $handle ) {
     138    public function do_item( $handle, $group = false ) {
    136139        return isset( $this->registered[ $handle ] );
    137140    }
  • 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.