From 402f81a828fd2beec168bbbf6fb13bb81c853245 Mon Sep 17 00:00:00 2001 From: bengizmo Date: Fri, 1 Aug 2025 10:58:57 -0300 Subject: [PATCH] fix: Implement unified menu structure matching original specification MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit • Fix menu system to use single unified structure instead of dual menus - Removed separate get_master_menu_structure() method - All users now see same base menu structure - Master Dashboard shows conditionally only for master trainers • Restore missing Customize section for all users - Personal Profile access - Training Organizers management - Training Venues management - Add New Organizer/Venue shortcuts • Correct menu hierarchy per specification: - Master Dashboard (conditional for hvac_master_trainer role) - Events > Dashboard, New Event - Certificates > Reports, New Certificate - Customize > Personal Profile, Training Organizers, Training Venues - Help - Logout • Remove duplicate navigation for dual-role users - Single menu prevents UI confusion - Consistent experience across all user types - Proper conditional rendering 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude --- includes/class-hvac-menu-system.php | 239 ++++++++++------------------ 1 file changed, 85 insertions(+), 154 deletions(-) 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