# bookit/trunk/includes/classes/Template.php

Bookit — Booking &amp; Appointment Calendar, version trunk. 76 lines.

- Page: https://pluginprobe.com/plugins/bookit/trunk/code/includes/classes/Template.php
- Raw: https://pluginprobe.com/plugins/bookit/trunk/raw/includes/classes/Template.php
- Modified: 2025-11-10T21:04:20+00:00

Line numbers below start at 1. Link to a line or a range by appending a fragment to the
page URL, for example `https://pluginprobe.com/plugins/bookit/trunk/code/includes/classes/Template.php#L10-L20`.

```php
<?php

namespace Bookit\Classes;

class Template {

	/**
	 * @param        $template_name
	 * @param string $template_path
	 * @param string $default_path
	 *
	 * @return string
	 */
	public static function locate_template( $template_name, $template_path = 'bookit/', $default_path = '' ) {
		$template_name .= '.php';
		if ( self::template_path() != $template_path ) {
			$template_path = self::template_path() . $template_path;
		}
		if ( locate_template( $template_path . $template_name ) ) {
			return locate_template( $template_path . $template_name );
		}

		return self::plugin_path( $default_path ) . '/' . $template_name;
	}

	/**
	 * @param       $template_name
	 * @param array $args
	 * @param null  $echo
	 *
	 * @return bool|string
	 */
	public static function load_template( $template_name, $args = array(), $echo = null ) {
		if ( null == $echo ) {
			return self::load( $template_name, $args );
		}
		echo self::load( $template_name, $args ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
	}

	/**
	 * @param        $template_name
	 * @param array  $args
	 * @param string $template_path
	 * @param string $default_path
	 *
	 * @return bool|string
	 */
	public static function load( $template_name, $args = array(), $template_path = 'bookit/', $default_path = '' ) {
		ob_start();
		if ( is_array( $args ) ) {
			extract( $args );
		}
		$file = self::locate_template( $template_name, $template_path, $default_path );
		if ( ! file_exists( $file ) ) {
			return false;
		}
		include( $file );

		return ob_get_clean();
	}

	public static function template_path() {
		return apply_filters( 'bookit_template_path', 'bookit/' );
	}

	/**
	 * @return string
	 */
	public static function plugin_path( $default_path = '' ) {
		if ( ! empty( $default_path ) ) {
			return untrailingslashit( $default_path );
		}
		return untrailingslashit( BOOKIT_PATH . '/templates/' );
	}
}

```
