fix: Resolve home page content disappearing issue
- Restricted HVAC plugin CSS/JS animations to only load on HVAC pages - Fixed parse_request certificate handler to be more specific and less intrusive - Prevented global CSS animations from affecting non-HVAC pages - Home page content now renders properly without disappearing 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
parent
39eb20e72b
commit
e95191f919
2 changed files with 94 additions and 81 deletions
|
|
@ -217,9 +217,20 @@ register_deactivation_hook(__FILE__, 'hvac_ce_remove_roles');
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Enqueue common styles and scripts for all HVAC Community Events pages
|
* Enqueue common styles and scripts for HVAC Community Events pages
|
||||||
*/
|
*/
|
||||||
function hvac_ce_enqueue_common_assets() {
|
function hvac_ce_enqueue_common_assets() {
|
||||||
|
// Check if we're on an HVAC plugin page to prevent conflicts with home page
|
||||||
|
$hvac_pages = [
|
||||||
|
'hvac-dashboard', 'community-login', 'trainer-registration', 'trainer-profile',
|
||||||
|
'manage-event', 'event-summary', 'email-attendees', 'certificate-reports',
|
||||||
|
'generate-certificates', 'certificate-fix', 'hvac-documentation'
|
||||||
|
];
|
||||||
|
|
||||||
|
$is_hvac_page = is_page($hvac_pages) || is_user_logged_in() && current_user_can('hvac_trainer');
|
||||||
|
|
||||||
|
// Only load framework styles globally (these are safe and minimal)
|
||||||
|
if ($is_hvac_page) {
|
||||||
// Enqueue the harmonized framework first - this provides the base styling
|
// Enqueue the harmonized framework first - this provides the base styling
|
||||||
wp_enqueue_style(
|
wp_enqueue_style(
|
||||||
'hvac-harmonized-framework',
|
'hvac-harmonized-framework',
|
||||||
|
|
@ -236,7 +247,7 @@ function hvac_ce_enqueue_common_assets() {
|
||||||
HVAC_CE_VERSION
|
HVAC_CE_VERSION
|
||||||
);
|
);
|
||||||
|
|
||||||
// Enqueue animations CSS file
|
// Enqueue animations CSS file (ONLY on HVAC pages)
|
||||||
wp_enqueue_style(
|
wp_enqueue_style(
|
||||||
'hvac-animations',
|
'hvac-animations',
|
||||||
HVAC_CE_PLUGIN_URL . 'assets/css/hvac-animations.css',
|
HVAC_CE_PLUGIN_URL . 'assets/css/hvac-animations.css',
|
||||||
|
|
@ -244,7 +255,7 @@ function hvac_ce_enqueue_common_assets() {
|
||||||
HVAC_CE_VERSION
|
HVAC_CE_VERSION
|
||||||
);
|
);
|
||||||
|
|
||||||
// Enqueue mobile navigation CSS file
|
// Enqueue mobile navigation CSS file (ONLY on HVAC pages)
|
||||||
wp_enqueue_style(
|
wp_enqueue_style(
|
||||||
'hvac-mobile-nav',
|
'hvac-mobile-nav',
|
||||||
HVAC_CE_PLUGIN_URL . 'assets/css/hvac-mobile-nav.css',
|
HVAC_CE_PLUGIN_URL . 'assets/css/hvac-mobile-nav.css',
|
||||||
|
|
@ -261,7 +272,7 @@ function hvac_ce_enqueue_common_assets() {
|
||||||
'print' // Print media only
|
'print' // Print media only
|
||||||
);
|
);
|
||||||
|
|
||||||
// Enqueue the accessibility helper JS for all pages
|
// Enqueue the accessibility helper JS (ONLY on HVAC pages)
|
||||||
wp_enqueue_script(
|
wp_enqueue_script(
|
||||||
'hvac-accessibility-js',
|
'hvac-accessibility-js',
|
||||||
HVAC_CE_PLUGIN_URL . 'assets/js/hvac-accessibility.js',
|
HVAC_CE_PLUGIN_URL . 'assets/js/hvac-accessibility.js',
|
||||||
|
|
@ -270,7 +281,7 @@ function hvac_ce_enqueue_common_assets() {
|
||||||
true // Load in footer
|
true // Load in footer
|
||||||
);
|
);
|
||||||
|
|
||||||
// Enqueue animations JS for all pages
|
// Enqueue animations JS (ONLY on HVAC pages)
|
||||||
wp_enqueue_script(
|
wp_enqueue_script(
|
||||||
'hvac-animations-js',
|
'hvac-animations-js',
|
||||||
HVAC_CE_PLUGIN_URL . 'assets/js/hvac-animations.js',
|
HVAC_CE_PLUGIN_URL . 'assets/js/hvac-animations.js',
|
||||||
|
|
@ -279,7 +290,7 @@ function hvac_ce_enqueue_common_assets() {
|
||||||
true // Load in footer
|
true // Load in footer
|
||||||
);
|
);
|
||||||
|
|
||||||
// Enqueue mobile navigation JS for all pages
|
// Enqueue mobile navigation JS (ONLY on HVAC pages)
|
||||||
wp_enqueue_script(
|
wp_enqueue_script(
|
||||||
'hvac-mobile-nav-js',
|
'hvac-mobile-nav-js',
|
||||||
HVAC_CE_PLUGIN_URL . 'assets/js/hvac-mobile-nav.js',
|
HVAC_CE_PLUGIN_URL . 'assets/js/hvac-mobile-nav.js',
|
||||||
|
|
@ -287,6 +298,7 @@ function hvac_ce_enqueue_common_assets() {
|
||||||
HVAC_CE_VERSION,
|
HVAC_CE_VERSION,
|
||||||
true // Load in footer
|
true // Load in footer
|
||||||
);
|
);
|
||||||
|
}
|
||||||
|
|
||||||
// Enqueue page-specific enhanced styles based on current page
|
// Enqueue page-specific enhanced styles based on current page
|
||||||
if (is_page('hvac-dashboard')) {
|
if (is_page('hvac-dashboard')) {
|
||||||
|
|
|
||||||
|
|
@ -122,29 +122,30 @@ class HVAC_Certificate_Security {
|
||||||
* This is a fallback method that works even if rewrite rules fail.
|
* This is a fallback method that works even if rewrite rules fail.
|
||||||
*/
|
*/
|
||||||
public function parse_certificate_request($wp) {
|
public function parse_certificate_request($wp) {
|
||||||
|
// Only process if we haven't already handled via template_redirect
|
||||||
|
if (did_action('template_redirect')) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
$request_uri = $_SERVER['REQUEST_URI'];
|
$request_uri = $_SERVER['REQUEST_URI'];
|
||||||
|
|
||||||
// Check if this is a certificate download request
|
// Only match exact certificate download URLs - be very specific
|
||||||
if (preg_match('#/hvac-certificate/([^/]+)/?#', $request_uri, $matches)) {
|
if (preg_match('#^/hvac-certificate/([a-zA-Z0-9]{32})/?$#', $request_uri, $matches)) {
|
||||||
$certificate_token = $matches[1];
|
$certificate_token = $matches[1];
|
||||||
|
|
||||||
// Validate the token
|
// Validate the token exists (don't delete it yet - let the normal handler do that)
|
||||||
$certificate_data = $this->validate_download_token($certificate_token);
|
$certificate_data = get_transient('hvac_certificate_token_' . $certificate_token);
|
||||||
|
|
||||||
if (!$certificate_data) {
|
if (!$certificate_data) {
|
||||||
wp_die(__('Invalid or expired certificate download link.', 'hvac-community-events'));
|
// Return 404 instead of wp_die to avoid interfering with other pages
|
||||||
|
status_header(404);
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Get file path
|
// If we have valid certificate data, let the normal template_redirect handler take over
|
||||||
$file_path = $this->get_certificate_file_path($certificate_data);
|
// Set the query var so the normal handler can pick it up
|
||||||
|
set_query_var('certificate_token', $certificate_token);
|
||||||
if (!$file_path || !file_exists($file_path)) {
|
return;
|
||||||
wp_die(__('Certificate file not found.', 'hvac-community-events'));
|
|
||||||
}
|
|
||||||
|
|
||||||
// Serve the file
|
|
||||||
$this->serve_certificate_file($file_path, $certificate_data);
|
|
||||||
exit;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue