fix: Registration page content and event manage styling issues
- Fixed registration form redirect to use hierarchical URL (/trainer/registration/) - Removed inline styles from event manage page that were breaking theme layout - Added proper CSS styles for event manage header navigation - Created header component to properly display navigation on event manage page - Fixed manage event page detection to be more specific The event manage page now uses external CSS instead of inline styles that conflict with the theme. 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
parent
6142b4b2df
commit
cd93ed573e
4 changed files with 1365 additions and 99 deletions
356
assets/css/hvac-event-manage.css
Normal file
356
assets/css/hvac-event-manage.css
Normal file
|
|
@ -0,0 +1,356 @@
|
|||
/**
|
||||
* HVAC Event Management Styles
|
||||
* Styles for The Events Calendar Community event creation/editing form
|
||||
*/
|
||||
|
||||
/* Import HVAC CSS variables and base styles */
|
||||
@import url('hvac-common.css');
|
||||
|
||||
/* Container and Layout */
|
||||
.tribe-community-events-content,
|
||||
#tribe-community-events {
|
||||
max-width: var(--hvac-container-width, 1200px);
|
||||
margin: 0 auto;
|
||||
padding: var(--hvac-spacing-xl, 2rem);
|
||||
background: var(--hvac-white, #ffffff);
|
||||
border-radius: var(--hvac-radius-lg, 12px);
|
||||
box-shadow: var(--hvac-shadow-sm, 0 1px 3px rgba(0, 0, 0, 0.1));
|
||||
}
|
||||
|
||||
/* Form Header */
|
||||
.tribe-events-community-header {
|
||||
margin-bottom: var(--hvac-spacing-xl, 2rem);
|
||||
padding-bottom: var(--hvac-spacing-lg, 1.5rem);
|
||||
border-bottom: 2px solid var(--hvac-border, #e5e7eb);
|
||||
}
|
||||
|
||||
/* Form Sections */
|
||||
.tribe-section {
|
||||
margin-bottom: var(--hvac-spacing-xl, 2rem);
|
||||
padding: var(--hvac-spacing-lg, 1.5rem);
|
||||
background: var(--hvac-background, #f9fafb);
|
||||
border-radius: var(--hvac-radius-base, 8px);
|
||||
border: 1px solid var(--hvac-border, #e5e7eb);
|
||||
}
|
||||
|
||||
/* Form Groups */
|
||||
.tribe-events-community-details .tribe-section-content,
|
||||
.tribe-events-community-details .tribe-events-community-section-content {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: var(--hvac-spacing-md, 1rem);
|
||||
}
|
||||
|
||||
/* Labels */
|
||||
.tribe-events-community-details label,
|
||||
.tribe-section label {
|
||||
display: block;
|
||||
margin-bottom: var(--hvac-spacing-xs, 0.5rem);
|
||||
font-weight: 500;
|
||||
color: var(--hvac-text-primary, #1f2937);
|
||||
font-size: 0.875rem;
|
||||
}
|
||||
|
||||
/* Input Fields */
|
||||
.tribe-events-community-details input[type="text"],
|
||||
.tribe-events-community-details input[type="email"],
|
||||
.tribe-events-community-details input[type="url"],
|
||||
.tribe-events-community-details input[type="number"],
|
||||
.tribe-events-community-details select,
|
||||
.tribe-events-community-details textarea {
|
||||
width: 100%;
|
||||
padding: var(--hvac-spacing-sm, 0.75rem);
|
||||
border: 1px solid var(--hvac-border-input, #d1d5db);
|
||||
border-radius: var(--hvac-radius-sm, 6px);
|
||||
font-size: 1rem;
|
||||
transition: all 0.2s ease;
|
||||
background: var(--hvac-white, #ffffff);
|
||||
}
|
||||
|
||||
/* Focus States */
|
||||
.tribe-events-community-details input:focus,
|
||||
.tribe-events-community-details select:focus,
|
||||
.tribe-events-community-details textarea:focus {
|
||||
outline: none;
|
||||
border-color: var(--hvac-primary, #0274be);
|
||||
box-shadow: 0 0 0 3px rgba(2, 116, 190, 0.1);
|
||||
}
|
||||
|
||||
/* Event Title Field */
|
||||
#EventTitle,
|
||||
input[name="post_title"] {
|
||||
font-size: 1.125rem !important;
|
||||
font-weight: 500;
|
||||
padding: var(--hvac-spacing-md, 1rem) !important;
|
||||
}
|
||||
|
||||
/* Description Editor Container */
|
||||
.wp-editor-wrap {
|
||||
border: 1px solid var(--hvac-border-input, #d1d5db);
|
||||
border-radius: var(--hvac-radius-sm, 6px);
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
.wp-editor-container {
|
||||
background: var(--hvac-white, #ffffff);
|
||||
}
|
||||
|
||||
/* Date and Time Fields */
|
||||
.tribe-datetime-block {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: var(--hvac-spacing-sm, 0.75rem);
|
||||
flex-wrap: wrap;
|
||||
}
|
||||
|
||||
.tribe-datetime-block input {
|
||||
flex: 1;
|
||||
min-width: 150px;
|
||||
}
|
||||
|
||||
/* Venue and Organizer Sections */
|
||||
.tribe-events-community-details .venue-details,
|
||||
.tribe-events-community-details .organizer-details {
|
||||
background: var(--hvac-white, #ffffff);
|
||||
padding: var(--hvac-spacing-md, 1rem);
|
||||
border-radius: var(--hvac-radius-sm, 6px);
|
||||
margin-top: var(--hvac-spacing-sm, 0.75rem);
|
||||
}
|
||||
|
||||
/* Submit Button */
|
||||
.tribe-events-community-footer input[type="submit"],
|
||||
.tribe-button-primary {
|
||||
background: var(--hvac-primary, #0274be);
|
||||
color: var(--hvac-white, #ffffff);
|
||||
padding: var(--hvac-spacing-sm, 0.75rem) var(--hvac-spacing-xl, 2rem);
|
||||
border: none;
|
||||
border-radius: var(--hvac-radius-base, 8px);
|
||||
font-size: 1rem;
|
||||
font-weight: 500;
|
||||
cursor: pointer;
|
||||
transition: all 0.2s ease;
|
||||
display: inline-block;
|
||||
}
|
||||
|
||||
.tribe-events-community-footer input[type="submit"]:hover,
|
||||
.tribe-button-primary:hover {
|
||||
background: var(--hvac-primary-dark, #025a96);
|
||||
transform: translateY(-1px);
|
||||
box-shadow: var(--hvac-shadow-md, 0 4px 6px rgba(0, 0, 0, 0.1));
|
||||
}
|
||||
|
||||
/* View Submitted Events Link */
|
||||
.view-events-link,
|
||||
a.tribe-button-secondary {
|
||||
background: var(--hvac-secondary, #54595f);
|
||||
color: var(--hvac-white, #ffffff);
|
||||
padding: var(--hvac-spacing-sm, 0.75rem) var(--hvac-spacing-lg, 1.5rem);
|
||||
text-decoration: none;
|
||||
border-radius: var(--hvac-radius-base, 8px);
|
||||
display: inline-block;
|
||||
margin-left: var(--hvac-spacing-md, 1rem);
|
||||
transition: all 0.2s ease;
|
||||
}
|
||||
|
||||
/* Error Messages */
|
||||
.tribe-events-community-notice,
|
||||
.tribe-events-notices {
|
||||
padding: var(--hvac-spacing-md, 1rem);
|
||||
margin-bottom: var(--hvac-spacing-lg, 1.5rem);
|
||||
border-radius: var(--hvac-radius-sm, 6px);
|
||||
border-left: 4px solid;
|
||||
}
|
||||
|
||||
.tribe-events-community-notice.tribe-events-community-error,
|
||||
.tribe-events-notices.tribe-events-notices-error {
|
||||
background: #fef2f2;
|
||||
border-color: var(--hvac-error, #ef4444);
|
||||
color: #991b1b;
|
||||
}
|
||||
|
||||
.tribe-events-community-notice.tribe-events-community-success,
|
||||
.tribe-events-notices.tribe-events-notices-success {
|
||||
background: #f0fdf4;
|
||||
border-color: var(--hvac-success, #4caf50);
|
||||
color: #166534;
|
||||
}
|
||||
|
||||
/* Responsive Design */
|
||||
@media (max-width: 768px) {
|
||||
.tribe-community-events-content,
|
||||
#tribe-community-events {
|
||||
padding: var(--hvac-spacing-md, 1rem);
|
||||
}
|
||||
|
||||
.tribe-datetime-block {
|
||||
flex-direction: column;
|
||||
align-items: stretch;
|
||||
}
|
||||
|
||||
.tribe-datetime-block input {
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
.tribe-events-community-footer {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: var(--hvac-spacing-sm, 0.75rem);
|
||||
}
|
||||
|
||||
.view-events-link,
|
||||
a.tribe-button-secondary {
|
||||
margin-left: 0;
|
||||
text-align: center;
|
||||
}
|
||||
}
|
||||
|
||||
/* Accessibility */
|
||||
.tribe-events-community-details input:focus-visible,
|
||||
.tribe-events-community-details select:focus-visible,
|
||||
.tribe-events-community-details textarea:focus-visible {
|
||||
outline: 2px solid var(--hvac-primary, #0274be);
|
||||
outline-offset: 2px;
|
||||
}
|
||||
|
||||
/* IE11 Fallbacks */
|
||||
.tribe-community-events-content,
|
||||
#tribe-community-events {
|
||||
max-width: 1200px; /* Fallback for var() */
|
||||
padding: 2rem; /* Fallback for var() */
|
||||
background: #ffffff; /* Fallback for var() */
|
||||
}
|
||||
|
||||
.tribe-events-community-footer input[type="submit"],
|
||||
.tribe-button-primary {
|
||||
background: #0274be; /* Fallback for var() */
|
||||
color: #ffffff; /* Fallback for var() */
|
||||
}
|
||||
|
||||
/* Fix for TinyMCE Editor */
|
||||
.wp-editor-area {
|
||||
width: 100% !important;
|
||||
min-height: 300px;
|
||||
font-family: inherit;
|
||||
}
|
||||
|
||||
/* Calendar Icon Fix */
|
||||
.ui-datepicker-trigger {
|
||||
margin-left: var(--hvac-spacing-xs, 0.5rem);
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
/* Required Field Indicators */
|
||||
.required {
|
||||
color: var(--hvac-error, #ef4444);
|
||||
font-weight: bold;
|
||||
}
|
||||
|
||||
/* Event Management Page Header Navigation */
|
||||
.hvac-dashboard-header {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
margin-bottom: var(--hvac-spacing-xl, 2rem);
|
||||
padding: var(--hvac-spacing-lg, 1.5rem) 0;
|
||||
border-bottom: 2px solid var(--hvac-border, #e5e7eb);
|
||||
flex-wrap: wrap;
|
||||
gap: var(--hvac-spacing-lg, 1.5rem);
|
||||
}
|
||||
|
||||
.hvac-dashboard-header .entry-title {
|
||||
margin: 0;
|
||||
font-size: 2.5em;
|
||||
color: var(--hvac-text-primary, #1f2937);
|
||||
}
|
||||
|
||||
.hvac-dashboard-nav {
|
||||
display: flex;
|
||||
gap: var(--hvac-spacing-sm, 0.75rem);
|
||||
flex-wrap: wrap;
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
.hvac-dashboard-nav .ast-button {
|
||||
padding: var(--hvac-spacing-sm, 0.75rem) var(--hvac-spacing-lg, 1.5rem);
|
||||
font-size: 14px;
|
||||
text-decoration: none;
|
||||
border-radius: var(--hvac-radius-base, 8px);
|
||||
transition: all 0.3s ease;
|
||||
border: none;
|
||||
cursor: pointer;
|
||||
display: inline-block;
|
||||
line-height: 1.5;
|
||||
}
|
||||
|
||||
.hvac-dashboard-nav .ast-button-secondary {
|
||||
background-color: var(--hvac-background, #f9fafb);
|
||||
color: var(--hvac-text-primary, #1f2937);
|
||||
border: 1px solid var(--hvac-border, #e5e7eb);
|
||||
}
|
||||
|
||||
.hvac-dashboard-nav .ast-button-secondary:hover {
|
||||
background-color: var(--hvac-border, #e5e7eb);
|
||||
color: var(--hvac-text-primary, #1f2937);
|
||||
}
|
||||
|
||||
.hvac-dashboard-nav .ast-button-primary {
|
||||
background-color: var(--hvac-primary, #0274be);
|
||||
color: var(--hvac-white, #ffffff);
|
||||
}
|
||||
|
||||
.hvac-dashboard-nav .ast-button-primary:hover {
|
||||
background-color: var(--hvac-primary-dark, #005a9e);
|
||||
color: var(--hvac-white, #ffffff);
|
||||
}
|
||||
|
||||
/* Event Management Header Content */
|
||||
.hvac-event-manage-header {
|
||||
margin-bottom: var(--hvac-spacing-xl, 2rem);
|
||||
padding: var(--hvac-spacing-lg, 1.5rem);
|
||||
background: var(--hvac-background, #f9fafb);
|
||||
border-radius: var(--hvac-radius-base, 8px);
|
||||
border: 1px solid var(--hvac-border, #e5e7eb);
|
||||
}
|
||||
|
||||
.hvac-event-manage-header h2 {
|
||||
margin: 0 0 var(--hvac-spacing-md, 1rem);
|
||||
color: var(--hvac-text-primary, #1f2937);
|
||||
}
|
||||
|
||||
.hvac-event-manage-tips {
|
||||
margin-top: var(--hvac-spacing-lg, 1.5rem);
|
||||
}
|
||||
|
||||
.hvac-event-manage-tips h3 {
|
||||
margin: 0 0 var(--hvac-spacing-sm, 0.75rem);
|
||||
color: var(--hvac-text-primary, #1f2937);
|
||||
font-size: 1.2em;
|
||||
}
|
||||
|
||||
.hvac-event-manage-tips ul {
|
||||
list-style: disc;
|
||||
padding-left: var(--hvac-spacing-lg, 1.5rem);
|
||||
margin: 0;
|
||||
}
|
||||
|
||||
.hvac-event-manage-tips li {
|
||||
margin-bottom: var(--hvac-spacing-xs, 0.5rem);
|
||||
color: var(--hvac-text-secondary, #6b7280);
|
||||
}
|
||||
|
||||
/* Responsive Header */
|
||||
@media (max-width: 768px) {
|
||||
.hvac-dashboard-header {
|
||||
flex-direction: column;
|
||||
align-items: flex-start;
|
||||
}
|
||||
|
||||
.hvac-dashboard-nav {
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
.hvac-dashboard-nav .ast-button {
|
||||
flex: 1;
|
||||
text-align: center;
|
||||
}
|
||||
}
|
||||
|
|
@ -95,105 +95,7 @@ function hvac_ce_create_required_pages() {
|
|||
'children' => [
|
||||
'manage' => [
|
||||
'title' => 'Manage Event',
|
||||
'content' => '<!-- 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>
|
||||
</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>
|
||||
|
||||
<style>
|
||||
.hvac-dashboard-header {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
margin-bottom: 30px;
|
||||
padding: 20px 0;
|
||||
border-bottom: 2px solid #f0f0f0;
|
||||
flex-wrap: wrap;
|
||||
gap: 20px;
|
||||
}
|
||||
|
||||
.hvac-dashboard-header .entry-title {
|
||||
margin: 0;
|
||||
font-size: 2.5em;
|
||||
color: #333;
|
||||
}
|
||||
|
||||
.hvac-dashboard-nav {
|
||||
display: flex;
|
||||
gap: 10px;
|
||||
flex-wrap: wrap;
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
.hvac-dashboard-nav .ast-button {
|
||||
padding: 10px 20px;
|
||||
font-size: 14px;
|
||||
text-decoration: none;
|
||||
border-radius: 4px;
|
||||
transition: all 0.3s ease;
|
||||
border: none;
|
||||
cursor: pointer;
|
||||
display: inline-block;
|
||||
line-height: 1.5;
|
||||
}
|
||||
|
||||
.hvac-dashboard-nav .ast-button-secondary {
|
||||
background-color: #f0f0f0;
|
||||
color: #333;
|
||||
}
|
||||
|
||||
.hvac-dashboard-nav .ast-button-secondary:hover {
|
||||
background-color: #e0e0e0;
|
||||
color: #000;
|
||||
}
|
||||
|
||||
.hvac-dashboard-nav .ast-button-primary {
|
||||
background-color: #0073aa;
|
||||
color: #fff;
|
||||
}
|
||||
|
||||
.hvac-dashboard-nav .ast-button-primary:hover {
|
||||
background-color: #005177;
|
||||
color: #fff;
|
||||
}
|
||||
|
||||
@media (max-width: 768px) {
|
||||
.hvac-dashboard-header {
|
||||
flex-direction: column;
|
||||
align-items: flex-start;
|
||||
}
|
||||
|
||||
.hvac-dashboard-nav {
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
.hvac-dashboard-nav .ast-button {
|
||||
flex: 1;
|
||||
text-align: center;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
[tribe_community_events view="submission_form"]',
|
||||
'content' => '[tribe_community_events view="submission_form"]',
|
||||
],
|
||||
'summary' => [
|
||||
'title' => 'Event Summary',
|
||||
|
|
|
|||
919
includes/class-hvac-community-events.php
Normal file
919
includes/class-hvac-community-events.php
Normal file
|
|
@ -0,0 +1,919 @@
|
|||
<?php
|
||||
/**
|
||||
* Main plugin class for HVAC Community Events
|
||||
*/
|
||||
|
||||
if (!defined('ABSPATH')) {
|
||||
exit;
|
||||
}
|
||||
|
||||
class HVAC_Community_Events {
|
||||
/**
|
||||
* The single instance of the class
|
||||
*/
|
||||
private static $instance = null;
|
||||
|
||||
/**
|
||||
* Registration instance
|
||||
*/
|
||||
private $registration = null;
|
||||
|
||||
/**
|
||||
* Main instance
|
||||
*/
|
||||
public static function instance() {
|
||||
if (is_null(self::$instance)) {
|
||||
self::$instance = new self();
|
||||
}
|
||||
return self::$instance;
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*/
|
||||
public function __construct() {
|
||||
HVAC_Logger::info('HVAC_Community_Events constructor started', 'Core');
|
||||
$this->define_constants();
|
||||
HVAC_Logger::info('Constants defined', 'Core');
|
||||
$this->includes();
|
||||
HVAC_Logger::info('Includes completed', 'Core');
|
||||
$this->init_hooks();
|
||||
HVAC_Logger::info('Hooks initialized', 'Core');
|
||||
}
|
||||
|
||||
/**
|
||||
* Define constants
|
||||
*/
|
||||
private function define_constants() {
|
||||
// Additional constants can be defined here
|
||||
}
|
||||
|
||||
/**
|
||||
* Include required files
|
||||
*/
|
||||
private function includes() {
|
||||
HVAC_Logger::info('Loading required files', 'Core');
|
||||
$files_to_include = [
|
||||
'class-hvac-roles.php',
|
||||
'class-hvac-registration.php',
|
||||
'class-hvac-settings.php',
|
||||
'community/class-login-handler.php',
|
||||
'community/class-event-handler.php',
|
||||
'class-hvac-dashboard-data.php',
|
||||
'class-hvac-master-dashboard-data.php',
|
||||
'class-event-form-handler.php', // Add our form handler
|
||||
'class-event-author-fixer.php', // Fix event author assignment
|
||||
'class-hvac-dashboard.php', // New dashboard handler
|
||||
'class-hvac-manage-event.php', // Manage event page handler
|
||||
'class-hvac-event-manage-header.php', // Event management page header
|
||||
'class-hvac-help-system.php', // Help system for tooltips and documentation
|
||||
'certificates/class-certificate-installer.php', // Certificate database installer
|
||||
'certificates/class-certificate-manager.php', // Certificate management
|
||||
'certificates/class-certificate-generator.php', // Certificate generation
|
||||
'certificates/class-certificate-settings.php', // Certificate settings
|
||||
'certificates/class-certificate-template.php', // Certificate template
|
||||
'certificates/class-certificate-security.php', // Certificate security
|
||||
'certificates/class-certificate-url-handler.php', // Certificate URL handler
|
||||
'certificates/class-certificate-ajax-handler.php', // Certificate AJAX handling
|
||||
'certificates/class-certificate-fix.php', // Certificate diagnostic/fix tool
|
||||
'community/class-email-debug.php', // Email debugging tools
|
||||
'certificates/test-rewrite-rules.php', // Rewrite rules testing (temporary)
|
||||
'google-sheets/class-google-sheets-auth.php', // Google Sheets authentication
|
||||
'google-sheets/class-google-sheets-manager.php', // Google Sheets management
|
||||
'communication/class-communication-templates.php', // Email template management
|
||||
'communication/class-communication-installer.php', // Communication system database installer
|
||||
'communication/class-communication-schedule-manager.php', // Communication schedule manager
|
||||
'communication/class-communication-trigger-engine.php', // Communication trigger engine
|
||||
'communication/class-communication-logger.php', // Communication logger
|
||||
'communication/class-communication-scheduler.php' // Communication scheduler
|
||||
];
|
||||
// Make sure Login_Handler is loaded first for shortcode registration
|
||||
$login_handler_path = HVAC_CE_PLUGIN_DIR . 'includes/community/class-login-handler.php';
|
||||
if (file_exists($login_handler_path)) {
|
||||
require_once $login_handler_path;
|
||||
HVAC_Logger::info("Included file: community/class-login-handler.php", 'Core');
|
||||
}
|
||||
|
||||
foreach ($files_to_include as $file) {
|
||||
// Skip Login_Handler as we've already loaded it
|
||||
if ($file === 'community/class-login-handler.php') {
|
||||
continue;
|
||||
}
|
||||
|
||||
$path = HVAC_CE_PLUGIN_DIR . 'includes/' . $file;
|
||||
if (file_exists($path)) {
|
||||
require_once $path;
|
||||
HVAC_Logger::info("Included file: {$file}", 'Core');
|
||||
} else {
|
||||
HVAC_Logger::error("Failed to include file: {$file} - File not found", 'Core');
|
||||
}
|
||||
}
|
||||
|
||||
// Note: Zoho admin interface will be loaded in init_zoho_admin() method during hooks initialization
|
||||
|
||||
HVAC_Logger::info('All required files loaded', 'Core');
|
||||
}
|
||||
|
||||
/**
|
||||
* Initialize hooks
|
||||
*/
|
||||
private function init_hooks() {
|
||||
// Register activation/deactivation hooks
|
||||
// Note: These hooks are typically registered outside the class instance context
|
||||
// register_activation_hook(__FILE__, array($this, 'activate')); // This won't work correctly here
|
||||
// register_deactivation_hook(__FILE__, array($this, 'deactivate')); // This won't work correctly here
|
||||
|
||||
// Initialize other hooks
|
||||
add_action('init', array($this, 'init'));
|
||||
|
||||
// Template loading for custom pages
|
||||
add_filter('template_include', array($this, 'load_custom_templates'));
|
||||
|
||||
// Add authentication check for event summary page
|
||||
add_action('template_redirect', array($this, 'check_event_summary_auth'));
|
||||
|
||||
// Add authentication check for email attendees page
|
||||
add_action('template_redirect', array($this, 'check_email_attendees_auth'));
|
||||
|
||||
// Add authentication check for certificate pages
|
||||
add_action('template_redirect', array($this, 'check_certificate_pages_auth'));
|
||||
|
||||
// Add authentication check for master dashboard page
|
||||
add_action('template_redirect', array($this, 'check_master_dashboard_auth'));
|
||||
|
||||
// Add authentication check for Google Sheets page
|
||||
add_action('template_redirect', array($this, 'check_google_sheets_auth'));
|
||||
} // End init_hooks
|
||||
|
||||
/**
|
||||
* Check authentication for event summary page
|
||||
*/
|
||||
public function check_event_summary_auth() {
|
||||
// Check if we're on the event-summary page
|
||||
if (is_page('trainer/event/summary') && !is_user_logged_in()) {
|
||||
// Redirect to login page
|
||||
wp_redirect(home_url('/training-login/?redirect_to=' . urlencode($_SERVER['REQUEST_URI'])));
|
||||
exit;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Check authentication for email attendees page
|
||||
*/
|
||||
public function check_email_attendees_auth() {
|
||||
// Check if we're on the email-attendees page
|
||||
if (is_page('trainer/email-attendees') && !is_user_logged_in()) {
|
||||
// Redirect to login page
|
||||
wp_redirect(home_url('/training-login/?redirect_to=' . urlencode($_SERVER['REQUEST_URI'])));
|
||||
exit;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Check authentication for certificate pages
|
||||
*/
|
||||
public function check_certificate_pages_auth() {
|
||||
// Check if we're on certificate-related pages
|
||||
if ((is_page('trainer/certificate-reports') || is_page('trainer/generate-certificates')) && !is_user_logged_in()) {
|
||||
// Redirect to login page
|
||||
wp_redirect(home_url('/training-login/?redirect_to=' . urlencode($_SERVER['REQUEST_URI'])));
|
||||
exit;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Check authentication for master dashboard page
|
||||
*/
|
||||
public function check_master_dashboard_auth() {
|
||||
// Check if we're on the master dashboard page
|
||||
if (is_page('master-trainer/dashboard')) {
|
||||
if (!is_user_logged_in()) {
|
||||
// Redirect to login page
|
||||
wp_redirect(home_url('/training-login/?redirect_to=' . urlencode($_SERVER['REQUEST_URI'])));
|
||||
exit;
|
||||
}
|
||||
|
||||
// Check if user has master dashboard permissions - include administrator
|
||||
if (!current_user_can('view_master_dashboard') && !current_user_can('view_all_trainer_data') && !current_user_can('administrator')) {
|
||||
// Redirect to regular dashboard or show error
|
||||
wp_redirect(home_url('/trainer/dashboard/?error=access_denied'));
|
||||
exit;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Check authentication for Google Sheets page
|
||||
*/
|
||||
public function check_google_sheets_auth() {
|
||||
// Check if we're on the Google Sheets page - use multiple detection methods
|
||||
$is_google_sheets_page = false;
|
||||
|
||||
// Add debug logging
|
||||
if (isset($_GET['hvac_debug']) && $_GET['hvac_debug'] === 'google_sheets') {
|
||||
error_log('HVAC Google Sheets Auth Check - Starting');
|
||||
error_log('Request URI: ' . (isset($_SERVER['REQUEST_URI']) ? $_SERVER['REQUEST_URI'] : 'Not set'));
|
||||
global $post;
|
||||
if ($post) {
|
||||
error_log('Current post ID: ' . $post->ID);
|
||||
error_log('Current post name: ' . $post->post_name);
|
||||
error_log('Current post type: ' . $post->post_type);
|
||||
}
|
||||
}
|
||||
|
||||
// Method 1: Check by page path/slug
|
||||
if (is_page('master-trainer/google-sheets') || is_page('google-sheets')) {
|
||||
$is_google_sheets_page = true;
|
||||
if (isset($_GET['hvac_debug'])) error_log('HVAC Google Sheets: Detected via is_page()');
|
||||
}
|
||||
|
||||
// Method 2: Check by URL
|
||||
if (!$is_google_sheets_page && isset($_SERVER['REQUEST_URI'])) {
|
||||
$uri = $_SERVER['REQUEST_URI'];
|
||||
if (strpos($uri, '/master-trainer/google-sheets') !== false) {
|
||||
$is_google_sheets_page = true;
|
||||
if (isset($_GET['hvac_debug'])) error_log('HVAC Google Sheets: Detected via URL');
|
||||
}
|
||||
}
|
||||
|
||||
// Method 3: Check if current page has Google Sheets shortcode
|
||||
global $post;
|
||||
if (!$is_google_sheets_page && $post && has_shortcode($post->post_content, 'hvac_google_sheets')) {
|
||||
$is_google_sheets_page = true;
|
||||
if (isset($_GET['hvac_debug'])) error_log('HVAC Google Sheets: Detected via shortcode');
|
||||
}
|
||||
|
||||
// Only proceed if we're actually on the Google Sheets page
|
||||
if ($is_google_sheets_page) {
|
||||
// Prevent infinite redirect loops
|
||||
if (isset($_GET['hvac_redirect_check'])) {
|
||||
return; // Already redirected once, don't redirect again
|
||||
}
|
||||
|
||||
if (!is_user_logged_in()) {
|
||||
// Add a parameter to prevent redirect loops
|
||||
$redirect_url = add_query_arg('hvac_redirect_check', '1', home_url('/training-login/?redirect_to=' . urlencode($_SERVER['REQUEST_URI'])));
|
||||
wp_redirect($redirect_url);
|
||||
exit;
|
||||
}
|
||||
|
||||
// Check if user has master dashboard permissions (same as master dashboard)
|
||||
if (!current_user_can('view_master_dashboard') && !current_user_can('view_all_trainer_data') && !current_user_can('manage_options')) {
|
||||
// Add a parameter to prevent redirect loops
|
||||
$redirect_url = add_query_arg('hvac_redirect_check', '1', home_url('/trainer/dashboard/?error=access_denied'));
|
||||
wp_redirect($redirect_url);
|
||||
exit;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Plugin activation (Should be called statically or from the main plugin file context)
|
||||
*/
|
||||
public static function activate() {
|
||||
// Activation code here (e.g., page creation, role creation)
|
||||
// Note: This method might need to be moved or called differently
|
||||
}
|
||||
|
||||
/**
|
||||
* Plugin deactivation (Should be called statically or from the main plugin file context)
|
||||
*/
|
||||
public static function deactivate() {
|
||||
// Remove the hvac_trainer role
|
||||
require_once HVAC_CE_PLUGIN_DIR . 'includes/class-hvac-roles.php'; // Ensure class is available
|
||||
HVAC_Roles::remove_hvac_trainer_role();
|
||||
HVAC_Logger::info('Deactivation completed: HVAC trainer role removed.', 'Core');
|
||||
}
|
||||
|
||||
/**
|
||||
* Initialize function (hooked on 'init')
|
||||
*/
|
||||
public function init() {
|
||||
// Initialize roles
|
||||
$this->init_roles();
|
||||
|
||||
// Initialize settings (admin menu)
|
||||
$this->init_settings();
|
||||
|
||||
// Initialize Zoho admin always (needed for AJAX)
|
||||
$this->init_zoho_admin();
|
||||
|
||||
// Initialize Google Sheets integration (needed for AJAX)
|
||||
$this->init_google_sheets();
|
||||
|
||||
// Initialize admin dashboard if in admin or handling AJAX
|
||||
if (is_admin() || (defined('DOING_AJAX') && DOING_AJAX)) {
|
||||
$this->init_admin_dashboard();
|
||||
}
|
||||
|
||||
// Initialize forms first
|
||||
$this->init_forms();
|
||||
|
||||
// Initialize shortcodes after forms are ready
|
||||
$this->init_shortcodes();
|
||||
|
||||
// Initialize certificate AJAX handler
|
||||
if (class_exists('HVAC_Certificate_AJAX_Handler')) {
|
||||
HVAC_Certificate_AJAX_Handler::instance();
|
||||
}
|
||||
|
||||
// Initialize certificate security
|
||||
if (class_exists('HVAC_Certificate_Security')) {
|
||||
HVAC_Certificate_Security::instance();
|
||||
}
|
||||
|
||||
// Initialize certificate URL handler
|
||||
if (class_exists('HVAC_Certificate_URL_Handler')) {
|
||||
HVAC_Certificate_URL_Handler::instance();
|
||||
}
|
||||
|
||||
// Add manual flush rewrite rules for admins (debugging)
|
||||
if (is_admin() && current_user_can('manage_options') && isset($_GET['hvac_flush_rewrite']) && $_GET['hvac_flush_rewrite'] === '1') {
|
||||
flush_rewrite_rules();
|
||||
wp_die('Rewrite rules flushed. <a href="' . admin_url() . '">Return to admin</a>');
|
||||
}
|
||||
|
||||
// Initialize event form handler
|
||||
if (class_exists('HVAC_Community_Events\Event_Form_Handler')) {
|
||||
new \HVAC_Community_Events\Event_Form_Handler();
|
||||
}
|
||||
|
||||
// Initialize manage event handler
|
||||
if (class_exists('HVAC_Manage_Event')) {
|
||||
new HVAC_Manage_Event();
|
||||
}
|
||||
|
||||
// Initialize dashboard handler
|
||||
if (class_exists('HVAC_Dashboard')) {
|
||||
new HVAC_Dashboard();
|
||||
}
|
||||
|
||||
// Initialize help system (singleton)
|
||||
if (class_exists('HVAC_Help_System')) {
|
||||
HVAC_Help_System::instance();
|
||||
}
|
||||
|
||||
// Initialize communication system
|
||||
$this->init_communication_system();
|
||||
}
|
||||
|
||||
/**
|
||||
* Initialize roles
|
||||
*/
|
||||
private function init_roles() {
|
||||
$roles = new HVAC_Roles();
|
||||
// Note: Role creation is handled in the activate method or the class constructor
|
||||
}
|
||||
|
||||
/**
|
||||
* Initialize settings
|
||||
*/
|
||||
private function init_settings() {
|
||||
new HVAC_Settings();
|
||||
}
|
||||
|
||||
/**
|
||||
* Initialize Zoho admin
|
||||
*/
|
||||
private function init_zoho_admin() {
|
||||
if (file_exists(HVAC_CE_PLUGIN_DIR . 'includes/admin/class-zoho-admin.php')) {
|
||||
require_once HVAC_CE_PLUGIN_DIR . 'includes/admin/class-zoho-admin.php';
|
||||
new HVAC_Zoho_Admin();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Initialize admin dashboard
|
||||
*/
|
||||
private function init_admin_dashboard() {
|
||||
if (file_exists(HVAC_CE_PLUGIN_DIR . 'includes/admin/class-admin-dashboard.php')) {
|
||||
require_once HVAC_CE_PLUGIN_DIR . 'includes/admin/class-admin-dashboard.php';
|
||||
new HVAC_Admin_Dashboard();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Initialize forms
|
||||
*/
|
||||
private function init_forms() {
|
||||
$this->registration = new HVAC_Registration();
|
||||
// Note: Form registration is handled in the class constructor
|
||||
}
|
||||
|
||||
/**
|
||||
* Initialize shortcodes
|
||||
*/
|
||||
private function init_shortcodes() {
|
||||
// Note: Registration form shortcode is registered in HVAC_Registration constructor
|
||||
|
||||
// Community login shortcode - initialize Login_Handler to register the shortcode
|
||||
new \HVAC_Community_Events\Community\Login_Handler();
|
||||
|
||||
// Dashboard shortcode
|
||||
add_shortcode('hvac_dashboard', array($this, 'render_dashboard'));
|
||||
|
||||
// Master Dashboard shortcode
|
||||
add_shortcode('hvac_master_dashboard', array($this, 'render_master_dashboard'));
|
||||
|
||||
// Add the event summary shortcode
|
||||
add_shortcode('hvac_event_summary', array($this, 'render_event_summary'));
|
||||
|
||||
// Add trainer profile shortcode
|
||||
add_shortcode('hvac_trainer_profile', array($this, 'render_trainer_profile'));
|
||||
|
||||
// Note: Edit profile shortcode is registered in HVAC_Registration constructor
|
||||
|
||||
// Add email attendees shortcode
|
||||
add_shortcode('hvac_email_attendees', array($this, 'render_email_attendees'));
|
||||
|
||||
// Add certificate reports shortcode
|
||||
add_shortcode('hvac_certificate_reports', array($this, 'render_certificate_reports'));
|
||||
|
||||
// Add generate certificates shortcode
|
||||
add_shortcode('hvac_generate_certificates', array($this, 'render_generate_certificates'));
|
||||
|
||||
// Certificate fix shortcode is handled by the Certificate Fix class
|
||||
// to avoid duplicate registration and missing method issues
|
||||
|
||||
// Add Google Sheets admin shortcode
|
||||
add_shortcode('hvac_google_sheets', array($this, 'render_google_sheets_admin'));
|
||||
|
||||
// Add communication templates shortcode
|
||||
add_shortcode('hvac_communication_templates', array($this, 'render_communication_templates'));
|
||||
|
||||
// Add communication schedules shortcode
|
||||
add_shortcode('hvac_communication_schedules', array($this, 'render_communication_schedules'));
|
||||
|
||||
// Removed shortcode override - let The Events Calendar Community Events handle this shortcode
|
||||
// add_shortcode('tribe_community_events', array($this, 'render_tribe_community_events'));
|
||||
|
||||
// Add future shortcodes here
|
||||
}
|
||||
|
||||
/**
|
||||
* Render dashboard content
|
||||
*/
|
||||
public function render_dashboard() {
|
||||
if (!is_user_logged_in()) {
|
||||
return '<p>Please log in to view the dashboard.</p>';
|
||||
}
|
||||
|
||||
// Include the dashboard template
|
||||
ob_start();
|
||||
include HVAC_CE_PLUGIN_DIR . 'templates/template-hvac-dashboard.php';
|
||||
return ob_get_clean();
|
||||
}
|
||||
|
||||
/**
|
||||
* Render master dashboard content
|
||||
*/
|
||||
public function render_master_dashboard() {
|
||||
if (!is_user_logged_in()) {
|
||||
return '<p>Please log in to view the master dashboard.</p>';
|
||||
}
|
||||
|
||||
// Check if user has master dashboard permissions - include administrator
|
||||
if (!current_user_can('view_master_dashboard') && !current_user_can('view_all_trainer_data') && !current_user_can('administrator')) {
|
||||
return '<div class="hvac-error">You do not have permission to view the master dashboard. This dashboard is only available to Master Trainers and Administrators.</div>';
|
||||
}
|
||||
|
||||
// Include the master dashboard template
|
||||
ob_start();
|
||||
include HVAC_CE_PLUGIN_DIR . 'templates/template-hvac-master-dashboard.php';
|
||||
return ob_get_clean();
|
||||
}
|
||||
|
||||
/**
|
||||
* Render event summary content
|
||||
*/
|
||||
public function render_event_summary() {
|
||||
// Check if user is logged in
|
||||
if (!is_user_logged_in()) {
|
||||
return '<p>Please log in to view the event summary.</p>';
|
||||
}
|
||||
|
||||
// Get event ID from URL parameter
|
||||
$event_id = isset($_GET['event_id']) ? absint($_GET['event_id']) : 0;
|
||||
|
||||
if ($event_id <= 0) {
|
||||
return '<div class="hvac-error">No event ID provided. Please access this page from your dashboard.</div>';
|
||||
}
|
||||
|
||||
// Check if the event exists and user has permission to view it
|
||||
$event = get_post($event_id);
|
||||
if (!$event || get_post_type($event) !== Tribe__Events__Main::POSTTYPE) {
|
||||
return '<div class="hvac-error">Event not found or invalid.</div>';
|
||||
}
|
||||
|
||||
// Check if the current user has permission to view this event
|
||||
// For now, we'll check if they're the post author or have edit_posts capability
|
||||
if ($event->post_author != get_current_user_id() && !current_user_can('edit_posts')) {
|
||||
return '<div class="hvac-error">You do not have permission to view this event summary.</div>';
|
||||
}
|
||||
|
||||
// Include the event summary template
|
||||
ob_start();
|
||||
include HVAC_CE_PLUGIN_DIR . 'templates/event-summary/template-event-summary.php';
|
||||
return ob_get_clean();
|
||||
}
|
||||
|
||||
/**
|
||||
* Render trainer profile content
|
||||
*/
|
||||
public function render_trainer_profile() {
|
||||
if (!is_user_logged_in()) {
|
||||
return '<p>Please log in to view your profile.</p>';
|
||||
}
|
||||
|
||||
// Include the trainer profile template
|
||||
ob_start();
|
||||
include HVAC_CE_PLUGIN_DIR . 'templates/template-trainer-profile.php';
|
||||
return ob_get_clean();
|
||||
}
|
||||
|
||||
/**
|
||||
* Render email attendees content
|
||||
*/
|
||||
public function render_email_attendees() {
|
||||
// Check if user is logged in
|
||||
if (!is_user_logged_in()) {
|
||||
return '<p>Please log in to email event attendees.</p>';
|
||||
}
|
||||
|
||||
// Get event ID from URL parameter
|
||||
$event_id = isset($_GET['event_id']) ? absint($_GET['event_id']) : 0;
|
||||
|
||||
if ($event_id <= 0) {
|
||||
return '<div class="hvac-error">No event ID provided. Please access this page from your dashboard or event summary page.</div>';
|
||||
}
|
||||
|
||||
// Check if the event exists and user has permission to view it
|
||||
$event = get_post($event_id);
|
||||
if (!$event || get_post_type($event) !== Tribe__Events__Main::POSTTYPE) {
|
||||
return '<div class="hvac-error">Event not found or invalid.</div>';
|
||||
}
|
||||
|
||||
// Check if the current user has permission to view this event
|
||||
// For now, we'll check if they're the post author or have edit_posts capability
|
||||
if ($event->post_author != get_current_user_id() && !current_user_can('edit_posts')) {
|
||||
return '<div class="hvac-error">You do not have permission to email attendees for this event.</div>';
|
||||
}
|
||||
|
||||
// Include the email attendees template
|
||||
ob_start();
|
||||
include HVAC_CE_PLUGIN_DIR . 'templates/email-attendees/template-email-attendees.php';
|
||||
return ob_get_clean();
|
||||
}
|
||||
|
||||
/**
|
||||
* Validate template file for common syntax errors
|
||||
* @param string $file_path Path to the template file
|
||||
* @return bool|string True if valid, error message otherwise
|
||||
*/
|
||||
private function validate_template_file($file_path) {
|
||||
// Check if the file exists
|
||||
if (!file_exists($file_path)) {
|
||||
return "Template file does not exist: {$file_path}";
|
||||
}
|
||||
|
||||
// Get file contents
|
||||
$content = file_get_contents($file_path);
|
||||
|
||||
// Check for common syntax errors with escaped operators
|
||||
$common_errors = [
|
||||
'\\!==', // Escaped !==
|
||||
'\\!=' , // Escaped !=
|
||||
'\\!' , // Escaped !
|
||||
'\\=' , // Escaped =
|
||||
'\\>' , // Escaped >
|
||||
'\\<' , // Escaped <
|
||||
];
|
||||
|
||||
foreach ($common_errors as $error) {
|
||||
if (strpos($content, $error) !== false) {
|
||||
// Find the line number
|
||||
$lines = explode("\n", $content);
|
||||
$line_number = 0;
|
||||
foreach ($lines as $i => $line) {
|
||||
if (strpos($line, $error) !== false) {
|
||||
$line_number = $i + 1;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// Log the error for admin
|
||||
$filename = basename($file_path);
|
||||
HVAC_Logger::error("Syntax error detected in {$filename} line {$line_number}: Improper escape sequence {$error}", 'Core');
|
||||
|
||||
return "Template file contains syntax errors: {$filename} line {$line_number}. Please contact the administrator.";
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Render certificate reports content
|
||||
*/
|
||||
public function render_certificate_reports() {
|
||||
// Check if user is logged in
|
||||
if (!is_user_logged_in()) {
|
||||
return '<p>Please log in to view certificate reports.</p>';
|
||||
}
|
||||
|
||||
// Check if the current user has permission to view certificate reports
|
||||
// For now, we'll check if they're a trainer or have edit_posts capability
|
||||
if (!current_user_can('hvac_trainer') && !current_user_can('edit_posts')) {
|
||||
return '<div class="hvac-error">You do not have permission to view certificate reports.</div>';
|
||||
}
|
||||
|
||||
// Make sure certificate manager is loaded
|
||||
require_once HVAC_CE_PLUGIN_DIR . 'includes/certificates/class-certificate-manager.php';
|
||||
|
||||
// Make sure certificate security is loaded
|
||||
require_once HVAC_CE_PLUGIN_DIR . 'includes/certificates/class-certificate-security.php';
|
||||
|
||||
// Validate the template file before including
|
||||
$template_path = HVAC_CE_PLUGIN_DIR . 'templates/certificates/template-certificate-reports.php';
|
||||
$validation = $this->validate_template_file($template_path);
|
||||
if ($validation !== true) {
|
||||
return '<div class="hvac-error">' . esc_html($validation) . '</div>';
|
||||
}
|
||||
|
||||
// Include the certificate reports template with error handling
|
||||
try {
|
||||
ob_start();
|
||||
include $template_path;
|
||||
return ob_get_clean();
|
||||
} catch (Exception $e) {
|
||||
return '<div class="hvac-error">Error loading certificate reports: ' . esc_html($e->getMessage()) . '</div>';
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Render generate certificates content
|
||||
*/
|
||||
public function render_generate_certificates() {
|
||||
// Check if user is logged in
|
||||
if (!is_user_logged_in()) {
|
||||
return '<p>Please log in to generate certificates.</p>';
|
||||
}
|
||||
|
||||
// Get event ID from URL parameter if available
|
||||
$event_id = isset($_GET['event_id']) ? absint($_GET['event_id']) : 0;
|
||||
|
||||
// Check if the event exists and user has permission to view it when event_id is provided
|
||||
if ($event_id > 0) {
|
||||
$event = get_post($event_id);
|
||||
if (!$event || get_post_type($event) !== Tribe__Events__Main::POSTTYPE) {
|
||||
return '<div class="hvac-error">Event not found or invalid.</div>';
|
||||
}
|
||||
|
||||
// Check if the current user has permission to view this event
|
||||
if ($event->post_author != get_current_user_id() && !current_user_can('edit_posts')) {
|
||||
return '<div class="hvac-error">You do not have permission to generate certificates for this event.</div>';
|
||||
}
|
||||
} else {
|
||||
// If no event ID is provided, check general permissions
|
||||
if (!current_user_can('hvac_trainer') && !current_user_can('edit_posts')) {
|
||||
return '<div class="hvac-error">You do not have permission to generate certificates.</div>';
|
||||
}
|
||||
}
|
||||
|
||||
// Make sure certificate manager is loaded
|
||||
require_once HVAC_CE_PLUGIN_DIR . 'includes/certificates/class-certificate-manager.php';
|
||||
|
||||
// Make sure certificate security is loaded
|
||||
require_once HVAC_CE_PLUGIN_DIR . 'includes/certificates/class-certificate-security.php';
|
||||
|
||||
// Make sure certificate generator is loaded
|
||||
require_once HVAC_CE_PLUGIN_DIR . 'includes/certificates/class-certificate-generator.php';
|
||||
|
||||
// Validate the template file before including
|
||||
$template_path = HVAC_CE_PLUGIN_DIR . 'templates/certificates/template-generate-certificates.php';
|
||||
$validation = $this->validate_template_file($template_path);
|
||||
if ($validation !== true) {
|
||||
return '<div class="hvac-error">' . esc_html($validation) . '</div>';
|
||||
}
|
||||
|
||||
// Include the generate certificates template with error handling
|
||||
try {
|
||||
ob_start();
|
||||
include $template_path;
|
||||
return ob_get_clean();
|
||||
} catch (Exception $e) {
|
||||
return '<div class="hvac-error">Error loading certificate generation: ' . esc_html($e->getMessage()) . '</div>';
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Include custom templates for plugin pages
|
||||
*/
|
||||
public function load_custom_templates($template) {
|
||||
$custom_template = null;
|
||||
|
||||
// Check for dashboard page
|
||||
if (is_page('trainer/dashboard')) {
|
||||
$custom_template = HVAC_CE_PLUGIN_DIR . 'templates/template-hvac-dashboard.php';
|
||||
}
|
||||
|
||||
// Check for master dashboard page
|
||||
if (is_page('master-trainer/dashboard')) {
|
||||
$custom_template = HVAC_CE_PLUGIN_DIR . 'templates/template-hvac-master-dashboard.php';
|
||||
}
|
||||
|
||||
// Check for google-sheets page
|
||||
if (is_page('master-trainer/google-sheets')) {
|
||||
$custom_template = HVAC_CE_PLUGIN_DIR . 'templates/template-google-sheets.php';
|
||||
}
|
||||
|
||||
// Check for community-login page
|
||||
if (is_page('training-login')) {
|
||||
$custom_template = HVAC_CE_PLUGIN_DIR . 'templates/page-community-login.php';
|
||||
}
|
||||
|
||||
|
||||
// Check for trainer-profile page
|
||||
if (is_page('trainer/my-profile')) {
|
||||
$custom_template = HVAC_CE_PLUGIN_DIR . 'templates/template-trainer-profile.php';
|
||||
}
|
||||
|
||||
// Check for event-summary page
|
||||
if (is_page('trainer/event/summary')) {
|
||||
$custom_template = HVAC_CE_PLUGIN_DIR . 'templates/template-event-summary.php';
|
||||
}
|
||||
|
||||
// Check for email-attendees page
|
||||
if (is_page('trainer/email-attendees')) {
|
||||
$custom_template = HVAC_CE_PLUGIN_DIR . 'templates/email-attendees/template-email-attendees.php';
|
||||
}
|
||||
|
||||
// Check for certificate-reports page
|
||||
if (is_page('trainer/certificate-reports')) {
|
||||
$custom_template = HVAC_CE_PLUGIN_DIR . 'templates/certificates/template-certificate-reports.php';
|
||||
}
|
||||
|
||||
// Check for generate-certificates page
|
||||
if (is_page('trainer/generate-certificates')) {
|
||||
$custom_template = HVAC_CE_PLUGIN_DIR . 'templates/certificates/template-generate-certificates.php';
|
||||
}
|
||||
|
||||
// Check for edit-profile page
|
||||
if (is_page('edit-profile')) {
|
||||
$custom_template = HVAC_CE_PLUGIN_DIR . 'templates/template-edit-profile.php';
|
||||
}
|
||||
|
||||
// Check for communication-templates page
|
||||
if (is_page('trainer/communication-templates')) {
|
||||
$custom_template = HVAC_CE_PLUGIN_DIR . 'templates/communication/template-communication-templates.php';
|
||||
}
|
||||
|
||||
// Check for single event view (temporary)
|
||||
if (is_singular('tribe_events')) {
|
||||
$custom_template = HVAC_CE_PLUGIN_DIR . 'templates/single-tribe_events.php';
|
||||
}
|
||||
|
||||
// Process the custom template if one was found
|
||||
if ($custom_template !== null) {
|
||||
// Check if file exists
|
||||
if (file_exists($custom_template)) {
|
||||
// Validate certificate templates for syntax errors
|
||||
if (strpos($custom_template, 'certificates/') !== false) {
|
||||
$validation = $this->validate_template_file($custom_template);
|
||||
if ($validation !== true) {
|
||||
// Log error and show friendly message
|
||||
HVAC_Logger::error("Template validation failed in load_custom_templates: {$validation}", 'Core');
|
||||
|
||||
// Display error or fallback template
|
||||
add_action('wp_head', function() use ($validation) {
|
||||
echo '<div class="hvac-error">There was a problem loading this page. ' .
|
||||
'The administrator has been notified. Please try again later.</div>';
|
||||
});
|
||||
|
||||
// Either fall back to the standard WP template or use a simple error template
|
||||
return $template;
|
||||
}
|
||||
}
|
||||
|
||||
// Template exists and passes validation
|
||||
return $custom_template;
|
||||
}
|
||||
}
|
||||
|
||||
return $template;
|
||||
} // End load_custom_templates
|
||||
|
||||
// REMOVED: render_tribe_community_events() method
|
||||
// This method was overriding The Events Calendar Community Events shortcode
|
||||
// Let TEC handle the shortcode properly instead
|
||||
|
||||
/**
|
||||
* Render Google Sheets admin content
|
||||
*/
|
||||
public function render_google_sheets_admin() {
|
||||
if (!is_user_logged_in()) {
|
||||
return '<p>Please log in to access Google Sheets integration.</p>';
|
||||
}
|
||||
|
||||
// Check if user has master dashboard permissions
|
||||
if (!current_user_can('view_master_dashboard') && !current_user_can('view_all_trainer_data') && !current_user_can('manage_options')) {
|
||||
return '<p>You do not have permission to access Google Sheets integration.</p>';
|
||||
}
|
||||
|
||||
// Initialize Google Sheets admin if not already done
|
||||
if (!class_exists('HVAC_Google_Sheets_Admin')) {
|
||||
require_once HVAC_CE_PLUGIN_DIR . 'includes/google-sheets/class-google-sheets-admin.php';
|
||||
}
|
||||
|
||||
$google_sheets_admin = new HVAC_Google_Sheets_Admin();
|
||||
|
||||
ob_start();
|
||||
$google_sheets_admin->render_admin_page();
|
||||
return ob_get_clean();
|
||||
}
|
||||
|
||||
/**
|
||||
* Initialize Google Sheets integration
|
||||
*/
|
||||
private function init_google_sheets() {
|
||||
// Always initialize auth handler for OAuth callbacks
|
||||
if (file_exists(HVAC_CE_PLUGIN_DIR . 'includes/google-sheets/class-google-sheets-auth.php')) {
|
||||
require_once HVAC_CE_PLUGIN_DIR . 'includes/google-sheets/class-google-sheets-auth.php';
|
||||
new HVAC_Google_Sheets_Auth();
|
||||
}
|
||||
|
||||
// Initialize admin interface
|
||||
if (file_exists(HVAC_CE_PLUGIN_DIR . 'includes/google-sheets/class-google-sheets-admin.php')) {
|
||||
require_once HVAC_CE_PLUGIN_DIR . 'includes/google-sheets/class-google-sheets-admin.php';
|
||||
new HVAC_Google_Sheets_Admin();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Initialize communication system
|
||||
*/
|
||||
private function init_communication_system() {
|
||||
// Check and install/update communication database tables
|
||||
if (class_exists('HVAC_Communication_Installer')) {
|
||||
HVAC_Communication_Installer::maybe_update();
|
||||
}
|
||||
|
||||
// Initialize the communication scheduler (singleton)
|
||||
if (class_exists('HVAC_Communication_Scheduler')) {
|
||||
hvac_communication_scheduler();
|
||||
}
|
||||
|
||||
if (class_exists('HVAC_Logger')) {
|
||||
HVAC_Logger::info('Communication system initialized', 'Communication System');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Render communication templates content
|
||||
*/
|
||||
public function render_communication_templates() {
|
||||
if (!is_user_logged_in()) {
|
||||
return '<p>Please log in to manage communication templates.</p>';
|
||||
}
|
||||
|
||||
// Check if user is a trainer or has permission to manage templates
|
||||
$current_user = wp_get_current_user();
|
||||
if (!in_array('hvac_trainer', $current_user->roles) && !current_user_can('edit_posts')) {
|
||||
return '<p>You do not have permission to manage communication templates.</p>';
|
||||
}
|
||||
|
||||
// Initialize the communication templates class
|
||||
if (!class_exists('HVAC_Communication_Templates')) {
|
||||
require_once HVAC_CE_PLUGIN_DIR . 'includes/communication/class-communication-templates.php';
|
||||
}
|
||||
|
||||
ob_start();
|
||||
include HVAC_CE_PLUGIN_DIR . 'templates/communication/template-communication-templates.php';
|
||||
return ob_get_clean();
|
||||
}
|
||||
|
||||
/**
|
||||
* Render communication schedules content
|
||||
*/
|
||||
public function render_communication_schedules() {
|
||||
if (!is_user_logged_in()) {
|
||||
return '<p>Please log in to manage communication schedules.</p>';
|
||||
}
|
||||
|
||||
// Check if user is a trainer or has permission to manage schedules
|
||||
$current_user = wp_get_current_user();
|
||||
if (!in_array('hvac_trainer', $current_user->roles) && !current_user_can('edit_posts')) {
|
||||
return '<p>You do not have permission to manage communication schedules.</p>';
|
||||
}
|
||||
|
||||
// Initialize the communication scheduler class
|
||||
if (!class_exists('HVAC_Communication_Scheduler')) {
|
||||
require_once HVAC_CE_PLUGIN_DIR . 'includes/communication/class-communication-scheduler.php';
|
||||
}
|
||||
|
||||
ob_start();
|
||||
include HVAC_CE_PLUGIN_DIR . 'templates/communication/template-communication-schedules.php';
|
||||
return ob_get_clean();
|
||||
}
|
||||
|
||||
} // End class HVAC_Community_Events
|
||||
89
includes/class-hvac-event-manage-header.php
Normal file
89
includes/class-hvac-event-manage-header.php
Normal file
|
|
@ -0,0 +1,89 @@
|
|||
<?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() {
|
||||
add_action('tribe_events_community_before_event_submission_page', array($this, 'render_header'));
|
||||
add_filter('the_content', array($this, 'add_header_to_event_manage_page'), 5);
|
||||
}
|
||||
|
||||
/**
|
||||
* Add header to event manage page content
|
||||
*/
|
||||
public function add_header_to_event_manage_page($content) {
|
||||
// Only add on event manage pages
|
||||
if (!is_page('trainer/event/manage') && !is_page('manage-event') && !is_page('trainer-event-manage')) {
|
||||
return $content;
|
||||
}
|
||||
|
||||
// Check if we're displaying the tribe community events form
|
||||
if (strpos($content, 'tribe_community_events') === false && strpos($content, 'tribe-community-events') === false) {
|
||||
return $content;
|
||||
}
|
||||
|
||||
// Get the header HTML
|
||||
$header = $this->get_header_html();
|
||||
|
||||
// Add header before the content
|
||||
return $header . $content;
|
||||
}
|
||||
|
||||
/**
|
||||
* 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>
|
||||
</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();
|
||||
Loading…
Reference in a new issue