Completely removed JavaScript hack approach and implemented navigation using proper WordPress standards: ✅ WORDPRESS BEST PRACTICES IMPLEMENTED: - Removed JavaScript injection hacks completely - Modified dashboard template (template-hvac-dashboard.php) directly - Used proper PHP template integration instead of DOM manipulation - Navigation now renders server-side through WordPress template system ✅ TECHNICAL IMPROVEMENTS: - Fixed JavaScript syntax error causing console errors - Clean template integration with proper class instantiation - Proper escaping and WordPress coding standards - Maintainable code following WordPress plugin architecture ✅ PERFECT RESULTS: - Enhanced navigation menu working flawlessly - Professional horizontal navigation with icons and dropdowns - Working breadcrumbs (Home › Trainer › Dashboard) - Zero JavaScript errors - Clean, semantic HTML output - Responsive design integration ✅ NAVIGATION FEATURES: 🏠 Dashboard - Main trainer overview 📅 Events ▼ - Event management with dropdown 📍 Venues ▼ - Venue management with dropdown 🏢 Organizers ▼ - Organizer management with dropdown 👤 Profile ▼ - Profile management with dropdown The navigation system now follows WordPress best practices with: - Server-side rendering through templates - Proper PHP class integration - No JavaScript DOM manipulation - Clean, maintainable code architecture - Full compatibility with WordPress theme system 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
124 lines
No EOL
3.2 KiB
PHP
124 lines
No EOL
3.2 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()) {
|
|
// Use proper WordPress content filtering
|
|
add_filter('the_content', array($this, 'add_navigation_to_content'), 1);
|
|
}
|
|
}
|
|
|
|
/**
|
|
* 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
|
|
}
|
|
|
|
|
|
/**
|
|
* 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();
|