From 08944d48ee0f46f25b7101bd876feb9e964a195a Mon Sep 17 00:00:00 2001 From: ben Date: Tue, 16 Dec 2025 15:16:42 -0400 Subject: [PATCH] fix: Resolve console errors on staging MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 1. Created zoho-admin.css (was missing, causing 404) - Added styles for Zoho admin page layout - Card styling, form tables, sync buttons, status messages 2. Fixed jQuery not defined on master-trainer pages - Changed inject_inline_content hook from wp_head to wp_footer - Ensures jQuery is loaded before inline script executes Note: "message channel closed" error is a browser extension issue, not a code problem (typically ad blockers intercepting message passing) 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 --- assets/css/zoho-admin.css | 168 ++++++++++++++++++ .../class-hvac-master-content-injector.php | 14 +- 2 files changed, 177 insertions(+), 5 deletions(-) create mode 100644 assets/css/zoho-admin.css diff --git a/assets/css/zoho-admin.css b/assets/css/zoho-admin.css new file mode 100644 index 00000000..ea921426 --- /dev/null +++ b/assets/css/zoho-admin.css @@ -0,0 +1,168 @@ +/** + * Zoho CRM Admin Styles + * + * @package HVACCommunityEvents + */ + +/* Card Layout */ +.hvac-zoho-wrap { + max-width: 1200px; +} + +.hvac-zoho-wrap .card { + max-width: 100%; + padding: 20px; + margin-bottom: 20px; +} + +.hvac-zoho-wrap h2 { + margin-top: 0; + padding-bottom: 10px; + border-bottom: 1px solid #ccd0d4; +} + +/* Form Styles */ +.hvac-zoho-wrap table.form-table th { + width: 200px; +} + +.hvac-zoho-wrap .regular-text { + width: 400px; +} + +.hvac-zoho-wrap code { + background: #f0f0f1; + padding: 4px 8px; + border-radius: 3px; + font-size: 13px; +} + +/* Button Groups */ +.hvac-zoho-wrap .button-group { + display: flex; + gap: 10px; + flex-wrap: wrap; + margin-top: 15px; +} + +/* Sync Buttons */ +.hvac-zoho-wrap .sync-button { + min-width: 150px; +} + +/* Status Messages */ +.hvac-zoho-wrap .sync-status { + margin-top: 15px; + padding: 10px; + background: #f8f9fa; + border-left: 4px solid #007cba; +} + +.hvac-zoho-wrap .sync-status.success { + border-left-color: #00a32a; +} + +.hvac-zoho-wrap .sync-status.error { + border-left-color: #d63638; +} + +/* Connection Status */ +#connection-status { + margin-top: 15px; +} + +#connection-status .notice { + margin: 0; +} + +/* Staging Mode Banner */ +.hvac-zoho-wrap .staging-notice { + background: #fff3cd; + border: 1px solid #ffc107; + border-radius: 4px; + padding: 15px; + margin-bottom: 20px; +} + +.hvac-zoho-wrap .staging-notice h3 { + margin: 0 0 10px 0; + color: #856404; +} + +/* Debug Info */ +.hvac-zoho-debug-info { + margin-top: 15px; + padding: 10px; + background: #f0f0f1; + border-radius: 4px; + font-size: 12px; +} + +.hvac-zoho-debug-info details { + margin-top: 10px; +} + +.hvac-zoho-debug-info summary { + cursor: pointer; + color: #007cba; +} + +.hvac-zoho-debug-info pre { + margin: 10px 0 0 0; + white-space: pre-wrap; + word-wrap: break-word; +} + +/* Credentials Form */ +#zoho-credentials-form .description { + color: #646970; + font-style: italic; + margin-top: 5px; +} + +/* Password Toggle */ +#toggle-secret { + margin-left: 10px; + vertical-align: middle; +} + +/* Sync Results */ +.sync-results { + margin-top: 15px; +} + +.sync-results ul { + margin: 10px 0; + padding-left: 20px; +} + +.sync-results details { + margin-top: 10px; +} + +.sync-results pre { + background: #f0f0f1; + padding: 10px; + overflow: auto; + max-height: 300px; + font-size: 12px; +} + +/* Responsive */ +@media screen and (max-width: 782px) { + .hvac-zoho-wrap table.form-table th { + width: auto; + } + + .hvac-zoho-wrap .regular-text { + width: 100%; + } + + .hvac-zoho-wrap .button-group { + flex-direction: column; + } + + .hvac-zoho-wrap .sync-button { + width: 100%; + } +} diff --git a/includes/class-hvac-master-content-injector.php b/includes/class-hvac-master-content-injector.php index 18e20604..1a1c623a 100644 --- a/includes/class-hvac-master-content-injector.php +++ b/includes/class-hvac-master-content-injector.php @@ -66,7 +66,8 @@ class HVAC_Master_Content_Injector { */ private function __construct() { add_filter('the_content', array($this, 'inject_master_content'), 10); - add_action('wp_head', array($this, 'inject_inline_content'), 1); + // Use wp_footer instead of wp_head to ensure jQuery is loaded first + add_action('wp_footer', array($this, 'inject_inline_content'), 20); } /** @@ -220,16 +221,19 @@ class HVAC_Master_Content_Injector { return ''; } - // Try direct method call first + // Try direct method call first - check which method exists if (class_exists($shortcode_data['class'])) { - $instance = call_user_func(array($shortcode_data['class'], 'instance')); - if (!$instance && method_exists($shortcode_data['class'], 'get_instance')) { + $instance = null; + if (method_exists($shortcode_data['class'], 'get_instance')) { $instance = call_user_func(array($shortcode_data['class'], 'get_instance')); + } elseif (method_exists($shortcode_data['class'], 'instance')) { + $instance = call_user_func(array($shortcode_data['class'], 'instance')); } if ($instance && method_exists($instance, $shortcode_data['method'])) { ob_start(); - echo $instance->{$shortcode_data['method']}(); + // Pass empty array to satisfy shortcode callback signature + echo $instance->{$shortcode_data['method']}(array()); return ob_get_clean(); } }