- Add comprehensive Training Leads system for HVAC trainers * New /trainer/training-leads/ page with tabular contact submission display * HVAC_Training_Leads class with AJAX status updates and filtering * Empty state messaging and profile sharing CTA * Database integration with existing contact forms system - Restructure trainer navigation menu for better UX * Rename "Customize" to "Profile" with logical groupings * Move "Logout" under "Profile" submenu * Change "Personal Profile" to "Trainer Profile" * Add "Training Leads" under Profile section * Update help menu to show only question mark icon positioned far right - Enhance documentation system * Fix /trainer/documentation/ page styling and navigation integration * Update content to reflect current platform features * Add Training Leads documentation and navigation guide * Implement proper WordPress template structure - Update user management * Change joe@upskillhvac.com display name to "Joe Medosch" * Assign Joe as author of measureQuick headquarters venue * Assign Joe as author of measureQuick and Upskill HVAC organizers 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
		
			
				
	
	
		
			313 lines
		
	
	
		
			No EOL
		
	
	
		
			9.8 KiB
		
	
	
	
		
			PHP
		
	
	
	
	
	
			
		
		
	
	
			313 lines
		
	
	
		
			No EOL
		
	
	
		
			9.8 KiB
		
	
	
	
		
			PHP
		
	
	
	
	
	
| <?php
 | |
| /**
 | |
|  * HVAC Menu System
 | |
|  * 
 | |
|  * Implements proper WordPress menu API for HVAC trainer pages
 | |
|  * Following WordPress best practices for menu registration and display
 | |
|  *
 | |
|  * @package HVAC_Community_Events
 | |
|  * @since 2.0.0
 | |
|  */
 | |
| 
 | |
| if (!defined('ABSPATH')) {
 | |
|     exit;
 | |
| }
 | |
| 
 | |
| class HVAC_Menu_System {
 | |
|     
 | |
|     /**
 | |
|      * Plugin instance
 | |
|      * 
 | |
|      * @var HVAC_Menu_System
 | |
|      */
 | |
|     private static $instance = null;
 | |
|     
 | |
|     /**
 | |
|      * Get plugin instance
 | |
|      * 
 | |
|      * @return HVAC_Menu_System
 | |
|      */
 | |
|     public static function instance() {
 | |
|         if (null === self::$instance) {
 | |
|             self::$instance = new self();
 | |
|         }
 | |
|         return self::$instance;
 | |
|     }
 | |
|     
 | |
|     /**
 | |
|      * Constructor
 | |
|      */
 | |
|     public function __construct() {
 | |
|         add_action('init', array($this, 'register_menu_locations'));
 | |
|         add_action('wp', array($this, 'setup_trainer_menu'));
 | |
|         add_action('wp_enqueue_scripts', array($this, 'enqueue_menu_styles'));
 | |
|         add_filter('wp_nav_menu_items', array($this, 'add_logout_to_menu'), 10, 2);
 | |
|     }
 | |
|     
 | |
|     /**
 | |
|      * Register menu locations
 | |
|      */
 | |
|     public function register_menu_locations() {
 | |
|         register_nav_menus(array(
 | |
|             'hvac_trainer_menu' => __('HVAC Trainer Navigation', 'hvac-community-events'),
 | |
|         ));
 | |
|     }
 | |
|     
 | |
|     /**
 | |
|      * Setup trainer menu on appropriate pages
 | |
|      */
 | |
|     public function setup_trainer_menu() {
 | |
|         // Menu will be rendered directly in templates, not injected via JavaScript
 | |
|     }
 | |
|     
 | |
|     /**
 | |
|      * Check if current page is a trainer page
 | |
|      */
 | |
|     private function is_trainer_page() {
 | |
|         global $wp;
 | |
|         $current_url = home_url(add_query_arg(array(), $wp->request));
 | |
|         return (strpos($current_url, '/trainer/') !== false || strpos($current_url, '/master-trainer/') !== false);
 | |
|     }
 | |
|     
 | |
|     /**
 | |
|      * Check if user can access trainer area
 | |
|      */
 | |
|     private function user_can_access_trainer_area() {
 | |
|         if (!is_user_logged_in()) {
 | |
|             return false;
 | |
|         }
 | |
|         
 | |
|         return current_user_can('hvac_trainer') || 
 | |
|                current_user_can('hvac_master_trainer') || 
 | |
|                current_user_can('manage_options');
 | |
|     }
 | |
|     
 | |
|     /**
 | |
|      * Render the trainer menu
 | |
|      */
 | |
|     public function render_trainer_menu() {
 | |
|         if (!$this->user_can_access_trainer_area()) {
 | |
|             return;
 | |
|         }
 | |
|         
 | |
|         // Check if we're already showing a navigation menu
 | |
|         if (defined('HVAC_NAV_RENDERED') && HVAC_NAV_RENDERED) {
 | |
|             return;
 | |
|         }
 | |
|         
 | |
|         // Mark that navigation has been rendered
 | |
|         define('HVAC_NAV_RENDERED', true);
 | |
|         
 | |
|         $menu_items = $this->get_menu_structure();
 | |
|         
 | |
|         echo '<div class="hvac-trainer-menu-wrapper">';
 | |
|         echo '<nav class="hvac-trainer-nav" role="navigation">';
 | |
|         echo '<ul class="hvac-trainer-menu">';
 | |
|         
 | |
|         foreach ($menu_items as $item) {
 | |
|             $this->render_menu_item($item);
 | |
|         }
 | |
|         
 | |
|         echo '</ul>';
 | |
|         echo '</nav>';
 | |
|         echo '</div>';
 | |
|     }
 | |
|     
 | |
|     /**
 | |
|      * Get menu structure based on user capabilities
 | |
|      */
 | |
|     private function get_menu_structure() {
 | |
|         $user = wp_get_current_user();
 | |
|         $is_master = in_array('hvac_master_trainer', $user->roles) || current_user_can('manage_options');
 | |
|         
 | |
|         $menu = array();
 | |
|         
 | |
|         // Add Master Dashboard conditionally (only if user has master trainer role)
 | |
|         if ($is_master) {
 | |
|             $menu[] = array(
 | |
|                 'title' => 'Master Dashboard',
 | |
|                 'url' => home_url('/master-trainer/master-dashboard/'),
 | |
|                 'icon' => 'dashicons-star-filled'
 | |
|             );
 | |
|         }
 | |
|         
 | |
|         // Events section
 | |
|         $menu[] = array(
 | |
|             'title' => 'Events',
 | |
|             'url' => '#',
 | |
|             'icon' => 'dashicons-calendar-alt',
 | |
|             'children' => array(
 | |
|                 array(
 | |
|                     'title' => 'Dashboard',
 | |
|                     'url' => home_url('/trainer/dashboard/'),
 | |
|                     'icon' => 'dashicons-dashboard'
 | |
|                 ),
 | |
|                 array(
 | |
|                     'title' => 'New Event',
 | |
|                     'url' => home_url('/trainer/event/manage/'),
 | |
|                     'icon' => 'dashicons-plus-alt'
 | |
|                 )
 | |
|             )
 | |
|         );
 | |
|         
 | |
|         // Certificates section
 | |
|         $menu[] = array(
 | |
|             'title' => 'Certificates',
 | |
|             'url' => '#',
 | |
|             'icon' => 'dashicons-awards',
 | |
|             'children' => array(
 | |
|                 array(
 | |
|                     'title' => 'Reports',
 | |
|                     'url' => home_url('/trainer/certificate-reports/'),
 | |
|                     'icon' => 'dashicons-analytics'
 | |
|                 ),
 | |
|                 array(
 | |
|                     'title' => 'New Certificate',
 | |
|                     'url' => home_url('/trainer/generate-certificates/'),
 | |
|                     'icon' => 'dashicons-plus-alt'
 | |
|                 )
 | |
|             )
 | |
|         );
 | |
|         
 | |
|         // Profile section (previously Customize)
 | |
|         $menu[] = array(
 | |
|             'title' => 'Profile',
 | |
|             'url' => '#',
 | |
|             'icon' => 'dashicons-admin-users',
 | |
|             'children' => array(
 | |
|                 array(
 | |
|                     'title' => 'Trainer Profile',
 | |
|                     'url' => home_url('/trainer/profile/'),
 | |
|                     'icon' => 'dashicons-admin-users'
 | |
|                 ),
 | |
|                 array(
 | |
|                     'title' => 'Training Leads',
 | |
|                     'url' => home_url('/trainer/training-leads/'),
 | |
|                     'icon' => 'dashicons-email-alt'
 | |
|                 ),
 | |
|                 array(
 | |
|                     'title' => 'Training Organizers',
 | |
|                     'url' => home_url('/trainer/organizer/list/'),
 | |
|                     'icon' => 'dashicons-groups',
 | |
|                     'children' => array(
 | |
|                         array(
 | |
|                             'title' => 'Add New Organizer',
 | |
|                             'url' => home_url('/trainer/organizer/manage/'),
 | |
|                             'icon' => 'dashicons-plus-alt'
 | |
|                         )
 | |
|                     )
 | |
|                 ),
 | |
|                 array(
 | |
|                     'title' => 'Training Venues',
 | |
|                     'url' => home_url('/trainer/venue/list/'),
 | |
|                     'icon' => 'dashicons-location-alt',
 | |
|                     'children' => array(
 | |
|                         array(
 | |
|                             'title' => 'Add New Venue',
 | |
|                             'url' => home_url('/trainer/venue/manage/'),
 | |
|                             'icon' => 'dashicons-plus-alt'
 | |
|                         )
 | |
|                     )
 | |
|                 ),
 | |
|                 array(
 | |
|                     'title' => 'Logout',
 | |
|                     'url' => wp_logout_url(home_url('/training-login/')),
 | |
|                     'icon' => 'dashicons-exit'
 | |
|                 )
 | |
|             )
 | |
|         );
 | |
|         
 | |
|         // Help section (moved to end, with question mark icon)
 | |
|         $menu[] = array(
 | |
|             'title' => '?',
 | |
|             'url' => home_url('/trainer/documentation/'),
 | |
|             'icon' => 'dashicons-editor-help',
 | |
|             'class' => 'hvac-help-menu-item'
 | |
|         );
 | |
|         
 | |
|         return $menu;
 | |
|     }
 | |
|     
 | |
|     
 | |
|     /**
 | |
|      * Render individual menu item
 | |
|      */
 | |
|     private function render_menu_item($item, $level = 0) {
 | |
|         $has_children = !empty($item['children']);
 | |
|         $icon = !empty($item['icon']) ? '<span class="dashicons ' . esc_attr($item['icon']) . '"></span>' : '';
 | |
|         $classes = array('menu-item');
 | |
|         
 | |
|         if ($has_children) {
 | |
|             $classes[] = 'has-children';
 | |
|         }
 | |
|         
 | |
|         if ($level > 0) {
 | |
|             $classes[] = 'sub-menu-item';
 | |
|             $classes[] = 'level-' . $level;
 | |
|         }
 | |
|         
 | |
|         // Add custom class if specified
 | |
|         if (!empty($item['class'])) {
 | |
|             $classes[] = esc_attr($item['class']);
 | |
|         }
 | |
|         
 | |
|         echo '<li class="' . implode(' ', $classes) . '">';
 | |
|         
 | |
|         // Check if this is the help menu item (show only icon)
 | |
|         $is_help_menu = !empty($item['class']) && strpos($item['class'], 'hvac-help-menu-item') !== false;
 | |
|         $title_content = $is_help_menu ? '' : esc_html($item['title']);
 | |
|         
 | |
|         if ($item['url'] === '#' && $has_children) {
 | |
|             echo '<span class="menu-toggle">' . $icon . $title_content . '<span class="dropdown-arrow">▼</span></span>';
 | |
|         } else {
 | |
|             echo '<a href="' . esc_url($item['url']) . '">' . $icon . $title_content . '</a>';
 | |
|         }
 | |
|         
 | |
|         if ($has_children) {
 | |
|             echo '<ul class="sub-menu">';
 | |
|             foreach ($item['children'] as $child) {
 | |
|                 $this->render_menu_item($child, $level + 1);
 | |
|             }
 | |
|             echo '</ul>';
 | |
|         }
 | |
|         
 | |
|         echo '</li>';
 | |
|     }
 | |
|     
 | |
|     /**
 | |
|      * Enqueue menu styles and scripts
 | |
|      */
 | |
|     public function enqueue_menu_styles() {
 | |
|         if ($this->is_trainer_page() && $this->user_can_access_trainer_area()) {
 | |
|             wp_enqueue_style(
 | |
|                 'hvac-menu-system',
 | |
|                 HVAC_PLUGIN_URL . 'assets/css/hvac-menu-system.css',
 | |
|                 array(),
 | |
|                 HVAC_PLUGIN_VERSION
 | |
|             );
 | |
|             
 | |
|             wp_enqueue_script(
 | |
|                 'hvac-menu-system',
 | |
|                 HVAC_PLUGIN_URL . 'assets/js/hvac-menu-system.js',
 | |
|                 array('jquery'),
 | |
|                 HVAC_PLUGIN_VERSION,
 | |
|                 true
 | |
|             );
 | |
|         }
 | |
|     }
 | |
|     
 | |
|     /**
 | |
|      * Add logout link to WordPress menu (if using wp_nav_menu)
 | |
|      */
 | |
|     public function add_logout_to_menu($items, $args) {
 | |
|         if ($args->theme_location === 'hvac_trainer_menu' && $this->user_can_access_trainer_area()) {
 | |
|             $logout_link = '<li class="menu-item menu-item-logout"><a href="' . wp_logout_url(home_url('/training-login/')) . '"><span class="dashicons dashicons-exit"></span>Logout</a></li>';
 | |
|             $items .= $logout_link;
 | |
|         }
 | |
|         
 | |
|         return $items;
 | |
|     }
 | |
| }
 | |
| 
 | |
| // Initialize
 | |
| HVAC_Menu_System::instance(); |