<?php
/**
 * HVAC Template Integration
 *
 * Handles the integration of navigation and breadcrumbs into trainer pages
 */

if (!defined('ABSPATH')) {
    exit;
}

class HVAC_Template_Integration {
    
    /**
     * Instance of this class
     */
    private static $instance = null;
    
    /**
     * Get instance
     */
    public static function instance() {
        if (is_null(self::$instance)) {
            self::$instance = new self();
        }
        return self::$instance;
    }
    
    /**
     * Constructor
     */
    public function __construct() {
        add_action('init', array($this, 'init'));
    }
    
    /**
     * Initialize
     */
    public function init() {
        // Add navigation and breadcrumbs to trainer pages
        add_action('wp', array($this, 'setup_template_integration'));
    }
    
    /**
     * Setup template integration based on current page
     */
    public function setup_template_integration() {
        // REMOVED: Navigation injection via content filter
        // Navigation is now handled directly by page templates using HVAC_Menu_System
        // This prevents duplicate navigation rendering
    }
    
    /**
     * Check if current page is a trainer page
     */
    private function is_trainer_page() {
        global $wp;
        
        // Get current URL path
        $current_url = home_url(add_query_arg(array(), $wp->request));
        
        // Check if URL contains /trainer/ but not /master-trainer/
        return (strpos($current_url, '/trainer/') !== false && strpos($current_url, '/master-trainer/') === false);
    }
    
    /**
     * DEPRECATED: Navigation and breadcrumbs are now handled directly by page templates
     * @deprecated Use HVAC_Menu_System and HVAC_Breadcrumbs directly in templates
     */
    public function render_navigation_and_breadcrumbs() {
        // This method is deprecated - navigation and breadcrumbs
        // are now rendered directly by page templates to prevent duplication
        // and follow WordPress best practices for template structure
        return;
    }
    
    
    /**
     * DEPRECATED: Navigation is now handled directly by page templates
     * This method is kept for backward compatibility but does nothing
     * @deprecated Use HVAC_Menu_System::instance()->render_trainer_menu() in templates
     */
    public function add_navigation_to_content($content) {
        // Navigation is now handled directly by page templates using HVAC_Menu_System
        // This prevents duplicate navigation rendering and follows best practices
        return $content;
    }
}

// Initialize
HVAC_Template_Integration::instance();