WordPress at Your Fingertips
function is not described


AssetDataRegistry::add() public WC 1.0

Interface for adding data to the registry.

You can only register data that is not already in the registry identified by the given key. If there is a duplicate found, unless $ignore_duplicates is true, an exception will be thrown.

{} It's a method of the class: AssetDataRegistry{}

No Hooks.


null. Nothing.


$AssetDataRegistry = new AssetDataRegistry();
$AssetDataRegistry->add( $key, $data, $check_key_exists );
$key(string) (required)
The key used to reference the data being registered.
$data(mixed) (required)
If not a function, registered to the registry as is. If a function, then the callback is invoked right before output to the screen.
If set to true, duplicate data will be ignored if the key exists. If false, duplicate data will cause an exception.
Default: false

Code of AssetDataRegistry::add() WC 5.7.1

public function add( $key, $data, $check_key_exists = false ) {
	if ( $check_key_exists && $this->exists( $key ) ) {
	try {
		$this->add_data( $key, $data );
	} catch ( Exception $e ) {
		if ( $this->debug() ) {
			// bubble up.
			throw $e;
		wc_caught_exception( $e, __METHOD__, [ $key, $data ] );