From 3d6675671550e748ac964b6cb8f4778e2d988c33 Mon Sep 17 00:00:00 2001 From: Ben Date: Tue, 6 Jan 2026 11:10:34 -0400 Subject: [PATCH] fix(master-dashboard): Resolve trainers table AJAX loading error MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Initialize HVAC_Master_Dashboard_Data during plugin init to ensure AJAX handler is registered for all requests (not just template loads) - Accept both hvac_ajax_nonce and hvac_master_dashboard_nonce for backward compatibility with existing JavaScript 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 --- includes/class-hvac-master-dashboard-data.php | 13 ++++++++++--- includes/class-hvac-plugin.php | 7 ++++++- 2 files changed, 16 insertions(+), 4 deletions(-) diff --git a/includes/class-hvac-master-dashboard-data.php b/includes/class-hvac-master-dashboard-data.php index 20fb672b..1d43e7b8 100644 --- a/includes/class-hvac-master-dashboard-data.php +++ b/includes/class-hvac-master-dashboard-data.php @@ -850,9 +850,16 @@ class HVAC_Master_Dashboard_Data { * AJAX handler for trainers table */ public function ajax_get_trainers_table() { - // Check nonce - if ( ! isset( $_POST['nonce'] ) || ! wp_verify_nonce( $_POST['nonce'], 'hvac_master_dashboard_nonce' ) ) { - wp_die( 'Security check failed' ); + // Check nonce - accept both hvac_ajax_nonce and hvac_master_dashboard_nonce for compatibility + if ( ! isset( $_POST['nonce'] ) ) { + wp_die( 'Security check failed: No nonce provided' ); + } + + $nonce_valid = wp_verify_nonce( $_POST['nonce'], 'hvac_ajax_nonce' ) || + wp_verify_nonce( $_POST['nonce'], 'hvac_master_dashboard_nonce' ); + + if ( ! $nonce_valid ) { + wp_die( 'Security check failed: Invalid nonce' ); } // Check permissions diff --git a/includes/class-hvac-plugin.php b/includes/class-hvac-plugin.php index c9ba3593..f239050e 100644 --- a/includes/class-hvac-plugin.php +++ b/includes/class-hvac-plugin.php @@ -500,7 +500,12 @@ final class HVAC_Plugin { if (class_exists('HVAC_Access_Control')) { new HVAC_Access_Control(); } - + + // Initialize Master Dashboard Data to register AJAX handlers + if (class_exists('HVAC_Master_Dashboard_Data')) { + new HVAC_Master_Dashboard_Data(); + } + // Initialize optional components $this->initializeOptionalComponents();