65 lines
1.5 KiB
PHP
65 lines
1.5 KiB
PHP
<?php
|
|
/**
|
|
* Ticket Tailor Template Loader
|
|
*
|
|
* Handles template loading with theme override support
|
|
*/
|
|
|
|
// Exit if accessed directly
|
|
if (!defined('ABSPATH')) {
|
|
exit;
|
|
}
|
|
|
|
class Ticket_Tailor_Template_Loader {
|
|
|
|
/**
|
|
* Get template path
|
|
*
|
|
* Checks theme folder first, then plugin folder
|
|
*/
|
|
public static function get_template_path($template_name) {
|
|
$template = '';
|
|
|
|
// Check in theme
|
|
$theme_template = locate_template(array(
|
|
'ticket-tailor/' . $template_name,
|
|
$template_name,
|
|
));
|
|
|
|
if ($theme_template) {
|
|
$template = $theme_template;
|
|
} else {
|
|
// Use plugin template
|
|
$template = TICKET_TAILOR_PLUGIN_DIR . 'templates/' . $template_name;
|
|
}
|
|
|
|
return apply_filters('ticket_tailor_template_path', $template, $template_name);
|
|
}
|
|
|
|
/**
|
|
* Load template
|
|
*/
|
|
public static function load_template($template_name, $args = array()) {
|
|
$template_path = self::get_template_path($template_name);
|
|
|
|
if (!file_exists($template_path)) {
|
|
return;
|
|
}
|
|
|
|
// Extract variables
|
|
if (!empty($args) && is_array($args)) {
|
|
extract($args);
|
|
}
|
|
|
|
include $template_path;
|
|
}
|
|
|
|
/**
|
|
* Get template HTML
|
|
*/
|
|
public static function get_template_html($template_name, $args = array()) {
|
|
ob_start();
|
|
self::load_template($template_name, $args);
|
|
return ob_get_clean();
|
|
}
|
|
}
|