## Major Enhancements ### 🏗️ Architecture & Infrastructure - Implement comprehensive Docker testing infrastructure with hermetic environment - Add Forgejo Actions CI/CD pipeline for automated deployments - Create Page Object Model (POM) testing architecture reducing test duplication by 90% - Establish security-first development patterns with input validation and output escaping ### 🧪 Testing Framework Modernization - Migrate 146+ tests from 80 duplicate files to centralized architecture - Add comprehensive E2E test suites for all user roles and workflows - Implement WordPress error detection with automatic site health monitoring - Create robust browser lifecycle management with proper cleanup ### 📚 Documentation & Guides - Add comprehensive development best practices guide - Create detailed administrator setup documentation - Establish user guides for trainers and master trainers - Document security incident reports and migration guides ### 🔧 Core Plugin Features - Enhance trainer profile management with certification system - Improve find trainer functionality with advanced filtering - Strengthen master trainer area with content management - Add comprehensive venue and organizer management ### 🛡️ Security & Reliability - Implement security-first patterns throughout codebase - Add comprehensive input validation and output escaping - Create secure credential management system - Establish proper WordPress role-based access control ### 🎯 WordPress Integration - Strengthen singleton pattern implementation across all classes - Enhance template hierarchy with proper WordPress integration - Improve page manager with hierarchical URL structure - Add comprehensive shortcode and menu system ### 🔍 Developer Experience - Add extensive debugging and troubleshooting tools - Create comprehensive test data seeding scripts - Implement proper error handling and logging - Establish consistent code patterns and standards ### 📊 Performance & Optimization - Optimize database queries and caching strategies - Improve asset loading and script management - Enhance template rendering performance - Streamline user experience across all interfaces 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
259 lines
No EOL
8.4 KiB
PHP
259 lines
No EOL
8.4 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/profile/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);
|
|
}
|
|
} |