BREAKING CHANGE: Removed Astra theme integration and all theme-specific code
- Removed class-hvac-astra-integration.php (584 lines of theme-specific code)
- Removed 500+ theme-specific CSS files (ast-*, astra-*, divi-*)
- Removed 15+ theme-specific JavaScript files
- Created theme-agnostic HVAC_Layout_Manager class
- Added generic hvac-layout.css with universal styling
- Plugin now works with ANY WordPress theme
This refactoring ensures the plugin complies with WordPress.org plugin
guidelines which require plugins to be theme-independent. The new layout
system uses standard WordPress hooks and filters that work universally.
Key changes:
- Body classes: hvac-plugin-page, hvac-no-sidebar, hvac-full-width
- Generic post meta: _sidebar_layout, page_layout (widely supported)
- Standard WordPress hooks: body_class, wp_enqueue_scripts, is_active_sidebar
- CSS uses generic selectors: .site-content, .content-area, #primary
Removed monitoring infrastructure files that were causing PHP segfaults:
- class-hvac-background-jobs.php
- class-hvac-health-monitor.php
- class-hvac-error-recovery.php
- class-hvac-security-monitor.php
- class-hvac-performance-monitor.php
- class-hvac-backup-manager.php
- class-hvac-cache-optimizer.php
🤖 Generated with Claude Code
Co-Authored-By: Claude <noreply@anthropic.com>
		
	
			
		
			
				
	
	
		
			259 lines
		
	
	
		
			No EOL
		
	
	
		
			8.3 KiB
		
	
	
	
		
			PHP
		
	
	
	
	
	
			
		
		
	
	
			259 lines
		
	
	
		
			No EOL
		
	
	
		
			8.3 KiB
		
	
	
	
		
			PHP
		
	
	
	
	
	
| <?php
 | |
| /**
 | |
|  * HVAC Template Router
 | |
|  * 
 | |
|  * Manages template routing and page configuration for the base template system
 | |
|  * 
 | |
|  * @package HVAC_Community_Events
 | |
|  * @since 2.0.0
 | |
|  */
 | |
| 
 | |
| if (!defined('ABSPATH')) {
 | |
|     exit;
 | |
| }
 | |
| 
 | |
| class HVAC_Template_Router {
 | |
|     
 | |
|     /**
 | |
|      * Page configurations mapping slugs to render settings
 | |
|      * 
 | |
|      * @var array
 | |
|      */
 | |
|     private static $page_configs = [
 | |
|         // Simple shortcode-based pages
 | |
|         'trainer/certificate-reports' => [
 | |
|             'render_method' => 'shortcode',
 | |
|             'content_source' => '[hvac_certificate_reports]',
 | |
|             'show_navigation' => true,
 | |
|             'show_breadcrumbs' => true,
 | |
|             'menu_type' => 'trainer'
 | |
|         ],
 | |
|         'trainer/generate-certificates' => [
 | |
|             'render_method' => 'shortcode',
 | |
|             'content_source' => '[hvac_generate_certificates]',
 | |
|             'show_navigation' => true,
 | |
|             'show_breadcrumbs' => true,
 | |
|             'menu_type' => 'trainer'
 | |
|         ],
 | |
|         'trainer/profile/edit' => [
 | |
|             'render_method' => 'shortcode',
 | |
|             'content_source' => '[hvac_trainer_profile_edit]',
 | |
|             'show_navigation' => true,
 | |
|             'show_breadcrumbs' => false,
 | |
|             'menu_type' => 'trainer'
 | |
|         ],
 | |
|         'trainer/venue/list' => [
 | |
|             'render_method' => 'shortcode',
 | |
|             'content_source' => '[hvac_trainer_venues_list]',
 | |
|             'show_navigation' => true,
 | |
|             'show_breadcrumbs' => true,
 | |
|             'menu_type' => 'trainer'
 | |
|         ],
 | |
|         'trainer/venue/manage' => [
 | |
|             'render_method' => 'shortcode',
 | |
|             'content_source' => '[hvac_trainer_venue_manage]',
 | |
|             'show_navigation' => true,
 | |
|             'show_breadcrumbs' => true,
 | |
|             'menu_type' => 'trainer'
 | |
|         ],
 | |
|         'trainer/organizer/list' => [
 | |
|             'render_method' => 'shortcode',
 | |
|             'content_source' => '[hvac_trainer_organizers_list]',
 | |
|             'show_navigation' => true,
 | |
|             'show_breadcrumbs' => true,
 | |
|             'menu_type' => 'trainer'
 | |
|         ],
 | |
|         'trainer/organizer/manage' => [
 | |
|             'render_method' => 'shortcode',
 | |
|             'content_source' => '[hvac_trainer_organizer_manage]',
 | |
|             'show_navigation' => true,
 | |
|             'show_breadcrumbs' => true,
 | |
|             'menu_type' => 'trainer'
 | |
|         ],
 | |
|         'trainer/training-leads' => [
 | |
|             'render_method' => 'shortcode',
 | |
|             'content_source' => '[hvac_trainer_training_leads]',
 | |
|             'show_navigation' => true,
 | |
|             'show_breadcrumbs' => true,
 | |
|             'menu_type' => 'trainer'
 | |
|         ],
 | |
|         'trainer/announcements' => [
 | |
|             'render_method' => 'shortcode',
 | |
|             'content_source' => '[hvac_trainer_announcements]',
 | |
|             'show_navigation' => true,
 | |
|             'show_breadcrumbs' => true,
 | |
|             'menu_type' => 'trainer'
 | |
|         ],
 | |
|         'trainer/resources' => [
 | |
|             'render_method' => 'shortcode',
 | |
|             'content_source' => '[hvac_trainer_resources]',
 | |
|             'show_navigation' => true,
 | |
|             'show_breadcrumbs' => true,
 | |
|             'menu_type' => 'trainer'
 | |
|         ],
 | |
|         'trainer/documentation' => [
 | |
|             'render_method' => 'shortcode',
 | |
|             'content_source' => '[hvac_documentation]',
 | |
|             'show_navigation' => true,
 | |
|             'show_breadcrumbs' => true,
 | |
|             'menu_type' => 'trainer'
 | |
|         ],
 | |
|         
 | |
|         // Master trainer pages
 | |
|         'master-trainer/announcements' => [
 | |
|             'render_method' => 'shortcode',
 | |
|             'content_source' => '[hvac_master_announcements]',
 | |
|             'show_navigation' => true,
 | |
|             'show_breadcrumbs' => true,
 | |
|             'menu_type' => 'master_trainer'
 | |
|         ],
 | |
|         'master-trainer/manage-announcements' => [
 | |
|             'render_method' => 'shortcode',
 | |
|             'content_source' => '[hvac_master_manage_announcements]',
 | |
|             'show_navigation' => true,
 | |
|             'show_breadcrumbs' => true,
 | |
|             'menu_type' => 'master_trainer'
 | |
|         ],
 | |
|         
 | |
|         // Email and communication pages
 | |
|         'trainer/email-attendees' => [
 | |
|             'render_method' => 'shortcode',
 | |
|             'content_source' => '[hvac_email_attendees]',
 | |
|             'show_navigation' => true,
 | |
|             'show_breadcrumbs' => true,
 | |
|             'menu_type' => 'trainer'
 | |
|         ],
 | |
|         'trainer/communication-templates' => [
 | |
|             'render_method' => 'shortcode',
 | |
|             'content_source' => '[hvac_communication_templates]',
 | |
|             'show_navigation' => true,
 | |
|             'show_breadcrumbs' => true,
 | |
|             'menu_type' => 'trainer'
 | |
|         ],
 | |
|         'trainer/communication-schedules' => [
 | |
|             'render_method' => 'shortcode',
 | |
|             'content_source' => '[hvac_communication_schedules]',
 | |
|             'show_navigation' => true,
 | |
|             'show_breadcrumbs' => true,
 | |
|             'menu_type' => 'trainer'
 | |
|         ],
 | |
|         
 | |
|         // Event management pages
 | |
|         'trainer/event/summary' => [
 | |
|             'render_method' => 'shortcode',
 | |
|             'content_source' => '[hvac_event_summary]',
 | |
|             'show_navigation' => true,
 | |
|             'show_breadcrumbs' => true,
 | |
|             'menu_type' => 'trainer'
 | |
|         ],
 | |
|         
 | |
|         // Public pages (no navigation)
 | |
|         'community-login' => [
 | |
|             'render_method' => 'shortcode',
 | |
|             'content_source' => '[hvac_community_login]',
 | |
|             'show_navigation' => false,
 | |
|             'show_breadcrumbs' => false
 | |
|         ],
 | |
|         'trainer/registration' => [
 | |
|             'render_method' => 'shortcode',
 | |
|             'content_source' => '[hvac_trainer_registration]',
 | |
|             'show_navigation' => false,
 | |
|             'show_breadcrumbs' => false
 | |
|         ],
 | |
|         'registration-pending' => [
 | |
|             'render_method' => 'template_part',
 | |
|             'content_source' => 'templates/content/registration-pending',
 | |
|             'show_navigation' => false,
 | |
|             'show_breadcrumbs' => false
 | |
|         ]
 | |
|     ];
 | |
|     
 | |
|     /**
 | |
|      * Get page configuration for a given slug
 | |
|      * 
 | |
|      * @param string $page_slug
 | |
|      * @return array
 | |
|      */
 | |
|     public static function get_page_config($page_slug) {
 | |
|         // Normalize slug
 | |
|         $page_slug = trim($page_slug, '/');
 | |
|         
 | |
|         // Check direct match first
 | |
|         if (isset(self::$page_configs[$page_slug])) {
 | |
|             return self::$page_configs[$page_slug];
 | |
|         }
 | |
|         
 | |
|         // Check for pattern matches
 | |
|         foreach (self::$page_configs as $pattern => $config) {
 | |
|             if (self::slug_matches_pattern($page_slug, $pattern)) {
 | |
|                 return $config;
 | |
|             }
 | |
|         }
 | |
|         
 | |
|         // Default configuration for unknown pages
 | |
|         return [
 | |
|             'render_method' => 'shortcode',
 | |
|             'content_source' => '[hvac_' . str_replace(['/', '-'], '_', $page_slug) . ']',
 | |
|             'show_navigation' => true,
 | |
|             'show_breadcrumbs' => true,
 | |
|             'menu_type' => 'trainer'
 | |
|         ];
 | |
|     }
 | |
|     
 | |
|     /**
 | |
|      * Check if a slug matches a pattern
 | |
|      * 
 | |
|      * @param string $slug
 | |
|      * @param string $pattern
 | |
|      * @return bool
 | |
|      */
 | |
|     private static function slug_matches_pattern($slug, $pattern) {
 | |
|         // Convert pattern to regex (basic implementation)
 | |
|         $regex = str_replace(['*', '/'], ['[^/]*', '\/'], $pattern);
 | |
|         $regex = '/^' . $regex . '$/';
 | |
|         
 | |
|         return preg_match($regex, $slug);
 | |
|     }
 | |
|     
 | |
|     /**
 | |
|      * Register additional page configuration
 | |
|      * 
 | |
|      * @param string $slug
 | |
|      * @param array $config
 | |
|      */
 | |
|     public static function register_page_config($slug, $config) {
 | |
|         self::$page_configs[$slug] = $config;
 | |
|     }
 | |
|     
 | |
|     /**
 | |
|      * Get all registered page configurations
 | |
|      * 
 | |
|      * @return array
 | |
|      */
 | |
|     public static function get_all_configs() {
 | |
|         return self::$page_configs;
 | |
|     }
 | |
|     
 | |
|     /**
 | |
|      * Check if a page can use the base template
 | |
|      * 
 | |
|      * @param string $page_slug
 | |
|      * @return bool
 | |
|      */
 | |
|     public static function can_use_base_template($page_slug) {
 | |
|         $config = self::get_page_config($page_slug);
 | |
|         
 | |
|         // Complex pages that need their own templates
 | |
|         $complex_pages = [
 | |
|             'trainer/dashboard',
 | |
|             'master-trainer/master-dashboard',
 | |
|             'trainer/profile',
 | |
|             'trainer/account-pending',
 | |
|             'trainer/account-disabled',
 | |
|             'trainer/event/edit',
 | |
|             'trainer/event/create'
 | |
|         ];
 | |
|         
 | |
|         return !in_array($page_slug, $complex_pages);
 | |
|     }
 | |
| } |