diff --git a/includes/class-hvac-plugin.php b/includes/class-hvac-plugin.php index f68c9fd5..c2d35c1f 100644 --- a/includes/class-hvac-plugin.php +++ b/includes/class-hvac-plugin.php @@ -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', diff --git a/includes/class-hvac-template-integration.php b/includes/class-hvac-template-integration.php new file mode 100644 index 00000000..2ce8cdd7 --- /dev/null +++ b/includes/class-hvac-template-integration.php @@ -0,0 +1,130 @@ +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; + } + + ?> +
+ render_navigation(); + } + + // Render breadcrumbs if class exists + if (class_exists('HVAC_Breadcrumbs')) { + $breadcrumbs = new HVAC_Breadcrumbs(); + $breadcrumbs->render(); + } + ?> +
+ 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(); \ No newline at end of file diff --git a/templates/page-trainer-dashboard.php b/templates/page-trainer-dashboard.php index cd0cab19..e30b7a09 100644 --- a/templates/page-trainer-dashboard.php +++ b/templates/page-trainer-dashboard.php @@ -5,8 +5,23 @@ */ get_header(); +?> -// Render the dashboard shortcode -echo do_shortcode('[hvac_dashboard]'); +
+ +
+ +
+
+
+
+
+
- -
-
- -
-
- - -// Render the trainer profile shortcode -echo do_shortcode('[hvac_trainer_profile]'); +
+ +
+ +
+
+
+
+