<?php
class kavehboardheaderandfooter {

    public $dashboard_page_id;
    public $selected_style;
    public $use_enhanced_dashboard;
    
    public static $instance = null;

    public function __construct() {
        // Extract page IDs from Codestar Framework
        $options = get_option('kavehboard_options');
        $this->dashboard_page_id = isset($options['kavehboard_page']) ? $options['kavehboard_page'] : '';
        $this->selected_style = isset($options['kavehboard_panel_style']) ? $options['kavehboard_panel_style'] : '';

        add_filter('template_include', [$this, 'force_custom_template']);
    }

    // Singleton Instance
    public static function get_instance() {
        if (self::$instance === null) {
            self::$instance = new self();
        }
        return self::$instance;
    }

    // Force custom template for specific pages
    public function force_custom_template($template) {
        if(is_page($this->dashboard_page_id)) {
            // Choose between original and enhanced dashboard template
            $template = KAVEHBOARD_PATH . 'template-part/dashboard.php';
             return $template;
        }
        return $template;
    }

}
