Tribe__Context::safe_set( $values_or_key, mixed|null $value = null )
Safely set the value of a group of locations.
Contents
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
$valueto be passed. - $value
-
(mixed|null) (Optional) The value to set for the key, this parameter will be ignored if the
$values_or_keyparameter is not a string.Default value: null
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;
}
}
Changelog
| Version | Description |
|---|---|
| 4.10.2 | Introduced. |