# easy-invoice/2.3.7/includes/TemplateLoader.php

Easy Invoice – Invoice Generator, PDF Quotes &amp; Payments, version 2.3.7. 105 lines.

- Page: https://pluginprobe.com/plugins/easy-invoice/2.3.7/code/includes/TemplateLoader.php
- Raw: https://pluginprobe.com/plugins/easy-invoice/2.3.7/raw/includes/TemplateLoader.php
- Modified: 2025-08-14T09:51:16+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/easy-invoice/2.3.7/code/includes/TemplateLoader.php#L10-L20`.

```php
<?php
/**
 * Template Loader Class
 *
 * @package Easy_Invoice
 * @subpackage Includes
 */

namespace EasyInvoice;

/**
 * Template Loader Class
 * 
 * Handles loading of custom templates for the Easy Invoice plugin.
 */
class TemplateLoader {
    
    /**
     * Initialize the template loader
     */
    public function init() {
        add_filter('single_template', [$this, 'loadSingleQuoteTemplate']);
        add_filter('single_template', [$this, 'loadSingleInvoiceTemplate']);
        add_filter('template_include', [$this, 'loadCustomTemplates']);
    }
    
    /**
     * Load single quote template
     *
     * @param string $template The template path
     * @return string Modified template path
     */
    public function loadSingleQuoteTemplate($template) {
        global $post;
        
        if ($post && $post->post_type === \EasyInvoice\Constants\PostTypes::EASY_INVOICE_QUOTE_POST_TYPE) {
            $custom_template = EASY_INVOICE_PLUGIN_DIR . 'templates/quotes/single.php';
            
            if (file_exists($custom_template)) {
                return $custom_template;
            } else {
                // Single quote template not found
            }
        }
        
        return $template;
    }
    
    /**
     * Load single invoice template
     *
     * @param string $template The template path
     * @return string Modified template path
     */
    public function loadSingleInvoiceTemplate($template) {
        global $post;
        
        if ($post && $post->post_type === \EasyInvoice\Constants\PostTypes::EASY_INVOICE_POST_TYPE) {
            $custom_template = EASY_INVOICE_PLUGIN_DIR . 'templates/invoices/single.php';
            
            if (file_exists($custom_template)) {
                return $custom_template;
            } else {
                // Single invoice template not found
            }
        }
        
        return $template;
    }
    
    /**
     * Load custom templates for Easy Invoice pages
     *
     * @param string $template The template path
     * @return string Modified template path
     */
    public function loadCustomTemplates($template) {
        global $post;
        
        // Handle single quote pages
        if (is_singular(\EasyInvoice\Constants\PostTypes::EASY_INVOICE_QUOTE_POST_TYPE)) {
            $custom_template = EASY_INVOICE_PLUGIN_DIR . 'templates/quotes/single.php';
            
            
            if (file_exists($custom_template)) {
                return $custom_template;
            } else {
                // Single quote template not found
            }
        }
        
        // Handle single invoice pages
        if (is_singular(\EasyInvoice\Constants\PostTypes::EASY_INVOICE_POST_TYPE)) {
            $custom_template = EASY_INVOICE_PLUGIN_DIR . 'templates/invoices/single.php';
            
            if (file_exists($custom_template)) {
                return $custom_template;
            } else {
                // Single invoice template not found
            }
        }
        
        return $template;
    }
} 
```
