- Strip WordPress block editor comments (<\!-- wp:shortcode -->) from content - Prevent duplicate header rendering when using page template vs shortcode - Add conditional header rendering based on URL path to avoid duplication - Header now only renders for non-hierarchical URLs where template isn't used The manage event page was showing duplicate "Create and Manage Your HVAC Training Events" sections and raw block editor comments because both the template and the header class were outputting content, and block editor wrapper comments weren't being stripped. Co-Authored-By: Ben Reed <ben@tealmaker.com>
85 lines
No EOL
3.1 KiB
PHP
85 lines
No EOL
3.1 KiB
PHP
<?php
|
|
/**
|
|
* HVAC Event Manage Header
|
|
*
|
|
* @package HVACCommunityEvents
|
|
*/
|
|
|
|
if (!defined('ABSPATH')) {
|
|
exit;
|
|
}
|
|
|
|
/**
|
|
* Class to handle event management page header
|
|
*/
|
|
class HVAC_Event_Manage_Header {
|
|
|
|
/**
|
|
* Constructor
|
|
*/
|
|
public function __construct() {
|
|
// Only use the tribe-specific action to avoid duplication
|
|
// Check if we should render the header based on the context
|
|
add_action('init', array($this, 'maybe_add_header_hook'));
|
|
}
|
|
|
|
/**
|
|
* Conditionally add the header hook
|
|
*/
|
|
public function maybe_add_header_hook() {
|
|
// Check if we're using the page template approach
|
|
// If the page template is being used, it likely already has header content
|
|
$current_path = trim(parse_url($_SERVER['REQUEST_URI'] ?? '', PHP_URL_PATH), '/');
|
|
|
|
// Only add the header for the tribe shortcode, not for our custom page template
|
|
if ($current_path !== 'trainer/event/manage' && $current_path !== 'trainer/event/manage/') {
|
|
add_action('tribe_events_community_before_event_submission_page', array($this, 'render_header'));
|
|
}
|
|
}
|
|
|
|
|
|
/**
|
|
* Render the header
|
|
*/
|
|
public function render_header() {
|
|
echo $this->get_header_html();
|
|
}
|
|
|
|
/**
|
|
* Get the header HTML
|
|
*/
|
|
private function get_header_html() {
|
|
ob_start();
|
|
?>
|
|
<!-- Navigation Header -->
|
|
<div class="hvac-dashboard-header">
|
|
<h1 class="entry-title">Create Event</h1>
|
|
<div class="hvac-dashboard-nav">
|
|
<a href="/trainer/dashboard/" class="ast-button ast-button-secondary">Dashboard</a>
|
|
<a href="/trainer/certificate-reports/" class="ast-button ast-button-secondary">Certificate Reports</a>
|
|
<a href="/trainer/generate-certificates/" class="ast-button ast-button-secondary">Generate Certificates</a>
|
|
<button class="ast-button hvac-help-trigger">Help</button>
|
|
</div>
|
|
</div>
|
|
|
|
<div class="hvac-event-manage-header">
|
|
<h2>Create and Manage Your HVAC Training Events</h2>
|
|
<p>Use this form to create new training events or edit existing ones. Please fill out all required fields to ensure your event is properly listed and attendees receive accurate information.</p>
|
|
<div class="hvac-event-manage-tips">
|
|
<h3>Event Creation Tips:</h3>
|
|
<ul>
|
|
<li><strong>Event Title:</strong> Use a clear, descriptive title that indicates the training topic</li>
|
|
<li><strong>Date & Time:</strong> Ensure you select the correct timezone for your location</li>
|
|
<li><strong>Description:</strong> Provide detailed information about what attendees will learn</li>
|
|
<li><strong>Capacity:</strong> Set an appropriate maximum number of attendees</li>
|
|
</ul>
|
|
</div>
|
|
<hr style="margin: 20px 0;">
|
|
</div>
|
|
<?php
|
|
return ob_get_clean();
|
|
}
|
|
}
|
|
|
|
// Initialize
|
|
new HVAC_Event_Manage_Header();
|