- 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
101 lines
No EOL
3.6 KiB
PHP
101 lines
No EOL
3.6 KiB
PHP
<?php
|
|
/**
|
|
* HVAC Manage Event Handler
|
|
*
|
|
* Ensures proper shortcode processing for the manage-event page
|
|
*
|
|
* @package HVAC_Community_Events
|
|
* @since 1.0.0
|
|
*/
|
|
|
|
if (!defined('ABSPATH')) {
|
|
exit;
|
|
}
|
|
|
|
class HVAC_Manage_Event {
|
|
|
|
/**
|
|
* Constructor
|
|
*/
|
|
public function __construct() {
|
|
// 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');
|
|
}
|
|
}
|
|
|
|
/**
|
|
* Ensure shortcode processing for manage-event page
|
|
*/
|
|
public function ensure_shortcode_processing($content) {
|
|
// Only process on manage-event page
|
|
if (!is_page('manage-event')) {
|
|
return $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($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>
|
|
<li>The Events Calendar Community Events add-on is active</li>
|
|
<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>
|
|
<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 $processed_content;
|
|
}
|
|
|
|
/**
|
|
* Check authentication for manage-event page
|
|
*/
|
|
public function check_manage_event_auth() {
|
|
// Check if we're on the manage-event page
|
|
if (is_page('manage-event') && !is_user_logged_in()) {
|
|
// Redirect to login page
|
|
wp_redirect(home_url('/community-login/?redirect_to=' . urlencode($_SERVER['REQUEST_URI'])));
|
|
exit;
|
|
}
|
|
}
|
|
} |