Make WordPress Core

#48760 closed enhancement (fixed)

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:


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 18 months ago.
Fixed function doc parameter info.

Download all attachments as: .zip

Change History (5)

#1 @johnbillion
18 months ago

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

18 months ago

Fixed function doc parameter info.

#2 @dishitpala
18 months ago

  • Keywords has-patch added; needs-patch removed

#3 @SergeyBiryukov
18 months ago

  • Milestone changed from Awaiting Review to 5.4
  • Owner set to SergeyBiryukov
  • Status changed from new to reviewing

#4 @SergeyBiryukov
16 months ago

  • Resolution set to fixed
  • Status changed from reviewing to closed

Thanks for the ticket and the patch! This appears to be addressed in [46661].

Both WP_Dependencies::enqueue() and ::dequeue() now have the $handles parameter documented as string|string[] instead of mixed.

Note: See TracTickets for help on using tickets.