diff --git a/includes/class-hvac-menu-system.php b/includes/class-hvac-menu-system.php index c3d8db96..fb50f334 100644 --- a/includes/class-hvac-menu-system.php +++ b/includes/class-hvac-menu-system.php @@ -120,102 +120,101 @@ class HVAC_Menu_System { $user = wp_get_current_user(); $is_master = in_array('hvac_master_trainer', $user->roles) || current_user_can('manage_options'); - // If user has master trainer role, ALWAYS show master menu - // This prevents duplicate navigation for dual-role users + $menu = array(); + + // Add Master Dashboard conditionally (only if user has master trainer role) if ($is_master) { - return $this->get_master_menu_structure(); + $menu[] = array( + 'title' => 'Master Dashboard', + 'url' => home_url('/master-trainer/master-dashboard/'), + 'icon' => 'dashicons-star-filled' + ); } - $menu = array( - 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' - ) + // 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' ) - ), - 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' - ) - ) - ), - array( - 'title' => 'Customize', - 'url' => '#', - 'icon' => 'dashicons-admin-customizer', - 'children' => array( - array( - 'title' => 'Personal Profile', - 'url' => home_url('/trainer/profile/'), - 'icon' => 'dashicons-admin-users' - ), - 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' => 'Help', - 'url' => home_url('/trainer/documentation/'), - 'icon' => 'dashicons-sos' ) ); - // Add Master Dashboard for qualified users - if ($is_master) { - array_splice($menu, 0, 0, array( + // Certificates section + $menu[] = array( + 'title' => 'Certificates', + 'url' => '#', + 'icon' => 'dashicons-awards', + 'children' => array( array( - 'title' => 'Master Dashboard', - 'url' => home_url('/master-trainer/master-dashboard/'), - 'icon' => 'dashicons-star-filled' + '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' ) - )); - } + ) + ); - // Add logout as last item + // Customize section + $menu[] = array( + 'title' => 'Customize', + 'url' => '#', + 'icon' => 'dashicons-admin-customizer', + 'children' => array( + array( + 'title' => 'Personal Profile', + 'url' => home_url('/trainer/profile/'), + 'icon' => 'dashicons-admin-users' + ), + 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' + ) + ) + ) + ) + ); + + // Help section + $menu[] = array( + 'title' => 'Help', + 'url' => home_url('/trainer/documentation/'), + 'icon' => 'dashicons-sos' + ); + + // Logout (always last) $menu[] = array( 'title' => 'Logout', 'url' => wp_logout_url(home_url('/training-login/')), @@ -225,74 +224,6 @@ class HVAC_Menu_System { return $menu; } - /** - * Get master trainer menu structure - */ - private function get_master_menu_structure() { - $menu = array( - array( - 'title' => 'Master Dashboard', - 'url' => home_url('/master-trainer/master-dashboard/'), - 'icon' => 'dashicons-dashboard' - ), - array( - 'title' => 'Trainer Dashboard', - 'url' => home_url('/trainer/dashboard/'), - 'icon' => 'dashicons-admin-home' - ), - array( - 'title' => 'Events', - 'url' => '#', - 'icon' => 'dashicons-calendar-alt', - 'children' => array( - array( - 'title' => 'All Events', - 'url' => home_url('/master-trainer/events/'), - 'icon' => 'dashicons-list-view' - ), - array( - 'title' => 'Create Event', - 'url' => home_url('/trainer/create-event/'), - 'icon' => 'dashicons-plus-alt' - ), - array( - 'title' => 'My Events', - 'url' => home_url('/trainer/dashboard/'), - 'icon' => 'dashicons-calendar' - ) - ) - ), - array( - 'title' => 'Certificates', - 'url' => '#', - 'icon' => 'dashicons-awards', - 'children' => array( - array( - 'title' => 'Certificate Reports', - 'url' => home_url('/trainer/certificate-reports/'), - 'icon' => 'dashicons-analytics' - ), - array( - 'title' => 'Generate Certificates', - 'url' => home_url('/trainer/generate-certificates/'), - 'icon' => 'dashicons-media-document' - ) - ) - ), - array( - 'title' => 'Profile', - 'url' => home_url('/trainer/profile/'), - 'icon' => 'dashicons-admin-users' - ), - array( - 'title' => 'Logout', - 'url' => wp_logout_url(home_url('/training-login/')), - 'icon' => 'dashicons-exit' - ) - ); - - return $menu; - } /** * Render individual menu item