upskill-event-manager/includes/class-hvac-astra-integration.php
bengizmo 705e6b563c feat: Implement Training Leads system and restructure navigation menu
- Add comprehensive Training Leads system for HVAC trainers
  * New /trainer/training-leads/ page with tabular contact submission display
  * HVAC_Training_Leads class with AJAX status updates and filtering
  * Empty state messaging and profile sharing CTA
  * Database integration with existing contact forms system

- Restructure trainer navigation menu for better UX
  * Rename "Customize" to "Profile" with logical groupings
  * Move "Logout" under "Profile" submenu
  * Change "Personal Profile" to "Trainer Profile"
  * Add "Training Leads" under Profile section
  * Update help menu to show only question mark icon positioned far right

- Enhance documentation system
  * Fix /trainer/documentation/ page styling and navigation integration
  * Update content to reflect current platform features
  * Add Training Leads documentation and navigation guide
  * Implement proper WordPress template structure

- Update user management
  * Change joe@upskillhvac.com display name to "Joe Medosch"
  * Assign Joe as author of measureQuick headquarters venue
  * Assign Joe as author of measureQuick and Upskill HVAC organizers

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

Co-Authored-By: Claude <noreply@anthropic.com>
2025-08-05 16:02:57 -03:00

455 lines
No EOL
15 KiB
PHP

<?php
/**
* HVAC Astra Theme Integration
*
* Properly integrates HVAC plugin with Astra theme using theme-specific hooks and filters
*
* @package HVAC_Community_Events
* @since 1.0.0
*/
// Exit if accessed directly
if (!defined('ABSPATH')) {
exit;
}
/**
* HVAC Astra Integration Class
*/
class HVAC_Astra_Integration {
/**
* Instance
*
* @var HVAC_Astra_Integration
*/
private static $instance = null;
/**
* Get instance
*/
public static function instance() {
if (null === self::$instance) {
self::$instance = new self();
}
return self::$instance;
}
/**
* Constructor
*/
private function __construct() {
// Only run if Astra theme is active
if (!defined('ASTRA_THEME_VERSION')) {
return;
}
$this->init_hooks();
}
/**
* Initialize hooks
*/
private function init_hooks() {
// Early init to catch template redirects
add_action('template_redirect', [$this, 'ensure_correct_template'], 1);
// Layout filters - use higher priority to ensure they run after Astra's defaults
add_filter('astra_page_layout', [$this, 'force_hvac_page_layout'], 999);
add_filter('astra_get_content_layout', [$this, 'force_hvac_content_layout'], 999);
add_filter('astra_site_layout', [$this, 'force_hvac_site_layout'], 999);
// Container filters
add_filter('astra_container_class', [$this, 'modify_container_class'], 999, 2);
add_filter('astra_get_container_class', [$this, 'get_hvac_container_class'], 999);
// Body classes
add_filter('body_class', [$this, 'add_hvac_body_classes'], 999);
// Content width
add_action('wp', [$this, 'setup_hvac_content_width'], 999);
// Dynamic CSS
add_filter('astra_dynamic_theme_css', [$this, 'add_hvac_dynamic_css'], 999);
// Disable sidebar for HVAC pages
add_action('wp', [$this, 'disable_sidebar_for_hvac_pages'], 1);
// Force template usage
add_filter('template_include', [$this, 'force_hvac_template'], 999);
// Disable Astra breadcrumbs for HVAC pages
add_filter('astra_breadcrumb_enabled', [$this, 'disable_astra_breadcrumbs'], 999);
add_filter('astra_get_option_ast-breadcrumbs-content', [$this, 'disable_breadcrumb_option'], 999);
add_filter('astra_get_option_breadcrumb-position', [$this, 'disable_breadcrumb_position'], 999);
}
/**
* Force page layout for HVAC pages
*/
public function force_hvac_page_layout($layout) {
if ($this->is_hvac_page()) {
return 'no-sidebar';
}
return $layout;
}
/**
* Force content layout for HVAC pages
*/
public function force_hvac_content_layout($layout) {
if ($this->is_hvac_page() && !$this->is_find_trainer_page()) {
return 'plain-container';
}
return $layout;
}
/**
* Force site layout for HVAC pages
*/
public function force_hvac_site_layout($layout) {
if ($this->is_hvac_page() && !$this->is_find_trainer_page()) {
return 'ast-full-width-layout';
}
return $layout;
}
/**
* Modify container class for HVAC pages
*/
public function modify_container_class($classes, $layout) {
if ($this->is_hvac_page() && !$this->is_find_trainer_page()) {
// Remove any constrained container classes
$classes = str_replace('ast-container', 'ast-full-width-container', $classes);
}
return $classes;
}
/**
* Get HVAC-specific container class
*/
public function get_hvac_container_class($class) {
if ($this->is_hvac_page() && !$this->is_find_trainer_page()) {
return 'ast-full-width-container';
}
return $class;
}
/**
* Add HVAC-specific body classes
*/
public function add_hvac_body_classes($classes) {
if ($this->is_hvac_page()) {
// Add Astra-specific classes for full-width layout
$classes[] = 'ast-no-sidebar';
$classes[] = 'ast-separate-container';
$classes[] = 'ast-full-width-layout';
$classes[] = 'ast-plain-container';
$classes[] = 'hvac-astra-integrated';
// Remove conflicting classes
$remove_classes = ['ast-right-sidebar', 'ast-left-sidebar', 'ast-page-builder-template'];
$classes = array_diff($classes, $remove_classes);
}
return $classes;
}
/**
* Setup content width for HVAC pages
*/
public function setup_hvac_content_width() {
if ($this->is_hvac_page() && !$this->is_find_trainer_page()) {
// Set global content width for dashboard pages only
global $content_width;
$content_width = 1920; // Full HD width
// Update Astra's content width
add_filter('astra_get_content_width', function() {
return 1920;
}, 999);
} elseif ($this->is_find_trainer_page()) {
// Set standard content width for Find A Trainer page
global $content_width;
$content_width = 1200; // Standard boxed width
add_filter('astra_get_content_width', function() {
return 1200;
}, 999);
}
}
/**
* Add dynamic CSS for HVAC pages
*/
public function add_hvac_dynamic_css($css) {
if ($this->is_hvac_page()) {
if ($this->is_find_trainer_page()) {
// Find A Trainer page - boxed layout with 1200px max-width
$hvac_css = '
/* Find A Trainer - Boxed layout */
.hvac-find-trainer-page .ast-container {
max-width: 1200px !important;
width: 100% !important;
padding-left: 20px !important;
padding-right: 20px !important;
margin: 0 auto !important;
}
.hvac-find-trainer-page .site-content .ast-container {
max-width: 1200px !important;
}
/* Remove sidebar for Find A Trainer */
.hvac-find-trainer-page .widget-area,
.hvac-find-trainer-page .ast-sidebar,
.hvac-find-trainer-page #secondary,
.hvac-find-trainer-page aside.widget-area,
.hvac-find-trainer-page .sidebar-main {
display: none !important;
}
/* Single column content */
.hvac-find-trainer-page #primary,
.hvac-find-trainer-page .site-main,
.hvac-find-trainer-page .content-area {
width: 100% !important;
max-width: 100% !important;
margin: 0 !important;
float: none !important;
}
/* Map container constraints */
.hvac-find-trainer-page .hvac-map-section {
overflow: hidden !important;
max-width: 100% !important;
}
.hvac-find-trainer-page .hvac-map-section .map_wrapper,
.hvac-find-trainer-page .hvac-map-section .map_box,
.hvac-find-trainer-page .hvac-map-section .map_container {
max-width: 100% !important;
width: 100% !important;
overflow: hidden !important;
}
';
} else {
// Other HVAC pages - full-width layout
$hvac_css = '
/* HVAC Full-width overrides for Astra */
.hvac-astra-integrated .ast-container {
max-width: 100% !important;
width: 100% !important;
padding-left: 40px !important;
padding-right: 40px !important;
}
.hvac-astra-integrated .site-content .ast-container {
max-width: 100% !important;
}
.hvac-astra-integrated .hvac-page-wrapper {
max-width: 1920px;
margin: 0 auto;
}
/* Remove sidebar completely */
.hvac-astra-integrated .widget-area,
.hvac-astra-integrated .ast-sidebar,
.hvac-astra-integrated #secondary,
.hvac-astra-integrated aside.widget-area,
.hvac-astra-integrated .sidebar-main {
display: none !important;
width: 0 !important;
height: 0 !important;
visibility: hidden !important;
position: absolute !important;
left: -9999px !important;
}
/* Full-width content area */
.hvac-astra-integrated #primary,
.hvac-astra-integrated .site-main,
.hvac-astra-integrated .content-area {
width: 100% !important;
max-width: 100% !important;
margin: 0 !important;
float: none !important;
display: block !important;
}
/* Force single column layout */
.hvac-astra-integrated .ast-container > .ast-row {
display: block !important;
}
.hvac-astra-integrated .ast-col-md-8,
.hvac-astra-integrated .ast-col-lg-8 {
width: 100% !important;
max-width: 100% !important;
}
/* Ensure content takes full width */
.hvac-astra-integrated .entry-content {
width: 100% !important;
max-width: 100% !important;
}
';
}
$css .= $hvac_css;
}
return $css;
}
/**
* Disable sidebar for HVAC pages
*/
public function disable_sidebar_for_hvac_pages() {
if ($this->is_hvac_page()) {
// Remove ALL sidebar actions from Astra
remove_action('astra_sidebars', 'astra_get_sidebar');
remove_action('astra_sidebar', 'astra_get_sidebar');
remove_action('astra_primary_content_bottom', 'astra_primary_content_bottom');
// Force sidebar removal via filters
add_filter('astra_display_sidebar', '__return_false', 999);
add_filter('is_active_sidebar', [$this, 'disable_sidebar'], 999, 2);
// Update post meta to ensure no sidebar
global $post;
if ($post) {
update_post_meta($post->ID, 'site-sidebar-layout', 'no-sidebar');
update_post_meta($post->ID, 'site-content-layout', 'plain-container');
update_post_meta($post->ID, 'ast-site-sidebar-layout', 'no-sidebar');
update_post_meta($post->ID, 'ast-featured-img', 'disabled');
update_post_meta($post->ID, 'ast-breadcrumbs-content', 'disabled');
}
}
}
/**
* Disable sidebar check for HVAC pages
*/
public function disable_sidebar($is_active, $index) {
if ($this->is_hvac_page()) {
return false;
}
return $is_active;
}
/**
* Check if current page is an HVAC page
*/
private function is_hvac_page() {
// Check by template
if (is_page_template()) {
$template = get_page_template_slug();
if (strpos($template, 'page-trainer') !== false ||
strpos($template, 'page-master') !== false ||
strpos($template, 'page-certificate') !== false ||
strpos($template, 'page-generate') !== false) {
return true;
}
}
// Check by URL
$current_url = $_SERVER['REQUEST_URI'];
$hvac_paths = ['trainer/', 'master-trainer/', 'certificate', 'generate-certificates'];
foreach ($hvac_paths as $path) {
if (strpos($current_url, $path) !== false) {
return true;
}
}
// Check by page slug
if (is_page()) {
global $post;
if ($post) {
$slug = $post->post_name;
$hvac_slugs = ['trainer', 'dashboard', 'profile', 'certificate', 'venue', 'organizer'];
foreach ($hvac_slugs as $hvac_slug) {
if (strpos($slug, $hvac_slug) !== false) {
return true;
}
}
}
}
return false;
}
/**
* Check if current page is Find A Trainer page
*/
private function is_find_trainer_page() {
if (is_page()) {
global $post;
if ($post && $post->post_name === 'find-a-trainer') {
return true;
}
}
$current_url = $_SERVER['REQUEST_URI'];
return strpos($current_url, 'find-a-trainer') !== false;
}
/**
* Ensure correct template is loaded
*/
public function ensure_correct_template() {
if ($this->is_hvac_page() && is_page()) {
global $post;
if ($post && $post->post_name === 'profile') {
// Force the profile template
$template = get_post_meta($post->ID, '_wp_page_template', true);
if (empty($template) || $template === 'default') {
update_post_meta($post->ID, '_wp_page_template', 'templates/page-trainer-profile.php');
}
}
}
}
/**
* Force HVAC template loading
*/
public function force_hvac_template($template) {
// Temporarily disabled to avoid errors
return $template;
}
/**
* Disable Astra breadcrumbs for HVAC pages
*/
public function disable_astra_breadcrumbs($enabled) {
if ($this->is_hvac_page()) {
return false;
}
return $enabled;
}
/**
* Disable breadcrumb option for HVAC pages
*/
public function disable_breadcrumb_option($option) {
if ($this->is_hvac_page()) {
return 'disabled';
}
return $option;
}
/**
* Disable breadcrumb position for HVAC pages
*/
public function disable_breadcrumb_position($position) {
if ($this->is_hvac_page()) {
return '';
}
return $position;
}
}
// Initialize
HVAC_Astra_Integration::instance();