Tribe__Template::template_safe_include( string $file )
Includes a give PHP inside of a safe context.
This method is required to prevent template files messing with local variables used inside of the self::template
method. Also shelters the template loading from any possible variables that could be overwritten by the context.
Parameters
- $file
-
(string) (Required) Which file will be included with safe context.
Return
(string) Contents of the included file.
Source
File: src/Tribe/Template.php
public function template_safe_include( $file ) { // We use this instance variable to prevent collisions. $this->template_current_file_path = $file; unset( $file ); // Only do this if really needed (by default it wont). if ( true === $this->template_context_extract && ! empty( $this->context ) ) { // Make any provided variables available in the template variable scope. extract( $this->context ); // @phpcs:ignore } include $this->template_current_file_path; // After the include we reset the variable. unset( $this->template_current_file_path ); }
Changelog
Version | Description |
---|---|
4.11.0 | Introduced. |