WP_Dependencies::set_group() WordPress Method

The WP_Dependencies::set_group() method allows you to set the group level for enqueued scripts. This is useful for loading scripts in the correct order, as well as for debugging purposes. The default group level is 0.

WP_Dependencies::set_group( string $handle, bool $recursion, int|false $group ) #

Set item group, unless already in a lower group.


Parameters

$handle

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

$recursion

(bool)(Required)Internal flag that calling function was called recursively.

$group

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


Top ↑

Return

(bool) Not already in the group or a lower group.


Top ↑

Source

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

	public function set_group( $handle, $recursion, $group ) {
		$group = (int) $group;

		if ( isset( $this->groups[ $handle ] ) && $this->groups[ $handle ] <= $group ) {
			return false;
		}

		$this->groups[ $handle ] = $group;

		return true;
	}


Top ↑

Changelog

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