WP_Dependencies::query() WordPress Method

The query() method of WP_Dependencies allows for a query to be run against the dependency values. This is useful for finding out which dependencies are required for a particular component. The query can be either a string or an array.

WP_Dependencies::query( string $handle, string $status = 'registered' ) #

Query the list for an item.


Parameters

$handle

(string)(Required)Name of the item. Should be unique.

$status

(string)(Optional) Status of the item to query.

Default value: 'registered'


Top ↑

Return

(bool|_WP_Dependency) Found, or object Item data.


Top ↑

Source

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

	public function query( $handle, $status = 'registered' ) {
		switch ( $status ) {
			case 'registered':
			case 'scripts': // Back compat.
				if ( isset( $this->registered[ $handle ] ) ) {
					return $this->registered[ $handle ];
				}
				return false;

			case 'enqueued':
			case 'queue': // Back compat.
				if ( in_array( $handle, $this->queue, true ) ) {
					return true;
				}
				return $this->recurse_deps( $this->queue, $handle );

			case 'to_do':
			case 'to_print': // Back compat.
				return in_array( $handle, $this->to_do, true );

			case 'done':
			case 'printed': // Back compat.
				return in_array( $handle, $this->done, true );
		}

		return false;
	}


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.