_WP_Dependency::add_data() WordPress Method

The add_data() method of the WP_Dependency class is used to add data to a Dependency object. The first parameter is the data key, and the second parameter is the data value. The data key can be any string, but must be unique within the Dependency object. The data value can be any PHP data type, including arrays and objects.

_WP_Dependency::add_data( string $name, mixed $data ) #

Add handle data.


Parameters

$name

(string)(Required)The data key to add.

$data

(mixed)(Required)The data value to add.


Top ↑

Return

(bool) False if not scalar, true otherwise.


Top ↑

Source

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

	public function add_data( $name, $data ) {
		if ( ! is_scalar( $name ) ) {
			return false;
		}
		$this->extra[ $name ] = $data;
		return true;
	}

Top ↑

Changelog

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