HEX
Server: Apache/2.4.41 (Ubuntu)
System: Linux wordpress-ubuntu-s-2vcpu-4gb-fra1-01 5.4.0-169-generic #187-Ubuntu SMP Thu Nov 23 14:52:28 UTC 2023 x86_64
User: root (0)
PHP: 7.4.33
Disabled: pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wifcontinued,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_get_handler,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,pcntl_async_signals,pcntl_unshare,
Upload Files
File: /var/www/shoetique/wp-content/plugins/googleanalytics/class/class-ga-template.php
<?php
/**
 * Google Analytics template.
 *
 * @package GoogleAnalytics
 */

/**
 * Class Ga_Template
 */
class Ga_Template {
	/**
	 * Array of template properties.
	 *
	 * @var array Props array.
	 */
	protected $props;

	/**
	 * Relative path in view/ folder.
	 *
	 * @var string Path string.
	 */
	protected $path;

	/**
	 * Ga_Template constructor.
	 *
	 * @param string $path Relative path in view/ folder.
	 * @param array  $props Array of props to be passed to the template.
	 */
	public function __construct( $path, $props = array() ) {
		$this->path  = $path;
		$this->props = $props;
	}

	/**
	 * Include rendered template inline.
	 *
	 * @param string $path Relative path in view/ folder.
	 * @param array  $props Array of props to be passed to the template.
	 */
	public static function load( $path, $props = array() ) {
		( new static( $path, $props ) )->include_template();
	}

	/**
	 * Get rendered template.
	 *
	 * @param string $path Relative path in view/ folder.
	 * @param array  $props Array of props to be passed to the template.
	 *
	 * @return string Rendered template.
	 */
	public static function render( $path, $props = array() ) {
		return ( new static( $path, $props ) )->render_template();
	}

	/**
	 * Include template.
	 */
	public function include_template() {
		$template_path = GA_PLUGIN_DIR . '/view/' . $this->path . '.php';

		if ( is_readable( $template_path ) ) {
			load_template( $template_path, false, $this->props );
		}
	}

	/**
	 * Get rendered template.
	 *
	 * @return string
	 */
	public function render_template() {
		ob_start();
		$this->include_template();
		$render = ob_get_contents();

		return false === empty( $render ) ? $render : '';
	}
}