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
This commit is contained in:
parent
bf9a2125a3
commit
797ec10771
3 changed files with 99 additions and 14 deletions
41
wordpress-dev/tests/e2e/test-manage-event-page.test.ts
Normal file
41
wordpress-dev/tests/e2e/test-manage-event-page.test.ts
Normal file
|
|
@ -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);
|
||||
}
|
||||
});
|
||||
});
|
||||
|
|
@ -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();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -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 = '<div class="hvac-notice">
|
||||
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 = '<div class="hvac-notice hvac-error">
|
||||
<p><strong>Event Submission Form Unavailable</strong></p>
|
||||
<p>The event submission form is currently unavailable. Please ensure:</p>
|
||||
<ul>
|
||||
<li>The Events Calendar plugin is active</li>
|
||||
|
|
@ -50,10 +68,23 @@ class HVAC_Manage_Event {
|
|||
<li>You are logged in as a trainer</li>
|
||||
</ul>
|
||||
<p><a href="' . esc_url(home_url('/hvac-dashboard/')) . '" class="button">Return to Dashboard</a></p>
|
||||
</div>';
|
||||
</div>
|
||||
<style>
|
||||
.hvac-notice.hvac-error {
|
||||
background: #f8d7da;
|
||||
border: 1px solid #f5c6cb;
|
||||
color: #721c24;
|
||||
padding: 20px;
|
||||
margin: 20px 0;
|
||||
border-radius: 4px;
|
||||
}
|
||||
.hvac-notice.hvac-error ul {
|
||||
margin: 15px 0 15px 30px;
|
||||
}
|
||||
</style>';
|
||||
}
|
||||
|
||||
return $content;
|
||||
return $processed_content;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -67,7 +98,4 @@ class HVAC_Manage_Event {
|
|||
exit;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Initialize the manage event handler
|
||||
new HVAC_Manage_Event();
|
||||
}
|
||||
Loading…
Reference in a new issue