upskill-event-manager/templates/page-create-event.php
ben 16acf2c8e7 docs: comprehensive deprecation of legacy event creation system
- Create authoritative DEPRECATED-FILES.md documenting 27+ deprecated files
- Add deprecation notices to legacy templates (page-create-event.php, page-manage-event.php, page-edit-event.php)
- Mark deprecated JavaScript files (hvac-event-form-templates.js) with migration paths
- Add deprecation notices to 8 legacy test files with comprehensive explanations
- Update Status.md to reflect completion of comprehensive event creation system v3.2.0
- Automated deprecation script for consistent messaging across files

All deprecated functionality has been replaced by:
- page-tec-create-event.php with AI assistance and native TEC integration
- Comprehensive E2E testing framework with Page Object Model
- Integrated template system with enhanced user experience
- Modern responsive design with role-based permissions

Scheduled for removal in v3.3 after transition period

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-09-26 20:55:13 -03:00

152 lines
No EOL
4.8 KiB
PHP

<?php
/**
* Template Name: Create Event
* Description: Template for creating new events with REST API (100% field control)
*
* ⛔ DEPRECATED - January 2025
* This template has been deprecated and replaced by page-tec-create-event.php
*
* Reasons for deprecation:
* - Legacy REST API approach replaced by native TEC integration
* - No AI assistance capabilities
* - Limited template system
* - Outdated UX patterns
*
* Replacement: templates/page-tec-create-event.php
* - Native Events Calendar integration
* - AI-powered event population
* - Template system with auto-save
* - Modern responsive design
* - Dynamic searchable selectors
* - Featured image support
*
* See: DEPRECATED-FILES.md for full migration details
*/
// Define constant to indicate we are in a page template
define('HVAC_IN_PAGE_TEMPLATE', true);
get_header();
?>
<style>
.hvac-create-event-wrapper {
max-width: 1200px;
margin: 0 auto;
padding: 20px;
}
.hvac-create-event-wrapper 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;
}
</style>
<div class="hvac-create-event-wrapper">
<?php
// Display trainer navigation menu
if (class_exists('HVAC_Menu_System')) {
HVAC_Menu_System::instance()->render_trainer_menu();
}
?>
<h1>Create New Event</h1>
<div class="hvac-form-notice">
<p>Create your event with full control over all fields including excerpt, categories, featured images, and tags.</p>
</div>
<div class="hvac-page-content">
<?php
// Handle form submission
if ($_SERVER['REQUEST_METHOD'] === 'POST' && isset($_POST['hvac_event_form_nonce'])) {
if (wp_verify_nonce($_POST['hvac_event_form_nonce'], 'hvac_event_form')) {
try {
// Create event form builder instance with template support
$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);
// Create event 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}";
$form_submitted = true;
} else {
$form_errors['general'] = 'Event creation failed: ' . $event_id->get_error_message();
}
}
} catch (Exception $e) {
$form_errors['general'] = 'Form error: ' . $e->getMessage();
}
} else {
$form_errors['nonce'] = 'Security check failed. Please try again.';
}
}
// Display success message
if (isset($success_message)) {
echo '<div class="hvac-form-notice" style="background: #d4edda; border-color: #c3e6cb; color: #155724;">';
echo '<p>' . esc_html($success_message) . '</p>';
echo '</div>';
}
// Display errors
if (isset($form_errors['general'])) {
echo '<div style="background: #f8d7da; border: 1px solid #f5c6cb; padding: 12px; border-radius: 4px; margin-bottom: 20px;">';
echo esc_html($form_errors['general']);
echo '</div>';
}
// Create and display the event form with template support
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);
}
echo $event_form->render();
} catch (Exception $e) {
echo '<div style="background: #f8d7da; border: 1px solid #f5c6cb; padding: 12px; border-radius: 4px;">';
echo 'Form Builder Error: ' . esc_html($e->getMessage());
echo '</div>';
}
?>
</div>
</div>
<?php
get_footer();
?>