fix: Remove shortcode override for tribe_community_events
The HVAC plugin was overriding The Events Calendar Community Events
shortcode with a custom implementation that displayed a non-functional
form instead of the proper TEC Community Events form. This caused events
to never be created when users submitted the form.
Changes:
- Removed add_shortcode('tribe_community_events', ...) override
- Removed render_tribe_community_events() method
- Removed render_event_submission_form() helper method
The manage-event page now correctly uses The Events Calendar Community
Events plugin shortcode, allowing proper event creation and submission.
🤖 Generated with Claude Code
Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
parent
bcc0a082d3
commit
9d053f2b0f
1 changed files with 5 additions and 174 deletions
|
|
@ -304,8 +304,8 @@ class HVAC_Community_Events {
|
||||||
// Add certificate fix shortcode (admin only)
|
// Add certificate fix shortcode (admin only)
|
||||||
add_shortcode('hvac_certificate_fix', array($this, 'render_certificate_fix'));
|
add_shortcode('hvac_certificate_fix', array($this, 'render_certificate_fix'));
|
||||||
|
|
||||||
// Add community events shortcode as fallback if TEC CE is not available
|
// Removed shortcode override - let The Events Calendar Community Events handle this shortcode
|
||||||
add_shortcode('tribe_community_events', array($this, 'render_tribe_community_events'));
|
// add_shortcode('tribe_community_events', array($this, 'render_tribe_community_events'));
|
||||||
|
|
||||||
// Add future shortcodes here
|
// Add future shortcodes here
|
||||||
}
|
}
|
||||||
|
|
@ -629,178 +629,9 @@ class HVAC_Community_Events {
|
||||||
return $template;
|
return $template;
|
||||||
} // End load_custom_templates
|
} // End load_custom_templates
|
||||||
|
|
||||||
/**
|
// REMOVED: render_tribe_community_events() method
|
||||||
* Render tribe community events shortcode
|
// This method was overriding The Events Calendar Community Events shortcode
|
||||||
*/
|
// Let TEC handle the shortcode properly instead
|
||||||
public function render_tribe_community_events($atts) {
|
|
||||||
// Parse shortcode attributes
|
|
||||||
$atts = shortcode_atts(array(
|
|
||||||
'view' => 'submission_form'
|
|
||||||
), $atts);
|
|
||||||
|
|
||||||
// Check if user is logged in
|
|
||||||
if (!is_user_logged_in()) {
|
|
||||||
return '<p>Please log in to access this feature.</p>';
|
|
||||||
}
|
|
||||||
|
|
||||||
// Check if user has permission
|
|
||||||
if (!current_user_can('hvac_trainer') && !current_user_can('edit_posts')) {
|
|
||||||
return '<div class="hvac-error">You do not have permission to access this feature.</div>';
|
|
||||||
}
|
|
||||||
|
|
||||||
// Check if TEC Community Events is active and working
|
|
||||||
if (class_exists('Tribe__Events__Community__Main')) {
|
|
||||||
// Check if the TEC shortcode handler exists
|
|
||||||
global $shortcode_tags;
|
|
||||||
$tec_handler = null;
|
|
||||||
|
|
||||||
// Look for TEC's original handler
|
|
||||||
if (isset($shortcode_tags['tribe_community_events'])) {
|
|
||||||
$current_handler = $shortcode_tags['tribe_community_events'];
|
|
||||||
|
|
||||||
// If it's our handler, temporarily remove it to find TEC's
|
|
||||||
if ($current_handler === array($this, 'render_tribe_community_events')) {
|
|
||||||
remove_shortcode('tribe_community_events');
|
|
||||||
|
|
||||||
// Try to get TEC's handler by calling their main class
|
|
||||||
if (class_exists('Tribe__Events__Community__Shortcodes')) {
|
|
||||||
$tec_shortcodes = new Tribe__Events__Community__Shortcodes();
|
|
||||||
if (method_exists($tec_shortcodes, 'tribe_community_events')) {
|
|
||||||
$tec_handler = array($tec_shortcodes, 'tribe_community_events');
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// If we found TEC's handler, use it
|
|
||||||
if ($tec_handler && is_callable($tec_handler)) {
|
|
||||||
$output = call_user_func($tec_handler, $atts);
|
|
||||||
|
|
||||||
// Re-add our handler for next time
|
|
||||||
add_shortcode('tribe_community_events', array($this, 'render_tribe_community_events'));
|
|
||||||
|
|
||||||
if (!empty($output) && !is_wp_error($output)) {
|
|
||||||
return $output;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Re-add our handler if TEC didn't work
|
|
||||||
add_shortcode('tribe_community_events', array($this, 'render_tribe_community_events'));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Handle different views
|
|
||||||
switch ($atts['view']) {
|
|
||||||
case 'submission_form':
|
|
||||||
return $this->render_event_submission_form();
|
|
||||||
default:
|
|
||||||
return '<div class="hvac-error">Unknown view: ' . esc_html($atts['view']) . '</div>';
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Render event submission form
|
|
||||||
*/
|
|
||||||
private function render_event_submission_form() {
|
|
||||||
ob_start();
|
|
||||||
?>
|
|
||||||
<div class="hvac-event-form-container">
|
|
||||||
<!-- Navigation Header -->
|
|
||||||
<div class="hvac-dashboard-header">
|
|
||||||
<h1 class="entry-title">Create New Training Event</h1>
|
|
||||||
<div class="hvac-dashboard-nav">
|
|
||||||
<a href="<?php echo esc_url( home_url( '/hvac-dashboard/' ) ); ?>" class="ast-button ast-button-secondary">Dashboard</a>
|
|
||||||
<a href="<?php echo esc_url( home_url( '/certificate-reports/' ) ); ?>" class="ast-button ast-button-secondary">Certificate Reports</a>
|
|
||||||
<a href="<?php echo esc_url( home_url( '/generate-certificates/' ) ); ?>" class="ast-button ast-button-primary">Generate Certificates</a>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="hvac-event-form-header">
|
|
||||||
<?php if (!class_exists('Tribe__Events__Community__Main')) : ?>
|
|
||||||
<div class="hvac-notice hvac-notice-warning">
|
|
||||||
<p><strong>Notice:</strong> The Events Calendar Community Events plugin is not active. Using basic event creation form.</p>
|
|
||||||
<p>For full event management features, please contact your administrator to activate The Events Calendar Community Events plugin.</p>
|
|
||||||
</div>
|
|
||||||
<?php endif; ?>
|
|
||||||
<p>Fill out the form below to create a new training event. All events are reviewed before being published.</p>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="hvac-event-form-instructions">
|
|
||||||
<h3>Instructions</h3>
|
|
||||||
<ul>
|
|
||||||
<li>Provide a clear, descriptive title for your training event</li>
|
|
||||||
<li>Include detailed description of what attendees will learn</li>
|
|
||||||
<li>Set appropriate pricing for your target audience</li>
|
|
||||||
<li>Ensure venue information is accurate and complete</li>
|
|
||||||
<li>Events will be reviewed within 1-2 business days</li>
|
|
||||||
</ul>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
|
|
||||||
<!-- Fallback form for basic event creation -->
|
|
||||||
<form id="hvac-basic-event-form" method="post" action="">
|
|
||||||
<?php wp_nonce_field('hvac_create_event', 'hvac_event_nonce'); ?>
|
|
||||||
|
|
||||||
<div class="hvac-form-field">
|
|
||||||
<label for="event_title">Event Title *</label>
|
|
||||||
<input type="text" id="event_title" name="event_title" required>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="hvac-form-field">
|
|
||||||
<label for="event_description">Event Description *</label>
|
|
||||||
<textarea id="event_description" name="event_description" rows="5" required></textarea>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="hvac-form-row">
|
|
||||||
<div class="hvac-form-field">
|
|
||||||
<label for="event_start_date">Start Date *</label>
|
|
||||||
<input type="date" id="event_start_date" name="event_start_date" required>
|
|
||||||
</div>
|
|
||||||
<div class="hvac-form-field">
|
|
||||||
<label for="event_start_time">Start Time *</label>
|
|
||||||
<input type="time" id="event_start_time" name="event_start_time" required>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="hvac-form-row">
|
|
||||||
<div class="hvac-form-field">
|
|
||||||
<label for="event_end_date">End Date *</label>
|
|
||||||
<input type="date" id="event_end_date" name="event_end_date" required>
|
|
||||||
</div>
|
|
||||||
<div class="hvac-form-field">
|
|
||||||
<label for="event_end_time">End Time *</label>
|
|
||||||
<input type="time" id="event_end_time" name="event_end_time" required>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="hvac-form-field">
|
|
||||||
<label for="event_venue">Venue Name</label>
|
|
||||||
<input type="text" id="event_venue" name="event_venue">
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="hvac-form-field">
|
|
||||||
<label for="event_address">Venue Address</label>
|
|
||||||
<textarea id="event_address" name="event_address" rows="3"></textarea>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="hvac-form-field">
|
|
||||||
<label for="event_price">Ticket Price ($)</label>
|
|
||||||
<input type="number" id="event_price" name="event_price" min="0" step="0.01">
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="hvac-form-field">
|
|
||||||
<label for="event_capacity">Maximum Capacity</label>
|
|
||||||
<input type="number" id="event_capacity" name="event_capacity" min="1">
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="hvac-form-actions">
|
|
||||||
<button type="submit" class="button button-primary">Submit Event for Review</button>
|
|
||||||
<a href="<?php echo home_url('/hvac-dashboard/'); ?>" class="button button-secondary">Return to Dashboard</a>
|
|
||||||
</div>
|
|
||||||
</form>
|
|
||||||
</div>
|
|
||||||
<?php
|
|
||||||
return ob_get_clean();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue