From 797ec10771e716f85697990d0c6d57f69fe62d28 Mon Sep 17 00:00:00 2001 From: bengizmo Date: Fri, 30 May 2025 10:59:33 -0600 Subject: [PATCH] fix: Fix manage-event page shortcode rendering - Move HVAC_Manage_Event initialization to proper init() method - Fix help system initialization (use singleton pattern) - Add help system to includes list - Page now properly processes [tribe_community_events] shortcode - Shows helpful error when TEC Community Events is inactive --- .../tests/e2e/test-manage-event-page.test.ts | 41 ++++++++++++++ .../includes/class-hvac-community-events.php | 16 ++++++ .../includes/class-hvac-manage-event.php | 56 ++++++++++++++----- 3 files changed, 99 insertions(+), 14 deletions(-) create mode 100644 wordpress-dev/tests/e2e/test-manage-event-page.test.ts diff --git a/wordpress-dev/tests/e2e/test-manage-event-page.test.ts b/wordpress-dev/tests/e2e/test-manage-event-page.test.ts new file mode 100644 index 00000000..590ecde7 --- /dev/null +++ b/wordpress-dev/tests/e2e/test-manage-event-page.test.ts @@ -0,0 +1,41 @@ +import { test, expect } from './fixtures/auth'; +import { CommonActions } from './utils/common-actions'; + +test.describe('Manage Event Page', () => { + test('Shortcode is rendered on manage-event page', async ({ authenticatedPage: page }) => { + test.setTimeout(30000); + const actions = new CommonActions(page); + + // Navigate directly to manage-event page + await actions.navigateAndWait('/manage-event/'); + + // Take a screenshot to see what's rendered + await actions.screenshot('manage-event-page'); + + // Check that the shortcode is not visible as raw text + const pageContent = await page.locator('body').textContent(); + console.log('Page content:', pageContent?.substring(0, 500)); + + // The raw shortcode should NOT be visible + expect(pageContent).not.toContain('[tribe_community_events'); + + // Check for either the form or error message + const hasForm = await page.locator('#tribe-community-events').count() > 0; + const hasErrorMessage = await page.locator('.hvac-notice.hvac-error').count() > 0; + + if (hasForm) { + console.log('✓ Event submission form is rendered'); + expect(hasForm).toBeTruthy(); + } else if (hasErrorMessage) { + console.log('✓ Error message is displayed (TEC plugin may be inactive)'); + const errorText = await page.locator('.hvac-notice.hvac-error').textContent(); + console.log('Error message:', errorText); + expect(hasErrorMessage).toBeTruthy(); + } else { + console.log('✗ Neither form nor error message found'); + // Log what we actually see + const mainContent = await page.locator('.entry-content, .site-main, main').first().innerHTML(); + console.log('Main content HTML:', mainContent); + } + }); +}); \ No newline at end of file diff --git a/wordpress-dev/wordpress/wp-content/plugins/hvac-community-events/includes/class-hvac-community-events.php b/wordpress-dev/wordpress/wp-content/plugins/hvac-community-events/includes/class-hvac-community-events.php index 0a8881d3..935a130d 100644 --- a/wordpress-dev/wordpress/wp-content/plugins/hvac-community-events/includes/class-hvac-community-events.php +++ b/wordpress-dev/wordpress/wp-content/plugins/hvac-community-events/includes/class-hvac-community-events.php @@ -59,6 +59,7 @@ class HVAC_Community_Events { 'class-event-author-fixer.php', // Fix event author assignment 'class-hvac-dashboard.php', // New dashboard handler 'class-hvac-manage-event.php', // Manage event page handler + 'class-hvac-help-system.php', // Help system for tooltips and documentation 'certificates/class-certificate-installer.php', // Certificate database installer 'certificates/class-certificate-manager.php', // Certificate management 'certificates/class-certificate-generator.php', // Certificate generation @@ -226,6 +227,21 @@ class HVAC_Community_Events { if (class_exists('HVAC_Community_Events\Event_Form_Handler')) { new \HVAC_Community_Events\Event_Form_Handler(); } + + // Initialize manage event handler + if (class_exists('HVAC_Manage_Event')) { + new HVAC_Manage_Event(); + } + + // Initialize dashboard handler + if (class_exists('HVAC_Dashboard')) { + new HVAC_Dashboard(); + } + + // Initialize help system (singleton) + if (class_exists('HVAC_Help_System')) { + HVAC_Help_System::instance(); + } } /** diff --git a/wordpress-dev/wordpress/wp-content/plugins/hvac-community-events/includes/class-hvac-manage-event.php b/wordpress-dev/wordpress/wp-content/plugins/hvac-community-events/includes/class-hvac-manage-event.php index 4a4fb5d3..ef41725a 100644 --- a/wordpress-dev/wordpress/wp-content/plugins/hvac-community-events/includes/class-hvac-manage-event.php +++ b/wordpress-dev/wordpress/wp-content/plugins/hvac-community-events/includes/class-hvac-manage-event.php @@ -18,11 +18,16 @@ class HVAC_Manage_Event { * Constructor */ public function __construct() { - // Hook into content filter with high priority to ensure shortcode processing - add_filter('the_content', array($this, 'ensure_shortcode_processing'), 1); + // Hook into content filter with low priority (99) to run after other filters + add_filter('the_content', array($this, 'ensure_shortcode_processing'), 99); // Add authentication check for manage-event page add_action('template_redirect', array($this, 'check_manage_event_auth')); + + // Debug: Log when this class is instantiated + if (defined('HVAC_CE_PLUGIN_DIR') && class_exists('HVAC_Logger')) { + HVAC_Logger::info('HVAC_Manage_Event class instantiated', 'ManageEvent'); + } } /** @@ -34,15 +39,28 @@ class HVAC_Manage_Event { return $content; } - // Check if content contains the tribe_community_events shortcode - if (has_shortcode($content, 'tribe_community_events')) { - // Process shortcodes explicitly - $content = do_shortcode($content); + // Debug logging + if (class_exists('HVAC_Logger')) { + HVAC_Logger::info('Processing manage-event page content', 'ManageEvent'); + HVAC_Logger::info('Original content: ' . substr($content, 0, 200), 'ManageEvent'); + } + + // Process all shortcodes in the content + $processed_content = do_shortcode($content); + + // Debug: Log if content changed + if (class_exists('HVAC_Logger') && $processed_content !== $content) { + HVAC_Logger::info('Content was processed by do_shortcode', 'ManageEvent'); } // If shortcode wasn't processed (plugin might be inactive), show helpful message - if (strpos($content, '[tribe_community_events') !== false) { - $content = '
+ if (strpos($processed_content, '[tribe_community_events') !== false) { + if (class_exists('HVAC_Logger')) { + HVAC_Logger::warning('tribe_community_events shortcode not processed - plugin may be inactive', 'ManageEvent'); + } + + $processed_content = '
+

Event Submission Form Unavailable

The event submission form is currently unavailable. Please ensure:

  • The Events Calendar plugin is active
  • @@ -50,10 +68,23 @@ class HVAC_Manage_Event {
  • You are logged in as a trainer

Return to Dashboard

-
'; +
+ '; } - return $content; + return $processed_content; } /** @@ -67,7 +98,4 @@ class HVAC_Manage_Event { exit; } } -} - -// Initialize the manage event handler -new HVAC_Manage_Event(); \ No newline at end of file +} \ No newline at end of file