Make WordPress Core


Ignore:
Timestamp:
02/12/2024 12:58:53 PM (4 months ago)
Author:
gziolo
Message:

Script Modules API: Add deregister module function

It was impossible to deregister a script module. It is changing to avoid problems for extenders that want to override any Core script module.

Fixes #60463.
Props cbravobernal, gziolo, mukesh27, youknowriad.

File:
1 edited

Legend:

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

    r57492 r57593  
    149149            $this->registered[ $id ]['enqueue'] = false;
    150150        }
     151        unset( $this->enqueued_before_registered[ $id ] );
     152    }
     153
     154    /**
     155     * Removes a registered script module.
     156     *
     157     * @since 6.5.0
     158     *
     159     * @param string $id The identifier of the script module.
     160     */
     161    public function deregister( string $id ) {
     162        unset( $this->registered[ $id ] );
    151163        unset( $this->enqueued_before_registered[ $id ] );
    152164    }
Note: See TracChangeset for help on using the changeset viewer.