From 3934b6353ca5f256f2cf855d2d9989717deb4f86 Mon Sep 17 00:00:00 2001 From: bengizmo Date: Fri, 25 Jul 2025 16:54:42 -0300 Subject: [PATCH] fix: Prevent event creation content from appearing on registration page The HVAC_Manage_Event class was using is_page('manage') which was too generic and could match any page with 'manage' in its slug. Changed to check for specific page slugs: 'manage-event' and 'trainer-event-manage' to ensure the event creation content only appears on the actual event management page. This resolves the issue where "Create Your Training Event" content was incorrectly showing on the trainer registration page. Ben Reed --- includes/class-hvac-manage-event.php | 515 +++++++++++++++++++++++++++ 1 file changed, 515 insertions(+) create mode 100644 includes/class-hvac-manage-event.php diff --git a/includes/class-hvac-manage-event.php b/includes/class-hvac-manage-event.php new file mode 100644 index 00000000..c05c112f --- /dev/null +++ b/includes/class-hvac-manage-event.php @@ -0,0 +1,515 @@ +get_navigation_bar(); + + // 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'); + } + + $error_content = '
+

Event Submission Form Unavailable

+

The event submission form is currently unavailable. Please ensure:

+
    +
  • The Events Calendar plugin is active
  • +
  • The Events Calendar Community Events add-on is active
  • +
  • You are logged in as a trainer
  • +
+

Return to Dashboard

+
+ '; + + return $navigation_html . $error_content; + } + + // Wrap the form content with navigation and styling + $final_content = $navigation_html . ' +
+ ' . $processed_content . ' +
+ + '; + + return $final_content; + } + + /** + * Generate the navigation bar HTML + */ + private function get_navigation_bar() { + // Check if Help System is available for tooltips + $help_available = class_exists('HVAC_Help_System'); + + $nav_html = ' +
+

Create Event

+
'; + + // Dashboard link + if ($help_available) { + $nav_html .= HVAC_Help_System::add_tooltip( + 'Dashboard', + 'Return to your main dashboard to view stats and manage events' + ); + } else { + $nav_html .= 'Dashboard'; + } + + // Generate Certificates link + if ($help_available) { + $nav_html .= HVAC_Help_System::add_tooltip( + 'Generate Certificates', + 'Create professional certificates for attendees who completed your training' + ); + } else { + $nav_html .= 'Generate Certificates'; + } + + // Certificate Reports link + if ($help_available) { + $nav_html .= HVAC_Help_System::add_tooltip( + 'Certificate Reports', + 'View and manage all certificates you\'ve issued to attendees' + ); + } else { + $nav_html .= 'Certificate Reports'; + } + + // Trainer Profile link + if ($help_available) { + $nav_html .= HVAC_Help_System::add_tooltip( + 'View Profile', + 'Update your professional credentials, business information, and training specialties' + ); + } else { + $nav_html .= 'View Profile'; + } + + // Help and Logout links + $nav_html .= ' + Help + Logout +
+
+ +
+
+

📝 Create Your Training Event: Fill in the required fields below including event title, dates, and pricing. All fields marked with an asterisk (*) are required for publication.

+

🎯 Event Visibility: Your published events will appear in the main events directory and your trainer dashboard, where attendees can register and make payments.

+

💼 Professional Features: Each event includes automatic attendee management, certificate generation capabilities, and integrated payment processing through PayPal.

+
+
'; + + return $nav_html; + } + + /** + * Inject navigation and styles into the head section for manage page + */ + public function inject_page_content() { + // Check if we're on the manage page using multiple methods + $is_manage_page = false; + + // Method 1: Check by specific slugs + if (is_page('manage-event') || is_page('trainer-event-manage')) { + $is_manage_page = true; + } + + // Method 2: Check by post ID + if (is_page(5334)) { + $is_manage_page = true; + } + + // Method 3: Check by URL path + $current_path = trim(parse_url($_SERVER['REQUEST_URI'], PHP_URL_PATH), '/'); + if ($current_path === 'trainer/event/manage' || $current_path === 'trainer/event/manage/') { + $is_manage_page = true; + } + + if (!$is_manage_page) { + return; + } + + // Generate navigation HTML + $navigation_html = $this->get_navigation_bar(); + + // Escape the HTML for JavaScript + $escaped_nav = json_encode($navigation_html); + + echo ' + + '; + } + + /** + * Check authentication for manage-event page + */ + public function check_manage_event_auth() { + // Check if we're on the manage page using multiple methods + $is_manage_page = false; + + // Method 1: Check by specific slugs + if (is_page('manage-event') || is_page('trainer-event-manage')) { + $is_manage_page = true; + } + + // Method 2: Check by post ID + if (is_page(5334)) { + $is_manage_page = true; + } + + // Method 3: Check by URL path + $current_path = trim(parse_url($_SERVER['REQUEST_URI'], PHP_URL_PATH), '/'); + if ($current_path === 'trainer/event/manage' || $current_path === 'trainer/event/manage/') { + $is_manage_page = true; + } + + // Check if we're on the manage page (event creation page) and not logged in + if ($is_manage_page && !is_user_logged_in()) { + // Redirect to login page + wp_redirect(home_url('/training-login/?redirect_to=' . urlencode($_SERVER['REQUEST_URI']))); + exit; + } + } +} \ No newline at end of file