fix: Implement unified menu structure matching original specification
• 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 <noreply@anthropic.com>
This commit is contained in:
parent
40274d98ad
commit
402f81a828
1 changed files with 85 additions and 154 deletions
|
|
@ -120,102 +120,101 @@ class HVAC_Menu_System {
|
||||||
$user = wp_get_current_user();
|
$user = wp_get_current_user();
|
||||||
$is_master = in_array('hvac_master_trainer', $user->roles) || current_user_can('manage_options');
|
$is_master = in_array('hvac_master_trainer', $user->roles) || current_user_can('manage_options');
|
||||||
|
|
||||||
// If user has master trainer role, ALWAYS show master menu
|
$menu = array();
|
||||||
// This prevents duplicate navigation for dual-role users
|
|
||||||
|
// Add Master Dashboard conditionally (only if user has master trainer role)
|
||||||
if ($is_master) {
|
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(
|
// Events section
|
||||||
array(
|
$menu[] = array(
|
||||||
'title' => 'Events',
|
'title' => 'Events',
|
||||||
'url' => '#',
|
'url' => '#',
|
||||||
'icon' => 'dashicons-calendar-alt',
|
'icon' => 'dashicons-calendar-alt',
|
||||||
'children' => array(
|
'children' => array(
|
||||||
array(
|
array(
|
||||||
'title' => 'Dashboard',
|
'title' => 'Dashboard',
|
||||||
'url' => home_url('/trainer/dashboard/'),
|
'url' => home_url('/trainer/dashboard/'),
|
||||||
'icon' => 'dashicons-dashboard'
|
'icon' => 'dashicons-dashboard'
|
||||||
),
|
),
|
||||||
array(
|
array(
|
||||||
'title' => 'New Event',
|
'title' => 'New Event',
|
||||||
'url' => home_url('/trainer/event/manage/'),
|
'url' => home_url('/trainer/event/manage/'),
|
||||||
'icon' => 'dashicons-plus-alt'
|
'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
|
// Certificates section
|
||||||
if ($is_master) {
|
$menu[] = array(
|
||||||
array_splice($menu, 0, 0, array(
|
'title' => 'Certificates',
|
||||||
|
'url' => '#',
|
||||||
|
'icon' => 'dashicons-awards',
|
||||||
|
'children' => array(
|
||||||
array(
|
array(
|
||||||
'title' => 'Master Dashboard',
|
'title' => 'Reports',
|
||||||
'url' => home_url('/master-trainer/master-dashboard/'),
|
'url' => home_url('/trainer/certificate-reports/'),
|
||||||
'icon' => 'dashicons-star-filled'
|
'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(
|
$menu[] = array(
|
||||||
'title' => 'Logout',
|
'title' => 'Logout',
|
||||||
'url' => wp_logout_url(home_url('/training-login/')),
|
'url' => wp_logout_url(home_url('/training-login/')),
|
||||||
|
|
@ -225,74 +224,6 @@ class HVAC_Menu_System {
|
||||||
return $menu;
|
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
|
* Render individual menu item
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue