Major accomplishments: - Successfully integrated Phase 2A template functionality with Phase 1 foundation - Fixed critical form builder inheritance and property visibility issues - Resolved cache initialization and method accessibility problems - Updated templates to use native form builder with template support Technical fixes: - Fixed null cache initialization in HVAC_Event_Form_Builder constructor - Changed form builder properties from private to protected for inheritance - Made critical methods (get_form_attributes, render_field, etc.) accessible to child classes - Updated create-event template to use native form with template mode enabled - Added null checks for cache operations to prevent fatal errors Form builder improvements: - Template-enabled forms now render correctly with data-template-enabled="1" - Form output increased from 2,871 to 37,966 characters (full field set) - Proper event_title, event_start_datetime, venue, and organizer fields - Template selector and template actions integrated seamlessly Testing results: - Phase 2A comprehensive tests now successfully locate template-enabled forms - All Phase 2A classes (Template Manager, Bulk Manager, Form Builder) operational - TEC Core compatibility maintained with tribe_events post type - Database schema and template management fully functional 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
245 lines
No EOL
6.9 KiB
PHP
245 lines
No EOL
6.9 KiB
PHP
<?php
|
|
/**
|
|
* Template Name: Native Event Test
|
|
* Description: Test template for native WordPress event form functionality
|
|
*/
|
|
|
|
// Define constant to indicate we are in a page template
|
|
define('HVAC_IN_PAGE_TEMPLATE', true);
|
|
|
|
get_header();
|
|
?>
|
|
|
|
<style>
|
|
.hvac-native-event-test {
|
|
max-width: 1200px;
|
|
margin: 0 auto;
|
|
padding: 20px;
|
|
}
|
|
|
|
.hvac-native-event-test h1 {
|
|
color: #1a1a1a;
|
|
font-size: 28px;
|
|
margin-bottom: 20px;
|
|
}
|
|
|
|
.hvac-form-notice {
|
|
background: #f0f7ff;
|
|
border: 1px solid #0073aa;
|
|
border-radius: 4px;
|
|
padding: 12px;
|
|
margin-bottom: 20px;
|
|
}
|
|
|
|
.hvac-form-notice p {
|
|
margin: 0;
|
|
color: #0073aa;
|
|
}
|
|
|
|
.form-group {
|
|
margin-bottom: 20px;
|
|
}
|
|
|
|
.form-group label {
|
|
display: block;
|
|
font-weight: bold;
|
|
margin-bottom: 5px;
|
|
}
|
|
|
|
.form-group input,
|
|
.form-group textarea,
|
|
.form-group select {
|
|
width: 100%;
|
|
padding: 8px;
|
|
border: 1px solid #ddd;
|
|
border-radius: 4px;
|
|
box-sizing: border-box;
|
|
}
|
|
|
|
.form-group textarea {
|
|
height: 100px;
|
|
resize: vertical;
|
|
}
|
|
|
|
.venue-group,
|
|
.organizer-group {
|
|
border: 1px solid #e0e0e0;
|
|
padding: 15px;
|
|
border-radius: 5px;
|
|
margin: 20px 0;
|
|
}
|
|
|
|
.venue-group h3,
|
|
.organizer-group h3 {
|
|
margin-top: 0;
|
|
color: #0073aa;
|
|
}
|
|
|
|
.required {
|
|
color: #d00;
|
|
}
|
|
|
|
.error {
|
|
color: #d00;
|
|
font-size: 14px;
|
|
display: block;
|
|
margin-top: 5px;
|
|
}
|
|
|
|
.button {
|
|
background: #0073aa;
|
|
color: white;
|
|
padding: 10px 20px;
|
|
border: none;
|
|
border-radius: 4px;
|
|
cursor: pointer;
|
|
}
|
|
|
|
.button:hover {
|
|
background: #005177;
|
|
}
|
|
|
|
.success-message {
|
|
background: #d4edda;
|
|
border: 1px solid #c3e6cb;
|
|
color: #155724;
|
|
padding: 12px;
|
|
border-radius: 4px;
|
|
margin-bottom: 20px;
|
|
}
|
|
</style>
|
|
|
|
<div class="hvac-native-event-test">
|
|
<?php
|
|
// Display trainer navigation menu
|
|
if (class_exists('HVAC_Menu_System')) {
|
|
HVAC_Menu_System::instance()->render_trainer_menu();
|
|
}
|
|
?>
|
|
|
|
<h1>Native Event Form Builder Test</h1>
|
|
|
|
<div class="hvac-form-notice">
|
|
<p><strong>Phase 1A Testing:</strong> This page tests the new HVAC_Event_Form_Builder with datetime, venue, organizer, and HVAC-specific fields.</p>
|
|
</div>
|
|
|
|
<?php
|
|
$form_submitted = false;
|
|
$form_errors = [];
|
|
$success_message = '';
|
|
|
|
// Handle form submission
|
|
if ($_SERVER['REQUEST_METHOD'] === 'POST' && isset($_POST['hvac_event_form_nonce'])) {
|
|
|
|
// Verify nonce for security
|
|
if (wp_verify_nonce($_POST['hvac_event_form_nonce'], 'hvac_event_form')) {
|
|
|
|
try {
|
|
// Create event form builder instance
|
|
$event_form = new HVAC_Event_Form_Builder('hvac_event_form', true);
|
|
$event_form->create_event_form();
|
|
|
|
// Validate submitted data
|
|
$form_errors = $event_form->validate($_POST);
|
|
|
|
if (empty($form_errors)) {
|
|
// Sanitize data
|
|
$sanitized_data = $event_form->sanitize($_POST);
|
|
|
|
// Phase 1B: Create tribe_events post using native WordPress
|
|
$post_handler = HVAC_Event_Post_Handler::instance();
|
|
$event_id = $post_handler->create_event($sanitized_data);
|
|
|
|
if (!is_wp_error($event_id)) {
|
|
$success_message = "Event created successfully! Event ID: {$event_id}. Native WordPress event system is working.";
|
|
$form_submitted = true;
|
|
} else {
|
|
$form_errors['general'] = 'Event creation failed: ' . $event_id->get_error_message();
|
|
}
|
|
|
|
} else {
|
|
$event_form->set_errors($form_errors);
|
|
}
|
|
|
|
} catch (Exception $e) {
|
|
$form_errors['general'] = 'Form processing error: ' . $e->getMessage();
|
|
}
|
|
|
|
} else {
|
|
$form_errors['nonce'] = 'Security check failed. Please refresh the page and try again.';
|
|
}
|
|
}
|
|
|
|
// Display success message
|
|
if ($success_message) {
|
|
echo '<div class="success-message">' . esc_html($success_message) . '</div>';
|
|
}
|
|
|
|
// Display general errors
|
|
if (isset($form_errors['general'])) {
|
|
echo '<div class="error" style="background: #f8d7da; border: 1px solid #f5c6cb; padding: 12px; border-radius: 4px; margin-bottom: 20px;">';
|
|
echo esc_html($form_errors['general']);
|
|
echo '</div>';
|
|
}
|
|
|
|
if (isset($form_errors['nonce'])) {
|
|
echo '<div class="error" style="background: #f8d7da; border: 1px solid #f5c6cb; padding: 12px; border-radius: 4px; margin-bottom: 20px;">';
|
|
echo esc_html($form_errors['nonce']);
|
|
echo '</div>';
|
|
}
|
|
|
|
// Create and display the event form
|
|
try {
|
|
$event_form = new HVAC_Event_Form_Builder('hvac_event_form', true);
|
|
$event_form->create_event_form();
|
|
|
|
// Set any existing errors
|
|
if (!empty($form_errors)) {
|
|
$event_form->set_errors($form_errors);
|
|
}
|
|
|
|
// Set form data if submitted (for re-population on errors)
|
|
if ($_SERVER['REQUEST_METHOD'] === 'POST') {
|
|
$event_form->set_data($_POST);
|
|
}
|
|
|
|
// Add some custom wrapper HTML
|
|
echo '<div class="native-event-form-wrapper">';
|
|
echo '<h3>Event Information</h3>';
|
|
echo $event_form->render();
|
|
echo '</div>';
|
|
|
|
} catch (Exception $e) {
|
|
echo '<div class="error" style="background: #f8d7da; border: 1px solid #f5c6cb; padding: 12px; border-radius: 4px;">';
|
|
echo 'Form Builder Error: ' . esc_html($e->getMessage());
|
|
echo '</div>';
|
|
}
|
|
?>
|
|
|
|
<div style="margin-top: 30px; padding: 15px; background: #f9f9f9; border-radius: 4px;">
|
|
<h4>Native WordPress Event System Implementation Status:</h4>
|
|
<ul>
|
|
<li><strong>Phase 1A - Complete:</strong></li>
|
|
<li>✅ HVAC_Event_Form_Builder class created</li>
|
|
<li>✅ DateTime field types (start/end dates, timezone, all-day)</li>
|
|
<li>✅ Venue field group (name, address, capacity, coordinates)</li>
|
|
<li>✅ Organizer field group (name, email, phone, website)</li>
|
|
<li>✅ HVAC-specific fields (trainer requirements, certifications, equipment)</li>
|
|
<li>✅ Featured image upload support</li>
|
|
<li>✅ WordPress security integration (nonce, sanitization, validation)</li>
|
|
<li>✅ Form validation and error handling</li>
|
|
<li><strong>Phase 1B - Complete:</strong></li>
|
|
<li>✅ HVAC_Event_Post_Handler class created</li>
|
|
<li>✅ Native tribe_events post creation/editing</li>
|
|
<li>✅ TEC meta field mapping and compatibility</li>
|
|
<li>✅ Venue and organizer post creation/assignment</li>
|
|
<li>✅ Featured image attachment handling</li>
|
|
<li>✅ WordPress security patterns throughout</li>
|
|
<li>⏳ Next: Phase 1C - HVAC_Security integration</li>
|
|
</ul>
|
|
</div>
|
|
</div>
|
|
|
|
<?php
|
|
get_footer();
|
|
?>
|