Tribe__Template::template_get_origin_namespace( string $path )

Based on a path it determines what is the namespace that should be used.


Parameters #

$path

(string) (Required) Which file we are going to load.


Top ↑

Return #

(string|false) The found namespace for that path or false.


Top ↑

Source #

File: src/Tribe/Template.php

	public function template_get_origin_namespace( $path ) {
		$matching_namespace = false;
		/**
		 * Allows more namespaces to be added based on the path of the file we are loading.
		 *
		 * @since 4.11.0
		 *
		 * @param array  $namespace_map Indexed array containing the namespace as the key and path to `strpos`.
		 * @param string $path          Path we will do the `strpos` to validate a given namespace.
		 * @param self   $template      Current instance of the template class.
		 */
		$namespace_map = (array) apply_filters( 'tribe_template_origin_namespace_map', [], $path, $this );

		foreach ( $namespace_map as $namespace => $contains_string ) {
			// Skip when we dont have the namespace path.
			if ( false === strpos( $path, $contains_string ) ) {
				continue;
			}

			$matching_namespace = $namespace;

			// Once the first namespace is found it breaks out.
			break;
		}

		if ( empty( $matching_namespace ) && ! empty( $this->origin->template_namespace ) ) {
			$matching_namespace = $this->origin->template_namespace;
		}

		return $matching_namespace;
	}

Top ↑

Changelog #

Changelog
Version Description
4.11.0 Introduced.