tribe_get_var( string $slug, null $default = null )

Returns the value of a registered variable.

Example use:

 tribe_set_var( 'tec.url', 'http://example.com' );

 $url = tribe_get_var( 'tec.url' );

Parameters #

$slug

(string) (Required) The slug of the variable registered using tribe_set_var.

$default

(null) (Optional) The value that should be returned if the variable slug is not a registered one.

Default value: null


Top ↑

Return #

(mixed) Either the registered value or the default value if the variable is not registered.


Top ↑

Source #

File: src/Tribe/Container.php

	function tribe_get_var( $slug, $default = null ) {
		$container = Tribe__Container::init();

		try {
			$var = $container->getVar( $slug );
		} catch ( InvalidArgumentException $e ) {
			return $default;
		}

		return $var;
	}