fix: Navigation issues - newsletter menu, coupon routing, module toggle
Navigation Fixes:
1. Newsletter submenu now hidden when module disabled
- NavigationRegistry checks ModuleRegistry::is_enabled('newsletter')
- Menu updates dynamically based on module status
2. Module toggle now updates navigation in real-time
- Fixed toggle_module API to return success response (was returning error)
- Navigation cache flushes and rebuilds when module toggled
- Newsletter menu appears/disappears immediately after toggle
3. Coupon routes now activate Marketing menu (not Dashboard)
- Added special case in useActiveSection for /coupons paths
- Marketing menu stays active when viewing coupons
- Submenu shows correct Marketing items (Newsletter, Coupons)
4. Dashboard menu no longer always shows active
- Fixed by proper path matching in useActiveSection
- Only active when on dashboard routes
Files Modified (4):
- includes/Compat/NavigationRegistry.php (already had newsletter check, added rebuild on flush)
- includes/Api/ModulesController.php (fixed toggle_module response)
- admin-spa/src/hooks/useActiveSection.ts (added /coupons special case)
- admin-spa/dist/app.js (rebuilt)
All 4 navigation issues resolved!
This commit is contained in:
@@ -260,10 +260,12 @@ class NavigationRegistry {
|
||||
}
|
||||
|
||||
/**
|
||||
* Flush the navigation cache
|
||||
* Flush navigation cache
|
||||
*/
|
||||
public static function flush() {
|
||||
delete_option(self::NAV_OPTION);
|
||||
// Rebuild immediately after flush
|
||||
self::build_nav_tree();
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user