diff --git a/includes/class-hvac-activator.php b/includes/class-hvac-activator.php
index f35ee74d..46ab2cd6 100644
--- a/includes/class-hvac-activator.php
+++ b/includes/class-hvac-activator.php
@@ -84,6 +84,11 @@ class HVAC_Activator {
require_once(ABSPATH . 'wp-admin/includes/upgrade.php');
dbDelta($sql);
+ // Create contact submissions table for Find a Trainer feature
+ if (class_exists('HVAC_Contact_Submissions_Table')) {
+ HVAC_Contact_Submissions_Table::create_table();
+ }
+
HVAC_Logger::info('Database tables created', 'Activator');
}
diff --git a/includes/class-hvac-page-manager.php b/includes/class-hvac-page-manager.php
index 20ba9e40..78242ae9 100644
--- a/includes/class-hvac-page-manager.php
+++ b/includes/class-hvac-page-manager.php
@@ -31,6 +31,13 @@ class HVAC_Page_Manager {
'parent' => null,
'capability' => null
],
+ 'find-a-trainer' => [
+ 'title' => 'Find a Trainer',
+ 'template' => 'page-find-trainer.php',
+ 'public' => true,
+ 'parent' => null,
+ 'capability' => null
+ ],
// Trainer pages
'trainer' => [
diff --git a/includes/class-hvac-plugin.php b/includes/class-hvac-plugin.php
index 03ee9d98..d4ab168e 100644
--- a/includes/class-hvac-plugin.php
+++ b/includes/class-hvac-plugin.php
@@ -59,6 +59,9 @@ class HVAC_Plugin {
if (!defined('HVAC_PLUGIN_VERSION')) {
define('HVAC_PLUGIN_VERSION', '1.0.1');
}
+ if (!defined('HVAC_VERSION')) {
+ define('HVAC_VERSION', '1.0.1');
+ }
if (!defined('HVAC_PLUGIN_FILE')) {
define('HVAC_PLUGIN_FILE', dirname(__DIR__) . '/hvac-community-events.php');
}
@@ -134,6 +137,15 @@ class HVAC_Plugin {
'class-hvac-page-content-fixer.php',
];
+ // Find a Trainer feature includes
+ $find_trainer_includes = [
+ 'database/class-hvac-contact-submissions-table.php',
+ 'find-trainer/class-hvac-find-trainer-page.php',
+ 'find-trainer/class-hvac-mapgeo-integration.php',
+ 'find-trainer/class-hvac-contact-form-handler.php',
+ 'find-trainer/class-hvac-trainer-directory-query.php',
+ ];
+
foreach ($feature_includes as $file) {
$file_path = HVAC_PLUGIN_DIR . 'includes/' . $file;
if (file_exists($file_path)) {
@@ -141,6 +153,14 @@ class HVAC_Plugin {
}
}
+ // Include Find a Trainer feature files
+ foreach ($find_trainer_includes as $file) {
+ $file_path = HVAC_PLUGIN_DIR . 'includes/' . $file;
+ if (file_exists($file_path)) {
+ require_once $file_path;
+ }
+ }
+
// Community includes
if (file_exists(HVAC_PLUGIN_DIR . 'includes/community/class-login-handler.php')) {
require_once HVAC_PLUGIN_DIR . 'includes/community/class-login-handler.php';
@@ -257,6 +277,9 @@ class HVAC_Plugin {
// Admin init
add_action('admin_init', [$this, 'admin_init']);
+ // Initialize Find a Trainer feature
+ add_action('init', [$this, 'initialize_find_trainer'], 20);
+
// AJAX handlers
add_action('wp_ajax_hvac_master_dashboard_events', [$this, 'ajax_master_dashboard_events']);
add_action('wp_ajax_nopriv_hvac_master_dashboard_events', [$this, 'ajax_master_dashboard_events']);
@@ -460,6 +483,33 @@ class HVAC_Plugin {
}
}
+ /**
+ * Initialize Find a Trainer feature
+ *
+ * @return void
+ */
+ public function initialize_find_trainer() {
+ // Initialize Find a Trainer page
+ if (class_exists('HVAC_Find_Trainer_Page')) {
+ HVAC_Find_Trainer_Page::get_instance();
+ }
+
+ // Initialize MapGeo integration
+ if (class_exists('HVAC_MapGeo_Integration')) {
+ HVAC_MapGeo_Integration::get_instance();
+ }
+
+ // Initialize contact form handler
+ if (class_exists('HVAC_Contact_Form_Handler')) {
+ HVAC_Contact_Form_Handler::get_instance();
+ }
+
+ // Initialize trainer directory query
+ if (class_exists('HVAC_Trainer_Directory_Query')) {
+ HVAC_Trainer_Directory_Query::get_instance();
+ }
+ }
+
/**
* Plugins loaded hook
*
diff --git a/scripts/analyze-mapgeo-data.sh b/scripts/analyze-mapgeo-data.sh
new file mode 100755
index 00000000..063fb916
--- /dev/null
+++ b/scripts/analyze-mapgeo-data.sh
@@ -0,0 +1,117 @@
+#!/bin/bash
+
+# Analyze MapGeo data structure
+# Usage: ./scripts/analyze-mapgeo-data.sh
+
+source .env
+
+echo "=== Analyzing MapGeo Data Structure ==="
+
+ssh -o StrictHostKeyChecking=no "$UPSKILL_STAGING_SSH_USER@$UPSKILL_STAGING_IP" << 'ENDSSH'
+cd /home/974670.cloudwaysapps.com/uberrxmprk/public_html
+
+echo "=== Getting map metadata for ID 5872 ==="
+wp eval '
+$map_id = 5872;
+$meta = get_post_meta($map_id);
+
+echo "Post meta keys for map $map_id:\n";
+foreach ($meta as $key => $values) {
+ if (strpos($key, "_") !== 0) { // Skip private meta
+ echo " $key: ";
+ $value = $values[0];
+ if (is_serialized($value)) {
+ $unserialized = unserialize($value);
+ if (is_array($unserialized)) {
+ echo "array with " . count($unserialized) . " items\n";
+ if (isset($unserialized["markers"])) {
+ echo " - Has markers: " . count($unserialized["markers"]) . "\n";
+ }
+ if (isset($unserialized["regions"])) {
+ echo " - Has regions: " . count($unserialized["regions"]) . "\n";
+ }
+ } else {
+ echo gettype($unserialized) . "\n";
+ }
+ } else {
+ echo substr($value, 0, 100) . (strlen($value) > 100 ? "..." : "") . "\n";
+ }
+ }
+}
+'
+
+echo -e "\n=== Checking igm_maps option ==="
+wp eval '
+$maps_data = get_option("igm_maps");
+if ($maps_data) {
+ echo "igm_maps option exists\n";
+ if (is_array($maps_data)) {
+ echo "Contains " . count($maps_data) . " maps\n";
+ if (isset($maps_data[5872])) {
+ echo "Map 5872 data found in option\n";
+ $map = $maps_data[5872];
+ if (is_array($map)) {
+ echo "Map data keys: " . implode(", ", array_keys($map)) . "\n";
+ }
+ }
+ }
+} else {
+ echo "No igm_maps option found\n";
+}
+'
+
+echo -e "\n=== Testing igm_add_meta filter directly ==="
+wp eval '
+// Simulate what the plugin does
+$map_id = 5872;
+$meta = get_post_meta($map_id, "map_info", true);
+
+if ($meta) {
+ echo "Original meta structure:\n";
+ echo " Type: " . gettype($meta) . "\n";
+ if (is_array($meta)) {
+ echo " Keys: " . implode(", ", array_keys($meta)) . "\n";
+ if (isset($meta["id"])) {
+ echo " Map ID in meta: " . $meta["id"] . "\n";
+ }
+ }
+
+ // Apply the filter as the plugin would
+ echo "\nApplying igm_add_meta filter...\n";
+ $filtered = apply_filters("igm_add_meta", $meta);
+
+ if ($filtered !== $meta) {
+ echo "Meta was modified by filters\n";
+ if (is_array($filtered)) {
+ echo " New keys: " . implode(", ", array_keys($filtered)) . "\n";
+ }
+ } else {
+ echo "Meta unchanged by filters\n";
+ }
+} else {
+ echo "No map_info meta found for map $map_id\n";
+}
+'
+
+echo -e "\n=== Checking how maps are rendered ==="
+wp eval '
+// Check what happens when we render a map
+echo "Attempting to render map 5872...\n";
+$shortcode_output = do_shortcode("[display-map id=\"5872\"]");
+if (strpos($shortcode_output, "error") !== false || strpos($shortcode_output, "Error") !== false) {
+ echo "Error in shortcode output: " . strip_tags($shortcode_output) . "\n";
+} else {
+ echo "Shortcode rendered successfully\n";
+ // Check if it contains expected elements
+ if (strpos($shortcode_output, "igm-map") !== false) {
+ echo " Contains igm-map element\n";
+ }
+ if (strpos($shortcode_output, "data-map-id") !== false) {
+ echo " Contains data-map-id attribute\n";
+ }
+}
+'
+
+ENDSSH
+
+echo "=== Analysis Complete ==="
\ No newline at end of file
diff --git a/scripts/create-find-trainer-page.sh b/scripts/create-find-trainer-page.sh
new file mode 100755
index 00000000..e20432b5
--- /dev/null
+++ b/scripts/create-find-trainer-page.sh
@@ -0,0 +1,162 @@
+#!/bin/bash
+
+# Create Find a Trainer page on staging
+# Usage: ./scripts/create-find-trainer-page.sh
+
+source .env
+
+echo "=== Creating Find a Trainer Page on Staging ==="
+
+# SSH into staging and create the page
+ssh -o StrictHostKeyChecking=no "$UPSKILL_STAGING_SSH_USER@$UPSKILL_STAGING_IP" << 'ENDSSH'
+cd /home/974670.cloudwaysapps.com/uberrxmprk/public_html
+
+# Create the Find a Trainer page via WP-CLI
+wp eval '
+// Initialize Find a Trainer page
+if (class_exists("HVAC_Find_Trainer_Page")) {
+ $finder = HVAC_Find_Trainer_Page::get_instance();
+ $finder->register_page();
+ echo "Find a Trainer page initialization triggered\n";
+}
+
+// Also directly create the page if it doesnt exist
+$page = get_page_by_path("find-a-trainer");
+if (!$page) {
+ $page_content = "
+
+
+
+
+
+
Find certified HVAC trainers in your area. Use the interactive map and filters below to discover trainers who match your specific needs. Click on any trainer to view their profile and contact them directly.
+
+
+
+
+
+
+
+
+
+
+ [display-map id=\"5872\"]
+
+
+
+
+
+
+
+
+
+
Filters:
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ [hvac_trainer_directory]
+
+
+
+
+
+
Are you an HVAC Trainer that wants to be listed in our directory?
Find certified HVAC trainers in your area. Use the interactive map and filters below to discover trainers who match your specific needs. Click on any trainer to view their profile and contact them directly.