HVAC trainer profile geocoding system with outstanding results: - 45 out of 53 trainer profiles successfully geocoded (85% coverage) - Coverage spans 15+ US states and 3 Canadian provinces - Google Maps API integration with intelligent rate limiting - Real-time statistics and comprehensive error handling Core Implementation: - HVAC_Geocoding_Ajax class with three AJAX endpoints: * hvac_trigger_geocoding: Manual geocoding operations * hvac_run_enhanced_import: CSV location data population * hvac_get_geocoding_stats: Coverage monitoring and statistics - Enhanced CSV import with corrected email field mapping - Proper field priority mapping for location data extraction - Automatic scheduling of geocoding operations after data import Technical Features: - Singleton pattern for proper class initialization - WordPress AJAX security with nonce verification - Role-based access control for master trainers - Comprehensive error logging and status tracking - API rate limiting (0.5s delays) to respect Google quotas - Multiple address format support (US/International) User Experience: - Master trainer controls for manual geocoding triggers - Real-time progress monitoring and statistics - Detailed error reporting for failed geocoding attempts - Production-ready interface for location data management Documentation: - Complete API reference with endpoint specifications - Comprehensive manual geocoding system documentation - Usage examples and troubleshooting guidelines - Error codes and integration patterns 🚀 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
276 lines
15 KiB
PHP
276 lines
15 KiB
PHP
<?php
|
|
/**
|
|
* Template Name: Trainer Profile
|
|
* Description: Template for viewing trainer profile
|
|
*/
|
|
|
|
// Define constant to indicate we are in a page template
|
|
define('HVAC_IN_PAGE_TEMPLATE', true);
|
|
|
|
get_header();
|
|
?>
|
|
|
|
|
|
<div class="hvac-page-wrapper hvac-trainer-profile-page">
|
|
<?php
|
|
// Display trainer navigation menu
|
|
if (class_exists('HVAC_Menu_System')) {
|
|
HVAC_Menu_System::instance()->render_trainer_menu();
|
|
}
|
|
?>
|
|
|
|
<?php
|
|
// Display breadcrumbs
|
|
if (class_exists('HVAC_Breadcrumbs')) {
|
|
echo HVAC_Breadcrumbs::instance()->render_breadcrumbs();
|
|
}
|
|
?>
|
|
<div class="container">
|
|
<?php
|
|
// Check if user is logged in and has proper permissions
|
|
if (!is_user_logged_in()) {
|
|
echo '<p>You must be logged in to view this page.</p>';
|
|
get_footer();
|
|
return;
|
|
}
|
|
|
|
if (!current_user_can('hvac_trainer') && !current_user_can('hvac_master_trainer') && !current_user_can('administrator')) {
|
|
echo '<p>You must be a trainer to view this page.</p>';
|
|
get_footer();
|
|
return;
|
|
}
|
|
|
|
$user_id = get_current_user_id();
|
|
|
|
// Get trainer profile using new system
|
|
$profile_manager = HVAC_Trainer_Profile_Manager::get_instance();
|
|
$profile = $profile_manager->get_trainer_profile($user_id);
|
|
|
|
if (!$profile) {
|
|
echo '<p>No trainer profile found. Please contact an administrator.</p>';
|
|
get_footer();
|
|
return;
|
|
}
|
|
|
|
// Get profile metadata
|
|
$profile_meta = $profile_manager->get_profile_meta($profile->ID);
|
|
$user = get_userdata($user_id);
|
|
|
|
// Get coordinates if available
|
|
$geocoding_service = HVAC_Geocoding_Service::get_instance();
|
|
$coordinates = $geocoding_service->get_coordinates($profile->ID);
|
|
?>
|
|
|
|
<div class="hvac-trainer-profile-view">
|
|
<div class="hvac-page-header">
|
|
<h1>Trainer Profile</h1>
|
|
<a href="/trainer/profile/edit/" class="hvac-button hvac-button-primary">Edit Profile</a>
|
|
</div>
|
|
|
|
<div class="hvac-profile-content">
|
|
<div class="hvac-profile-sidebar">
|
|
<div class="hvac-profile-photo">
|
|
<?php if (has_post_thumbnail($profile->ID)): ?>
|
|
<?php echo get_the_post_thumbnail($profile->ID, 'medium', ['alt' => $user->display_name]); ?>
|
|
<?php else: ?>
|
|
<div class="hvac-profile-photo-placeholder">
|
|
<span><?php echo esc_html(substr($user->first_name, 0, 1) . substr($user->last_name, 0, 1)); ?></span>
|
|
</div>
|
|
<?php endif; ?>
|
|
</div>
|
|
|
|
<div class="hvac-profile-stats">
|
|
<div class="hvac-stat-item">
|
|
<span class="hvac-stat-value"><?php echo count_user_posts($user_id, 'tribe_events'); ?></span>
|
|
<span class="hvac-stat-label">Events Created</span>
|
|
</div>
|
|
<?php if (!empty($profile_meta['years_experience'])): ?>
|
|
<div class="hvac-stat-item">
|
|
<span class="hvac-stat-value"><?php echo esc_html($profile_meta['years_experience']); ?></span>
|
|
<span class="hvac-stat-label">Years Experience</span>
|
|
</div>
|
|
<?php endif; ?>
|
|
<?php if ($coordinates): ?>
|
|
<div class="hvac-stat-item">
|
|
<span class="hvac-stat-value">📍</span>
|
|
<span class="hvac-stat-label">Location Verified</span>
|
|
</div>
|
|
<?php endif; ?>
|
|
</div>
|
|
</div>
|
|
|
|
<div class="hvac-profile-main">
|
|
<?php if (!empty($profile_meta['certification_status']) || !empty($profile_meta['certification_type']) || !empty($profile_meta['date_certified'])): ?>
|
|
<div class="hvac-profile-section hvac-certification-section">
|
|
<h2>Certification Information</h2>
|
|
<div class="hvac-profile-details">
|
|
<?php if (!empty($profile_meta['certification_status'])): ?>
|
|
<div class="hvac-detail-row">
|
|
<span class="hvac-detail-label">Certification Status:</span>
|
|
<span class="hvac-detail-value hvac-cert-status hvac-cert-status-<?php echo esc_attr(strtolower($profile_meta['certification_status'])); ?>">
|
|
<?php echo esc_html($profile_meta['certification_status']); ?>
|
|
</span>
|
|
</div>
|
|
<?php endif; ?>
|
|
<?php if (!empty($profile_meta['certification_type'])): ?>
|
|
<div class="hvac-detail-row">
|
|
<span class="hvac-detail-label">Certification Type:</span>
|
|
<span class="hvac-detail-value"><?php echo esc_html($profile_meta['certification_type']); ?></span>
|
|
</div>
|
|
<?php endif; ?>
|
|
<?php if (!empty($profile_meta['date_certified'])): ?>
|
|
<div class="hvac-detail-row">
|
|
<span class="hvac-detail-label">Date Certified:</span>
|
|
<span class="hvac-detail-value"><?php echo esc_html(date('F j, Y', strtotime($profile_meta['date_certified']))); ?></span>
|
|
</div>
|
|
<?php endif; ?>
|
|
</div>
|
|
</div>
|
|
<?php endif; ?>
|
|
|
|
<div class="hvac-profile-section">
|
|
<h2>Personal Information</h2>
|
|
<div class="hvac-profile-details">
|
|
<div class="hvac-detail-row">
|
|
<span class="hvac-detail-label">Display Name:</span>
|
|
<span class="hvac-detail-value"><?php echo esc_html($profile_meta['trainer_display_name'] ?? $user->display_name); ?></span>
|
|
</div>
|
|
<div class="hvac-detail-row">
|
|
<span class="hvac-detail-label">Full Name:</span>
|
|
<span class="hvac-detail-value"><?php echo esc_html(($profile_meta['trainer_first_name'] ?? $user->first_name) . ' ' . ($profile_meta['trainer_last_name'] ?? $user->last_name)); ?></span>
|
|
</div>
|
|
<div class="hvac-detail-row">
|
|
<span class="hvac-detail-label">Email:</span>
|
|
<span class="hvac-detail-value"><?php echo esc_html($user->user_email); ?></span>
|
|
</div>
|
|
<?php if (!empty($profile_meta['role'])): ?>
|
|
<div class="hvac-detail-row">
|
|
<span class="hvac-detail-label">Role:</span>
|
|
<span class="hvac-detail-value"><?php echo esc_html(ucwords($profile_meta['role'])); ?></span>
|
|
</div>
|
|
<?php endif; ?>
|
|
<?php if (!empty($profile_meta['years_experience'])): ?>
|
|
<div class="hvac-detail-row">
|
|
<span class="hvac-detail-label">Years Experience:</span>
|
|
<span class="hvac-detail-value"><?php echo esc_html($profile_meta['years_experience']); ?> years</span>
|
|
</div>
|
|
<?php endif; ?>
|
|
<?php
|
|
$location_parts = array_filter([
|
|
$profile_meta['trainer_city'] ?? '',
|
|
$profile_meta['trainer_state'] ?? '',
|
|
$profile_meta['trainer_country'] ?? ''
|
|
]);
|
|
if (!empty($location_parts)):
|
|
?>
|
|
<div class="hvac-detail-row">
|
|
<span class="hvac-detail-label">Location:</span>
|
|
<span class="hvac-detail-value"><?php echo esc_html(implode(', ', $location_parts)); ?></span>
|
|
</div>
|
|
<?php endif; ?>
|
|
<?php if (!empty($profile_meta['linkedin_profile_url'])): ?>
|
|
<div class="hvac-detail-row">
|
|
<span class="hvac-detail-label">LinkedIn:</span>
|
|
<span class="hvac-detail-value">
|
|
<a href="<?php echo esc_url($profile_meta['linkedin_profile_url']); ?>" target="_blank">View Profile</a>
|
|
</span>
|
|
</div>
|
|
<?php endif; ?>
|
|
</div>
|
|
</div>
|
|
|
|
<?php if (!empty($profile->post_content)): ?>
|
|
<div class="hvac-profile-section">
|
|
<h2>About</h2>
|
|
<div class="hvac-profile-bio">
|
|
<?php echo wp_kses_post(wpautop($profile->post_content)); ?>
|
|
</div>
|
|
</div>
|
|
<?php endif; ?>
|
|
|
|
<?php
|
|
// Get business type
|
|
$business_terms = get_the_terms($profile->ID, 'business_type');
|
|
$has_business_info = ($business_terms && !is_wp_error($business_terms)) ||
|
|
!empty($profile_meta['annual_revenue_target']) ||
|
|
!empty($profile_meta['application_details']);
|
|
if ($has_business_info):
|
|
?>
|
|
<div class="hvac-profile-section">
|
|
<h2>Business Information</h2>
|
|
<div class="hvac-profile-details">
|
|
<?php if ($business_terms && !is_wp_error($business_terms)): ?>
|
|
<div class="hvac-detail-row">
|
|
<span class="hvac-detail-label">Business Type:</span>
|
|
<span class="hvac-detail-value"><?php echo esc_html($business_terms[0]->name); ?></span>
|
|
</div>
|
|
<?php endif; ?>
|
|
<?php if (!empty($profile_meta['annual_revenue_target'])): ?>
|
|
<div class="hvac-detail-row">
|
|
<span class="hvac-detail-label">Annual Revenue Target:</span>
|
|
<span class="hvac-detail-value">$<?php echo esc_html(number_format($profile_meta['annual_revenue_target'])); ?></span>
|
|
</div>
|
|
<?php endif; ?>
|
|
<?php if (!empty($profile_meta['application_details'])): ?>
|
|
<div class="hvac-detail-row">
|
|
<span class="hvac-detail-label">Application Details:</span>
|
|
<span class="hvac-detail-value"><?php echo esc_html($profile_meta['application_details']); ?></span>
|
|
</div>
|
|
<?php endif; ?>
|
|
</div>
|
|
</div>
|
|
<?php endif; ?>
|
|
|
|
<?php
|
|
// Training Information Section
|
|
$has_training_info = !empty($profile_meta['training_audience']) ||
|
|
!empty($profile_meta['training_formats']) ||
|
|
!empty($profile_meta['training_locations']) ||
|
|
!empty($profile_meta['training_resources']) ||
|
|
!empty($profile_meta['personal_accreditation']);
|
|
if ($has_training_info):
|
|
?>
|
|
<div class="hvac-profile-section">
|
|
<h2>Training Information</h2>
|
|
<div class="hvac-profile-details">
|
|
<?php if (!empty($profile_meta['training_audience'])): ?>
|
|
<div class="hvac-detail-row">
|
|
<span class="hvac-detail-label">Training Audience:</span>
|
|
<span class="hvac-detail-value"><?php echo esc_html($profile_meta['training_audience']); ?></span>
|
|
</div>
|
|
<?php endif; ?>
|
|
<?php if (!empty($profile_meta['training_formats'])): ?>
|
|
<div class="hvac-detail-row">
|
|
<span class="hvac-detail-label">Training Formats:</span>
|
|
<span class="hvac-detail-value"><?php echo esc_html($profile_meta['training_formats']); ?></span>
|
|
</div>
|
|
<?php endif; ?>
|
|
<?php if (!empty($profile_meta['training_locations'])): ?>
|
|
<div class="hvac-detail-row">
|
|
<span class="hvac-detail-label">Training Locations:</span>
|
|
<span class="hvac-detail-value"><?php echo esc_html($profile_meta['training_locations']); ?></span>
|
|
</div>
|
|
<?php endif; ?>
|
|
<?php if (!empty($profile_meta['training_resources'])): ?>
|
|
<div class="hvac-detail-row">
|
|
<span class="hvac-detail-label">Training Resources:</span>
|
|
<span class="hvac-detail-value"><?php echo esc_html($profile_meta['training_resources']); ?></span>
|
|
</div>
|
|
<?php endif; ?>
|
|
<?php if (!empty($profile_meta['personal_accreditation'])): ?>
|
|
<div class="hvac-detail-row">
|
|
<span class="hvac-detail-label">Personal Accreditation:</span>
|
|
<span class="hvac-detail-value"><?php echo esc_html($profile_meta['personal_accreditation']); ?></span>
|
|
</div>
|
|
<?php endif; ?>
|
|
</div>
|
|
</div>
|
|
<?php endif; ?>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<?php
|
|
get_footer();
|