docs: update documentation with dashboard fixes and improvements
- Added troubleshooting section for dashboard access issues - Documented role-based checking vs capability checks - Added dashboard performance caching information - Updated API reference with HVAC_Dashboard_Data class methods - Documented caching durations for all dashboard statistics - Added clear_cache() method documentation - Updated changelog with all dashboard fixes from 2025-08-21
This commit is contained in:
parent
8be49ad5a9
commit
201e507b14
2 changed files with 100 additions and 1 deletions
|
|
@ -115,6 +115,63 @@ class HVAC_Trainer_Profile {
|
|||
}
|
||||
```
|
||||
|
||||
### HVAC_Dashboard_Data
|
||||
|
||||
Handles dashboard data retrieval with caching support.
|
||||
|
||||
```php
|
||||
class HVAC_Dashboard_Data {
|
||||
/**
|
||||
* Constructor
|
||||
* @param int $user_id Trainer user ID
|
||||
*/
|
||||
public function __construct($user_id)
|
||||
|
||||
/**
|
||||
* Get total events count (cached 1 hour)
|
||||
* @return int Event count
|
||||
*/
|
||||
public function get_total_events_count()
|
||||
|
||||
/**
|
||||
* Get upcoming events count (cached 15 minutes)
|
||||
* @return int Event count
|
||||
*/
|
||||
public function get_upcoming_events_count()
|
||||
|
||||
/**
|
||||
* Get past events count (cached 1 hour)
|
||||
* @return int Event count
|
||||
*/
|
||||
public function get_past_events_count()
|
||||
|
||||
/**
|
||||
* Get total tickets sold (cached 30 minutes)
|
||||
* @return int Ticket count
|
||||
*/
|
||||
public function get_total_tickets_sold()
|
||||
|
||||
/**
|
||||
* Get total revenue (cached 30 minutes)
|
||||
* @return float Revenue amount
|
||||
*/
|
||||
public function get_total_revenue()
|
||||
|
||||
/**
|
||||
* Clear all cached data for this user
|
||||
* @return void
|
||||
*/
|
||||
public function clear_cache()
|
||||
|
||||
/**
|
||||
* Get paginated events table data
|
||||
* @param array $args Query arguments
|
||||
* @return array Events and pagination data
|
||||
*/
|
||||
public function get_events_table_data($args)
|
||||
}
|
||||
```
|
||||
|
||||
### HVAC_Menu_System
|
||||
|
||||
Handles navigation menu rendering.
|
||||
|
|
|
|||
|
|
@ -12,7 +12,49 @@
|
|||
|
||||
## Common Issues
|
||||
|
||||
### 1. Pages Not Found (404 Errors)
|
||||
### 1. Dashboard Access and Functionality Issues
|
||||
|
||||
#### Incorrect Capability Checks
|
||||
**Symptoms:**
|
||||
- "Access Denied" errors for valid trainers
|
||||
- Users with correct roles can't access dashboard
|
||||
|
||||
**Root Cause:**
|
||||
- Using capability checks instead of role checks for custom roles
|
||||
|
||||
**Solution:**
|
||||
```php
|
||||
// CORRECT - Check user roles directly
|
||||
$user = wp_get_current_user();
|
||||
$has_trainer_role = in_array('hvac_trainer', $user->roles) ||
|
||||
in_array('hvac_master_trainer', $user->roles);
|
||||
|
||||
// WRONG - Custom roles are not capabilities!
|
||||
if (current_user_can('hvac_trainer')) // This won't work!
|
||||
```
|
||||
|
||||
#### Dashboard Dropdown Menus Not Working
|
||||
**Symptoms:**
|
||||
- Dropdown menus don't open on click
|
||||
- Navigation appears but isn't interactive
|
||||
|
||||
**Root Causes & Solutions:**
|
||||
1. **Welcome Popup Interference**: Z-index conflicts blocking clicks
|
||||
- Solution: Disable welcome popup or fix z-index layering
|
||||
2. **JavaScript Loading Issues**: Check browser console for errors
|
||||
3. **Cache Issues**: Clear all caches after deployment
|
||||
|
||||
#### Dashboard Performance Issues
|
||||
**Symptoms:**
|
||||
- Slow loading statistics
|
||||
- Database query timeouts
|
||||
|
||||
**Solution (Implemented August 2025):**
|
||||
- Added WordPress object caching to all dashboard queries
|
||||
- Cache duration: 1 hour for stats, 15-30 minutes for time-sensitive data
|
||||
- Clear cache manually: `wp_cache_delete('hvac_dashboard_*', 'hvac_dashboard')`
|
||||
|
||||
### 2. Pages Not Found (404 Errors)
|
||||
|
||||
**Symptoms:**
|
||||
- Trainer pages return 404
|
||||
|
|
|
|||
Loading…
Reference in a new issue