WP_Dependencies::do_items() WordPress Method

The WP_Dependencies::do_items() method is used to enqueue or print a script or style dependency. This is typically done by scripts or styles that have been registered or enqueued by the wp_register_script() or wp_register_style() functions.

WP_Dependencies::do_items( string|string[]|false $handles = false, int|false $group = false ) #

Processes the items and dependencies.


Description

Processes the items passed to it or the queue, and their dependencies.


Top ↑

Parameters

$handles

(string|string[]|false)(Optional) Items to be processed: queue (false), single item (string), or multiple items (array of strings).

Default value: false

$group

(int|false)(Optional) Group level: level (int), no group (false).

Default value: false


Top ↑

Return

(string[]) Array of handles of items that have been processed.


Top ↑

Source

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

	public function do_items( $handles = false, $group = false ) {
		/*
		 * If nothing is passed, print the queue. If a string is passed,
		 * print that item. If an array is passed, print those items.
		 */
		$handles = false === $handles ? $this->queue : (array) $handles;
		$this->all_deps( $handles );

		foreach ( $this->to_do as $key => $handle ) {
			if ( ! in_array( $handle, $this->done, true ) && isset( $this->registered[ $handle ] ) ) {
				/*
				 * Attempt to process the item. If successful,
				 * add the handle to the done array.
				 *
				 * Unset the item from the to_do array.
				 */
				if ( $this->do_item( $handle, $group ) ) {
					$this->done[] = $handle;
				}

				unset( $this->to_do[ $key ] );
			}
		}

		return $this->done;
	}


Top ↑

Changelog

Changelog
VersionDescription
2.8.0Added the $group parameter.
2.6.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.