Tribe__Context::safe_set( $values_or_key, mixed|null $value = null )

Safely set the value of a group of locations.

This method can only augment the context, without altering it; it can only add new values.


Parameters

$values

(array|string) (Required) The values to set, if not already set or the key of the value to set, requires the $value to be passed.

$value

(mixed|null) (Optional) The value to set for the key, this parameter will be ignored if the $values_or_key parameter is not a string.

Default value: null


Top ↑

Source

File: src/Tribe/Context.php

	public function safe_set( $values_or_key, $value = null ) {
		$values = func_num_args() === 2
			? [ $values_or_key => $value ]
			: $values_or_key;

		foreach ( $values as $key => $val ) {
			if ( static::NOT_FOUND !== $this->get( $key, static::NOT_FOUND ) ) {
				continue;
			}
			$this->request_cache[ $key ] = $val;
		}
	}

Top ↑

Changelog

Changelog
Version Description
4.10.2 Introduced.