WP_Scripts::set_group() WordPress Method

The WP_Scripts::set_group() function is used to set the group for a particular script. This function can be used in conjunction with the wp_enqueue_script() function.

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

Sets handle group.


Description

Top ↑

See also


Top ↑

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)(Optional) Group level: level (int), no groups (false).

Default value: false


Top ↑

Return

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


Top ↑

Source

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

	public function set_group( $handle, $recursion, $group = false ) {
		if ( isset( $this->registered[ $handle ]->args ) && 1 === $this->registered[ $handle ]->args ) {
			$grp = 1;
		} else {
			$grp = (int) $this->get_data( $handle, 'group' );
		}

		if ( false !== $group && $grp > $group ) {
			$grp = $group;
		}

		return parent::set_group( $handle, $recursion, $grp );
	}


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.