WP_Dependencies::dequeue() WordPress Method

The WP_Dependencies::dequeue() method is used to remove a registered script from the queue. This is useful for deregistering scripts that are no longer needed or for conditionally loading scripts.

WP_Dependencies::dequeue( string|string[] $handles ) #

Dequeue an item or items.


Description

Decodes handles and arguments, then dequeues handles and removes arguments from the class property $args.


Top ↑

Parameters

$handles

(string|string[])(Required)Item handle (string) or item handles (array of strings).


Top ↑

Source

File: wp-includes/class.wp-dependencies.php

	public function dequeue( $handles ) {
		foreach ( (array) $handles as $handle ) {
			$handle = explode( '?', $handle );
			$key    = array_search( $handle[0], $this->queue, true );

			if ( false !== $key ) {
				// Reset all dependencies so they must be recalculated in recurse_deps().
				$this->all_queued_deps = null;

				unset( $this->queue[ $key ] );
				unset( $this->args[ $handle[0] ] );
			} elseif ( array_key_exists( $handle[0], $this->queued_before_register ) ) {
				unset( $this->queued_before_register[ $handle[0] ] );
			}
		}
	}

Top ↑

Changelog

Changelog
VersionDescription
2.6.0Moved from WP_Scripts.
2.1.0Introduced.

The content displayed on this page has been created in part by processing WordPress source code files which are made available under the GPLv2 (or a later version) license by theĀ Free Software Foundation. In addition to this, the content includes user-written examples and information. All material is subject to review and curation by the WPPaste.com community.