fix: Resolve Trainer Login page and link issues
- Fix shortcode registration for community login with correct namespace - Create dedicated page template for community-login page - Enable template_include filter to properly load custom page templates - Fix early loading of Login_Handler class - Update Trainer Login page title and template handling - Ensure proper shortcode execution on the login page 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
parent
7d74938ab9
commit
12e360b6e6
4 changed files with 73 additions and 4 deletions
|
|
@ -35,8 +35,9 @@ function hvac_ce_create_required_pages() {
|
||||||
HVAC_Logger::info('Starting page creation process', 'Activation');
|
HVAC_Logger::info('Starting page creation process', 'Activation');
|
||||||
$required_pages = [
|
$required_pages = [
|
||||||
'community-login' => [
|
'community-login' => [
|
||||||
'title' => 'Community Login',
|
'title' => 'Trainer Login',
|
||||||
'content' => '<!-- wp:shortcode -->[hvac_community_login]<!-- /wp:shortcode -->',
|
'content' => '<!-- wp:shortcode -->[hvac_community_login]<!-- /wp:shortcode -->',
|
||||||
|
'template' => 'page-community-login.php',
|
||||||
],
|
],
|
||||||
'trainer-registration' => [
|
'trainer-registration' => [
|
||||||
'title' => 'Trainer Registration',
|
'title' => 'Trainer Registration',
|
||||||
|
|
@ -82,6 +83,11 @@ function hvac_ce_create_required_pages() {
|
||||||
'ping_status' => 'closed',
|
'ping_status' => 'closed',
|
||||||
];
|
];
|
||||||
|
|
||||||
|
// Check if we should use a specific template
|
||||||
|
if (!empty($page_data['template'])) {
|
||||||
|
$post_data['page_template'] = $page_data['template'];
|
||||||
|
}
|
||||||
|
|
||||||
$page_id = wp_insert_post($post_data);
|
$page_id = wp_insert_post($post_data);
|
||||||
|
|
||||||
// Log the result of wp_insert_post
|
// Log the result of wp_insert_post
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,15 @@
|
||||||
|
/**
|
||||||
|
* Initialize hooks
|
||||||
|
*/
|
||||||
|
private function init_hooks() {
|
||||||
|
// Register activation/deactivation hooks
|
||||||
|
// Note: These hooks are typically registered outside the class instance context
|
||||||
|
// register_activation_hook(__FILE__, array($this, 'activate')); // This won't work correctly here
|
||||||
|
// register_deactivation_hook(__FILE__, array($this, 'deactivate')); // This won't work correctly here
|
||||||
|
|
||||||
|
// Initialize other hooks
|
||||||
|
add_action('init', array($this, 'init'));
|
||||||
|
|
||||||
|
// Template loading for custom pages
|
||||||
|
add_filter('template_include', array($this, 'load_custom_templates'));
|
||||||
|
} // End init_hooks
|
||||||
|
|
@ -59,7 +59,19 @@ class HVAC_Community_Events {
|
||||||
'class-event-author-fixer.php', // Fix event author assignment
|
'class-event-author-fixer.php', // Fix event author assignment
|
||||||
'class-hvac-dashboard.php' // New dashboard handler
|
'class-hvac-dashboard.php' // New dashboard handler
|
||||||
];
|
];
|
||||||
|
// Make sure Login_Handler is loaded first for shortcode registration
|
||||||
|
$login_handler_path = HVAC_CE_PLUGIN_DIR . 'includes/community/class-login-handler.php';
|
||||||
|
if (file_exists($login_handler_path)) {
|
||||||
|
require_once $login_handler_path;
|
||||||
|
HVAC_Logger::info("Included file: community/class-login-handler.php", 'Core');
|
||||||
|
}
|
||||||
|
|
||||||
foreach ($files_to_include as $file) {
|
foreach ($files_to_include as $file) {
|
||||||
|
// Skip Login_Handler as we've already loaded it
|
||||||
|
if ($file === 'community/class-login-handler.php') {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
$path = HVAC_CE_PLUGIN_DIR . 'includes/' . $file;
|
$path = HVAC_CE_PLUGIN_DIR . 'includes/' . $file;
|
||||||
if (file_exists($path)) {
|
if (file_exists($path)) {
|
||||||
require_once $path;
|
require_once $path;
|
||||||
|
|
@ -93,8 +105,8 @@ class HVAC_Community_Events {
|
||||||
// Initialize other hooks
|
// Initialize other hooks
|
||||||
add_action('init', array($this, 'init'));
|
add_action('init', array($this, 'init'));
|
||||||
|
|
||||||
// Template loading for custom pages (removed - using content filter instead)
|
// Template loading for custom pages
|
||||||
// add_filter('template_include', array($this, 'load_custom_templates'));
|
add_filter('template_include', array($this, 'load_custom_templates'));
|
||||||
} // End init_hooks
|
} // End init_hooks
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -194,7 +206,7 @@ class HVAC_Community_Events {
|
||||||
add_shortcode('hvac_trainer_registration', array('HVAC_Registration', 'render_registration_form'));
|
add_shortcode('hvac_trainer_registration', array('HVAC_Registration', 'render_registration_form'));
|
||||||
|
|
||||||
// Community login shortcode
|
// Community login shortcode
|
||||||
add_shortcode('hvac_community_login', array('HVAC_Community_Login_Handler', 'render_login_form'));
|
add_shortcode('hvac_community_login', array('\\HVAC_Community_Events\\Community\\Login_Handler', 'render_login_form'));
|
||||||
|
|
||||||
// Dashboard shortcode
|
// Dashboard shortcode
|
||||||
add_shortcode('hvac_dashboard', array($this, 'render_dashboard'));
|
add_shortcode('hvac_dashboard', array($this, 'render_dashboard'));
|
||||||
|
|
@ -242,6 +254,14 @@ class HVAC_Community_Events {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Check for community-login page
|
||||||
|
if (is_page('community-login')) {
|
||||||
|
$custom_template = HVAC_CE_PLUGIN_DIR . 'templates/page-community-login.php';
|
||||||
|
if (file_exists($custom_template)) {
|
||||||
|
return $custom_template;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Check for my-events page
|
// Check for my-events page
|
||||||
if (is_page('my-events')) {
|
if (is_page('my-events')) {
|
||||||
$custom_template = HVAC_CE_PLUGIN_DIR . 'templates/page-my-events.php';
|
$custom_template = HVAC_CE_PLUGIN_DIR . 'templates/page-my-events.php';
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,28 @@
|
||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* Template Name: HVAC Community Login
|
||||||
|
*
|
||||||
|
* This is the custom template for the community login page.
|
||||||
|
*
|
||||||
|
* @package HVAC_Community_Events
|
||||||
|
*/
|
||||||
|
|
||||||
|
get_header(); ?>
|
||||||
|
|
||||||
|
<div id="primary" class="content-area">
|
||||||
|
<main id="main" class="site-main" role="main">
|
||||||
|
<div class="hvac-community-login-container">
|
||||||
|
<h1 class="entry-title">
|
||||||
|
<?php esc_html_e('Trainer Login', 'hvac-ce'); ?>
|
||||||
|
</h1>
|
||||||
|
<div class="entry-content">
|
||||||
|
<?php
|
||||||
|
// Process the shortcode directly
|
||||||
|
echo do_shortcode('[hvac_community_login]');
|
||||||
|
?>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</main><!-- #main -->
|
||||||
|
</div><!-- #primary -->
|
||||||
|
|
||||||
|
<?php get_footer(); ?>
|
||||||
Loading…
Reference in a new issue