WP_Dependencies::recurse_deps() WordPress Method

The recurse_deps() method is a recursive way of handling dependencies in WordPress. It is used to ensure that all dependencies are met before a particular piece of code is executed. This is important because some code may depend on others in order to work properly.

WP_Dependencies::recurse_deps( string[] $queue, string $handle ) #

Recursively search the passed dependency tree for a handle.


Parameters

$queue

(string[])(Required)An array of queued _WP_Dependency handles.

$handle

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


Top ↑

Return

(bool) Whether the handle is found after recursively searching the dependency tree.


Top ↑

Source

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

	protected function recurse_deps( $queue, $handle ) {
		if ( isset( $this->all_queued_deps ) ) {
			return isset( $this->all_queued_deps[ $handle ] );
		}

		$all_deps = array_fill_keys( $queue, true );
		$queues   = array();
		$done     = array();

		while ( $queue ) {
			foreach ( $queue as $queued ) {
				if ( ! isset( $done[ $queued ] ) && isset( $this->registered[ $queued ] ) ) {
					$deps = $this->registered[ $queued ]->deps;
					if ( $deps ) {
						$all_deps += array_fill_keys( $deps, true );
						array_push( $queues, $deps );
					}
					$done[ $queued ] = true;
				}
			}
			$queue = array_pop( $queues );
		}

		$this->all_queued_deps = $all_deps;

		return isset( $this->all_queued_deps[ $handle ] );
	}


Top ↑

Changelog

Changelog
VersionDescription
4.0.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.