feat: Integrate navigation and breadcrumbs into all trainer templates
- Created template integration class for automatic nav/breadcrumb injection
- Added trainer-header.php template part for consistent header
- Updated all trainer page templates to include navigation and breadcrumbs
- Navigation shows hierarchical menu with dropdowns
- Breadcrumbs provide context-aware navigation trail
All trainer pages now have consistent navigation structure
🤖 Generated with Claude Code
Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
parent
9bb104eea8
commit
ef87f555a0
10 changed files with 203 additions and 27 deletions
|
|
@ -102,6 +102,7 @@ class HVAC_Plugin {
|
|||
'class-hvac-organizers.php',
|
||||
'class-hvac-trainer-navigation.php',
|
||||
'class-hvac-breadcrumbs.php',
|
||||
'class-hvac-template-integration.php',
|
||||
'class-hvac-manage-event.php',
|
||||
'class-hvac-event-summary.php',
|
||||
'class-hvac-trainer-profile.php',
|
||||
|
|
|
|||
130
includes/class-hvac-template-integration.php
Normal file
130
includes/class-hvac-template-integration.php
Normal file
|
|
@ -0,0 +1,130 @@
|
|||
<?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
|
||||
add_action('astra_content_before', 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);
|
||||
|
||||
// Generic fallback hook
|
||||
add_action('wp_body_open', array($this, 'render_navigation_and_breadcrumbs'), 20);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 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();
|
||||
$nav->render_navigation();
|
||||
}
|
||||
|
||||
// Render breadcrumbs if class exists
|
||||
if (class_exists('HVAC_Breadcrumbs')) {
|
||||
$breadcrumbs = new HVAC_Breadcrumbs();
|
||||
$breadcrumbs->render();
|
||||
}
|
||||
?>
|
||||
</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();
|
||||
|
|
@ -5,8 +5,23 @@
|
|||
*/
|
||||
|
||||
get_header();
|
||||
?>
|
||||
|
||||
// Render the dashboard shortcode
|
||||
echo do_shortcode('[hvac_dashboard]');
|
||||
<div class="hvac-page-wrapper hvac-trainer-dashboard-page">
|
||||
<?php
|
||||
// Include trainer header with navigation and breadcrumbs
|
||||
$plugin_dir = WP_PLUGIN_DIR . '/hvac-community-events/';
|
||||
if (file_exists($plugin_dir . 'templates/template-parts/trainer-header.php')) {
|
||||
include $plugin_dir . 'templates/template-parts/trainer-header.php';
|
||||
}
|
||||
?>
|
||||
<div class="container">
|
||||
<?php
|
||||
// Render the dashboard shortcode
|
||||
echo do_shortcode('[hvac_dashboard]');
|
||||
?>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<?php
|
||||
get_footer();
|
||||
|
|
@ -1,13 +1,20 @@
|
|||
<?php
|
||||
/**
|
||||
* Template Name: Trainer Organizer Manage
|
||||
* Description: Template for creating and editing training organizers
|
||||
* Description: Template for creating/editing training organizers
|
||||
*/
|
||||
|
||||
get_header();
|
||||
?>
|
||||
|
||||
<div class="hvac-page-wrapper hvac-trainer-organizer-manage-page">
|
||||
<?php
|
||||
// Include trainer header with navigation and breadcrumbs
|
||||
$plugin_dir = WP_PLUGIN_DIR . '/hvac-community-events/';
|
||||
if (file_exists($plugin_dir . 'templates/template-parts/trainer-header.php')) {
|
||||
include $plugin_dir . 'templates/template-parts/trainer-header.php';
|
||||
}
|
||||
?>
|
||||
<div class="container">
|
||||
<?php
|
||||
// Render the organizer manage shortcode
|
||||
|
|
|
|||
|
|
@ -8,6 +8,13 @@ get_header();
|
|||
?>
|
||||
|
||||
<div class="hvac-page-wrapper hvac-trainer-organizers-list-page">
|
||||
<?php
|
||||
// Include trainer header with navigation and breadcrumbs
|
||||
$plugin_dir = WP_PLUGIN_DIR . '/hvac-community-events/';
|
||||
if (file_exists($plugin_dir . 'templates/template-parts/trainer-header.php')) {
|
||||
include $plugin_dir . 'templates/template-parts/trainer-header.php';
|
||||
}
|
||||
?>
|
||||
<div class="container">
|
||||
<?php
|
||||
// Render the organizers list shortcode
|
||||
|
|
|
|||
|
|
@ -8,6 +8,13 @@ get_header();
|
|||
?>
|
||||
|
||||
<div class="hvac-page-wrapper hvac-trainer-profile-edit-page">
|
||||
<?php
|
||||
// Include trainer header with navigation and breadcrumbs
|
||||
$plugin_dir = WP_PLUGIN_DIR . '/hvac-community-events/';
|
||||
if (file_exists($plugin_dir . 'templates/template-parts/trainer-header.php')) {
|
||||
include $plugin_dir . 'templates/template-parts/trainer-header.php';
|
||||
}
|
||||
?>
|
||||
<div class="container">
|
||||
<?php
|
||||
// Render the profile edit shortcode
|
||||
|
|
|
|||
|
|
@ -1,20 +0,0 @@
|
|||
<?php
|
||||
/**
|
||||
* Template Name: Trainer Profile View
|
||||
* Description: Template for viewing trainer profile
|
||||
*/
|
||||
|
||||
get_header();
|
||||
?>
|
||||
|
||||
<div class="hvac-page-wrapper hvac-trainer-profile-page">
|
||||
<div class="container">
|
||||
<?php
|
||||
// Render the profile view shortcode
|
||||
echo do_shortcode('[hvac_trainer_profile_view]');
|
||||
?>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<?php
|
||||
get_footer();
|
||||
|
|
@ -1,12 +1,27 @@
|
|||
<?php
|
||||
/**
|
||||
* Template Name: Trainer Profile
|
||||
* Description: Template for the trainer profile page
|
||||
* Description: Template for viewing trainer profile
|
||||
*/
|
||||
|
||||
get_header();
|
||||
?>
|
||||
|
||||
// Render the trainer profile shortcode
|
||||
echo do_shortcode('[hvac_trainer_profile]');
|
||||
<div class="hvac-page-wrapper hvac-trainer-profile-page">
|
||||
<?php
|
||||
// Include trainer header with navigation and breadcrumbs
|
||||
$plugin_dir = WP_PLUGIN_DIR . '/hvac-community-events/';
|
||||
if (file_exists($plugin_dir . 'templates/template-parts/trainer-header.php')) {
|
||||
include $plugin_dir . 'templates/template-parts/trainer-header.php';
|
||||
}
|
||||
?>
|
||||
<div class="container">
|
||||
<?php
|
||||
// Render the profile view shortcode
|
||||
echo do_shortcode('[hvac_trainer_profile_view]');
|
||||
?>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<?php
|
||||
get_footer();
|
||||
|
|
@ -1,13 +1,20 @@
|
|||
<?php
|
||||
/**
|
||||
* Template Name: Trainer Venue Manage
|
||||
* Description: Template for creating and editing training venues
|
||||
* Description: Template for creating/editing training venues
|
||||
*/
|
||||
|
||||
get_header();
|
||||
?>
|
||||
|
||||
<div class="hvac-page-wrapper hvac-trainer-venue-manage-page">
|
||||
<?php
|
||||
// Include trainer header with navigation and breadcrumbs
|
||||
$plugin_dir = WP_PLUGIN_DIR . '/hvac-community-events/';
|
||||
if (file_exists($plugin_dir . 'templates/template-parts/trainer-header.php')) {
|
||||
include $plugin_dir . 'templates/template-parts/trainer-header.php';
|
||||
}
|
||||
?>
|
||||
<div class="container">
|
||||
<?php
|
||||
// Render the venue manage shortcode
|
||||
|
|
|
|||
|
|
@ -8,6 +8,13 @@ get_header();
|
|||
?>
|
||||
|
||||
<div class="hvac-page-wrapper hvac-trainer-venues-list-page">
|
||||
<?php
|
||||
// Include trainer header with navigation and breadcrumbs
|
||||
$plugin_dir = WP_PLUGIN_DIR . '/hvac-community-events/';
|
||||
if (file_exists($plugin_dir . 'templates/template-parts/trainer-header.php')) {
|
||||
include $plugin_dir . 'templates/template-parts/trainer-header.php';
|
||||
}
|
||||
?>
|
||||
<div class="container">
|
||||
<?php
|
||||
// Render the venues list shortcode
|
||||
|
|
|
|||
Loading…
Reference in a new issue