WP_Dependencies::enqueue()publicWP 2.1.0

Queue an item or items.

Decodes handles and arguments, then queues handles and stores arguments in the class property $args. For example in extending classes, $args is appended to the item url as a query string. Note $args is NOT the $args property of items in the $registered array.

Метод класса: WP_Dependencies{}

Хуков нет.

Возвращает

null. Ничего (null).

Использование

$WP_Dependencies = new WP_Dependencies();
$WP_Dependencies->enqueue( $handles );
$handles(строка|string[]) (обязательный)
Item handle (string) or item handles (array of strings).

Список изменений

С версии 2.1.0 Введена.
С версии 2.6.0 Moved from WP_Scripts.

Код WP_Dependencies::enqueue() WP 6.5.2

public function enqueue( $handles ) {
	foreach ( (array) $handles as $handle ) {
		$handle = explode( '?', $handle );

		if ( ! in_array( $handle[0], $this->queue, true ) && isset( $this->registered[ $handle[0] ] ) ) {
			$this->queue[] = $handle[0];

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

			if ( isset( $handle[1] ) ) {
				$this->args[ $handle[0] ] = $handle[1];
			}
		} elseif ( ! isset( $this->registered[ $handle[0] ] ) ) {
			$this->queued_before_register[ $handle[0] ] = null; // $args

			if ( isset( $handle[1] ) ) {
				$this->queued_before_register[ $handle[0] ] = $handle[1];
			}
		}
	}
}