lib/Loader.php
public function choose_template( $templates ) {
		// Change $templates into array, if needed
		if ( !is_array($templates) ) {
			$templates = (array) $templates;
		}

		// Get Twig loader
		$loader = $this->get_loader();

		// Run through template array
		foreach ( $templates as $template ) {

			// Remove any whitespace around the template name
			$template = trim( $template );
			// Use the Twig loader to test for existance
			if ( $loader->exists($template) ) {
				// Return name of existing template
				return $template;
			}
		}

		// No existing template was found
		return false;
	}
public function choose_template( $templates ) {
		// Change $templates into array, if needed
		if ( !is_array($templates) ) {
			$templates = (array) $templates;
		}

		// Get Twig loader
		$loader = $this->get_loader();

		// Run through template array
		foreach ( $templates as $template ) {

			// Remove any whitespace around the template name
			$template = trim( $template );
			// Use the Twig loader to test for existance
			if ( $loader->exists($template) ) {
				// Return name of existing template
				return $template;
			}
		}

		// No existing template was found
		return false;
	}
public function choose_template ( $ templates ) { // Change $templates into array, if needed if ( ! is_array ( $ templates ) ) { $ templates = ( array ) $ templates ; } // Get Twig loader $ loader = $ this -> get_loader ( ) ; // Run through template array foreach ( $ templates as $ template ) { // Remove any whitespace around the template name $ template = trim ( $ template ) ; // Use the Twig loader to test for existance if ( $ loader -> exists ( $ template ) ) { // Return name of existing template return $ template ; } } // No existing template was found return false ; }
Get first existing template.

@param array|string $templates  Name(s) of the Twig template(s) to choose from.
@return string|bool             Name of chosen template, otherwise false.
Get first existing template .