# HVAC Plugin API Reference ## Table of Contents - [PHP Classes](#php-classes) - [JavaScript APIs](#javascript-apis) - [WordPress Hooks](#wordpress-hooks) - [AJAX Endpoints](#ajax-endpoints) - [Shortcodes](#shortcodes) - [Database Schema](#database-schema) ## PHP Classes ### HVAC_Plugin Main plugin initialization class. ```php class HVAC_Plugin { /** * Get plugin instance (Singleton) * @return HVAC_Plugin */ public static function instance() /** * Initialize plugin components * @return void */ public function init() } ``` ### HVAC_Event_Manager Manages event creation and manipulation. ```php class HVAC_Event_Manager { /** * Create a new event * @param array $event_data Event information * @return int|WP_Error Event ID or error */ public static function create_event($event_data) /** * Get trainer events * @param int $trainer_id Trainer user ID * @param array $args Query arguments * @return array Array of event objects */ public static function get_trainer_events($trainer_id, $args = array()) /** * Update event * @param int $event_id Event ID * @param array $data Event data to update * @return bool Success status */ public static function update_event($event_id, $data) } ``` ### HVAC_Certificate_Generator Handles PDF certificate generation. ```php class HVAC_Certificate_Generator { /** * Generate certificate for attendee * @param int $event_id Event ID * @param array $attendee Attendee data * @return string|WP_Error PDF file path or error */ public function generate_certificate($event_id, $attendee) /** * Generate bulk certificates * @param int $event_id Event ID * @param array $attendees Array of attendee data * @return array Results array with successes and failures */ public function generate_bulk_certificates($event_id, $attendees) } ``` ### HVAC_Trainer_Profile Manages trainer profile functionality. ```php class HVAC_Trainer_Profile { /** * Get trainer profile data * @param int $trainer_id User ID * @return array Profile data */ public static function get_profile($trainer_id) /** * Update trainer profile * @param int $trainer_id User ID * @param array $data Profile data * @return bool Success status */ public static function update_profile($trainer_id, $data) /** * Get trainer statistics * @param int $trainer_id User ID * @return array Statistics data */ public static function get_statistics($trainer_id) } ``` ### HVAC_Menu_System Handles navigation menu rendering. ```php class HVAC_Menu_System { /** * Render trainer navigation menu * @return void Outputs HTML */ public function render_trainer_menu() /** * Get menu structure for current user * @return array Menu items array */ private function get_menu_structure() } ``` ## JavaScript APIs ### Global Objects ```javascript // Main HVAC object window.HVAC = { // Initialize components init: function() {}, // Event management events: { create: function(data) {}, update: function(eventId, data) {}, delete: function(eventId) {} }, // Profile management profile: { load: function(userId) {}, save: function(data) {}, uploadPhoto: function(file) {} }, // Utilities utils: { showMessage: function(message, type) {}, confirm: function(message, callback) {}, formatDate: function(date) {} } }; // AJAX helper window.hvacAjax = { post: function(action, data, success, error) {}, get: function(action, data, success, error) {} }; ``` ### jQuery Plugins ```javascript // Dashboard initialization jQuery(document).ready(function($) { // Initialize date pickers $('.hvac-datepicker').datepicker({ dateFormat: 'yy-mm-dd' }); // Initialize form validation $('.hvac-form').validate({ rules: { event_title: 'required', event_date: 'required' } }); }); ``` ## WordPress Hooks ### Actions ```php // Plugin lifecycle do_action('hvac_plugin_activated'); do_action('hvac_plugin_deactivated'); do_action('hvac_plugin_updated', $old_version, $new_version); // Page creation do_action('hvac_before_create_pages'); do_action('hvac_after_create_pages', $page_ids); // Event management do_action('hvac_before_event_save', $event_data); do_action('hvac_after_event_save', $event_id, $event_data); do_action('hvac_event_deleted', $event_id); // Certificate generation do_action('hvac_before_certificate_generate', $event_id, $attendee); do_action('hvac_after_certificate_generate', $certificate_path); // User profile do_action('hvac_profile_updated', $user_id, $profile_data); do_action('hvac_trainer_registered', $user_id); ``` ### Filters ```php // Capability checks apply_filters('hvac_user_can_manage_event', $can_manage, $user_id, $event_id); apply_filters('hvac_user_can_generate_certificates', $can_generate, $user_id); // Data manipulation apply_filters('hvac_event_data', $event_data, $event_id); apply_filters('hvac_certificate_data', $certificate_data, $event_id, $attendee); apply_filters('hvac_profile_fields', $fields, $user_id); // Display filters apply_filters('hvac_menu_items', $menu_items, $user_role); apply_filters('hvac_dashboard_widgets', $widgets, $user_id); apply_filters('hvac_date_format', $format); // Query filters apply_filters('hvac_events_query_args', $args, $context); apply_filters('hvac_trainers_query_args', $args); ``` ## Template System ### HVAC_Community_Events Template Loading The plugin uses a custom template loading system via the `template_include` filter. ```php class HVAC_Community_Events { /** * Load custom templates for HVAC pages * @param string $template Current template path * @return string Modified template path */ public function load_custom_templates($template) } ``` **Template Mappings:** ```php // Certificate pages use full page templates 'trainer/certificate-reports' => 'templates/page-certificate-reports.php' 'trainer/generate-certificates' => 'templates/page-generate-certificates.php' // Dashboard pages 'trainer/dashboard' => 'templates/template-hvac-dashboard.php' 'master-trainer/master-dashboard' => 'templates/template-hvac-master-dashboard.php' // Other pages 'trainer/event/manage' => 'templates/page-manage-event.php' // Event management with creation guide 'trainer/profile' => 'templates/page-trainer-profile.php' ``` **Template Structure Requirements:** All HVAC page templates must include: ```php // Define constant to indicate page template context define('HVAC_IN_PAGE_TEMPLATE', true); get_header(); // Required: WordPress header ?>