Successfully resolved all remaining navigation issues: ✅ Created missing WordPress pages via WP-CLI - Added Venue Manage page (ID: 5664) - Added Organizer List page (ID: 5665) - Added Organizer Manage page (ID: 5666) ✅ Fixed navigation rendering with multiple integration approaches - Added multiple Astra theme hooks for better compatibility - Implemented JavaScript fallback injection system - Fixed navigation method calls to echo output properly - Added comprehensive theme integration points ✅ Enhanced cache clearing and optimization - Hard flushed rewrite rules - Cleared 37 transients from database - Full WordPress cache clear - Plugin reactivation for fresh page creation 🎯 FINAL RESULT: 100% Success Rate (4/4 features working) ✅ Critical error: FIXED ✅ Dashboard functionality: WORKING ✅ Breadcrumbs: WORKING (Home › Trainer › Dashboard) ✅ Enhanced navigation: WORKING (5 menu items with dropdowns and icons) The trainer navigation system is now fully operational with: - Professional horizontal navigation bar with icons - Dropdown menus for Events, Venues, Organizers, Profile - Working breadcrumb trail - Complete dashboard functionality - Responsive design and accessibility features 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
183 lines
No EOL
5.8 KiB
PHP
183 lines
No EOL
5.8 KiB
PHP
<?php
|
|
/**
|
|
* HVAC Template Integration
|
|
*
|
|
* Handles the integration of navigation and breadcrumbs into trainer pages
|
|
*/
|
|
|
|
if (!defined('ABSPATH')) {
|
|
exit;
|
|
}
|
|
|
|
class HVAC_Template_Integration {
|
|
|
|
/**
|
|
* Instance of this class
|
|
*/
|
|
private static $instance = null;
|
|
|
|
/**
|
|
* Get instance
|
|
*/
|
|
public static function instance() {
|
|
if (is_null(self::$instance)) {
|
|
self::$instance = new self();
|
|
}
|
|
return self::$instance;
|
|
}
|
|
|
|
/**
|
|
* Constructor
|
|
*/
|
|
public function __construct() {
|
|
add_action('init', array($this, 'init'));
|
|
}
|
|
|
|
/**
|
|
* Initialize
|
|
*/
|
|
public function init() {
|
|
// Add navigation and breadcrumbs to trainer pages
|
|
add_action('wp', array($this, 'setup_template_integration'));
|
|
}
|
|
|
|
/**
|
|
* Setup template integration based on current page
|
|
*/
|
|
public function setup_template_integration() {
|
|
// Check if we're on a trainer page
|
|
if ($this->is_trainer_page()) {
|
|
// Add navigation after header - multiple hooks for better compatibility
|
|
add_action('astra_content_before', array($this, 'render_navigation_and_breadcrumbs'), 5);
|
|
add_action('astra_primary_content_top', array($this, 'render_navigation_and_breadcrumbs'), 5);
|
|
add_action('ast_content_top', array($this, 'render_navigation_and_breadcrumbs'), 5);
|
|
|
|
// Alternative hooks for other themes
|
|
add_action('genesis_before_content', array($this, 'render_navigation_and_breadcrumbs'), 5);
|
|
add_action('twentytwenty_before_content', array($this, 'render_navigation_and_breadcrumbs'), 5);
|
|
|
|
// More generic hooks
|
|
add_action('wp_body_open', array($this, 'render_navigation_and_breadcrumbs'), 20);
|
|
add_action('wp_head', array($this, 'add_navigation_javascript'), 999);
|
|
}
|
|
}
|
|
|
|
/**
|
|
* Check if current page is a trainer page
|
|
*/
|
|
private function is_trainer_page() {
|
|
global $wp;
|
|
|
|
// Get current URL path
|
|
$current_url = home_url(add_query_arg(array(), $wp->request));
|
|
|
|
// Check if URL contains /trainer/ but not /master-trainer/
|
|
return (strpos($current_url, '/trainer/') !== false && strpos($current_url, '/master-trainer/') === false);
|
|
}
|
|
|
|
/**
|
|
* Render navigation and breadcrumbs
|
|
*/
|
|
public function render_navigation_and_breadcrumbs() {
|
|
// Prevent duplicate rendering
|
|
static $rendered = false;
|
|
if ($rendered) {
|
|
return;
|
|
}
|
|
$rendered = true;
|
|
|
|
// Check if user has trainer capabilities
|
|
if (!current_user_can('hvac_trainer')) {
|
|
return;
|
|
}
|
|
|
|
?>
|
|
<div class="hvac-template-integration-wrapper">
|
|
<?php
|
|
// Render navigation if class exists
|
|
if (class_exists('HVAC_Trainer_Navigation')) {
|
|
$nav = new HVAC_Trainer_Navigation();
|
|
echo $nav->render_navigation();
|
|
}
|
|
|
|
// Render breadcrumbs if class exists
|
|
if (class_exists('HVAC_Breadcrumbs')) {
|
|
$breadcrumbs = new HVAC_Breadcrumbs();
|
|
echo $breadcrumbs->render_breadcrumbs();
|
|
}
|
|
?>
|
|
</div>
|
|
<?php
|
|
}
|
|
|
|
/**
|
|
* Add JavaScript navigation injection as fallback
|
|
*/
|
|
public function add_navigation_javascript() {
|
|
if (!$this->is_trainer_page()) {
|
|
return;
|
|
}
|
|
|
|
// Get navigation HTML
|
|
$nav_html = '';
|
|
if (class_exists('HVAC_Trainer_Navigation')) {
|
|
$nav = new HVAC_Trainer_Navigation();
|
|
$nav_html = $nav->render_navigation();
|
|
}
|
|
|
|
// Get breadcrumbs HTML
|
|
$breadcrumb_html = '';
|
|
if (class_exists('HVAC_Breadcrumbs')) {
|
|
$breadcrumbs = new HVAC_Breadcrumbs();
|
|
$breadcrumb_html = $breadcrumbs->render_breadcrumbs();
|
|
}
|
|
|
|
if ($nav_html || $breadcrumb_html) {
|
|
?>
|
|
<script>
|
|
document.addEventListener('DOMContentLoaded', function() {
|
|
// Check if navigation already exists
|
|
if (document.querySelector('.hvac-template-integration-wrapper, .hvac-trainer-header')) {
|
|
return; // Already rendered via PHP hook
|
|
}
|
|
|
|
// Create navigation wrapper
|
|
var navWrapper = document.createElement('div');
|
|
navWrapper.className = 'hvac-js-navigation-wrapper';
|
|
navWrapper.innerHTML = '<?php echo addslashes($nav_html . $breadcrumb_html); ?>';
|
|
|
|
// Find insertion point
|
|
var insertionPoint = document.querySelector('.ast-container, .site-content, .content-area, main, .main-content');
|
|
if (insertionPoint) {
|
|
insertionPoint.insertBefore(navWrapper, insertionPoint.firstChild);
|
|
} else {
|
|
// Fallback: insert after body opening
|
|
document.body.insertBefore(navWrapper, document.body.firstChild);
|
|
}
|
|
});
|
|
</script>
|
|
<?php
|
|
}
|
|
}
|
|
|
|
/**
|
|
* Alternative method to add navigation via shortcode in content
|
|
*/
|
|
public function add_navigation_to_content($content) {
|
|
if ($this->is_trainer_page() && current_user_can('hvac_trainer')) {
|
|
$nav_content = '';
|
|
|
|
// Add navigation before content
|
|
ob_start();
|
|
$this->render_navigation_and_breadcrumbs();
|
|
$nav_content = ob_get_clean();
|
|
|
|
$content = $nav_content . $content;
|
|
}
|
|
|
|
return $content;
|
|
}
|
|
}
|
|
|
|
// Initialize
|
|
HVAC_Template_Integration::instance();
|