WordPress.org

Make WordPress Core

Opened 2 weeks ago

Last modified 2 weeks ago

#48760 reviewing enhancement

Adjust argument type for wp_dequeue_style/wp_dequeue_script

Reported by: vanyukov Owned by: SergeyBiryukov
Milestone: 5.4 Priority: normal
Severity: normal Version:
Component: Script Loader Keywords: good-first-bug has-patch
Focuses: Cc:
PR Number:

Description

Currently, both functions require a string argument

@param string $handle Name of the stylesheet to be removed.

and will show a warning in IDE when an array is used: Expected string, got array

While the associated dequeue() methods for WP_Styles and WP_Scripts accept a mixed type argument.

* @param mixed $handles Item handle and argument (string) or item handles and arguments (array of strings).

and will actually cast the string to an array:

public function dequeue( $handles ) {
        foreach ( (array) $handles as $handle ) {
                $handle = explode( '?', $handle );
                $key    = array_search( $handle[0], $this->queue );
                if ( false !== $key ) {
                        unset( $this->queue[ $key ] );
                        unset( $this->args[ $handle[0] ] );
                }
        }
}

Attachments (1)

48760.patch (1.1 KB) - added by dishitpala 2 weeks ago.
Fixed function doc parameter info.

Download all attachments as: .zip

Change History (4)

#1 @johnbillion
2 weeks ago

  • Component changed from General to Script Loader
  • Keywords needs-patch good-first-bug added

@dishitpala
2 weeks ago

Fixed function doc parameter info.

#2 @dishitpala
2 weeks ago

  • Keywords has-patch added; needs-patch removed

#3 @SergeyBiryukov
2 weeks ago

  • Milestone changed from Awaiting Review to 5.4
  • Owner set to SergeyBiryukov
  • Status changed from new to reviewing
Note: See TracTickets for help on using tickets.