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:
bengizmo 2025-05-24 08:24:01 -03:00
parent 39eb20e72b
commit e95191f919
2 changed files with 94 additions and 81 deletions

View file

@ -217,76 +217,88 @@ 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() {
// Enqueue the harmonized framework first - this provides the base styling // Check if we're on an HVAC plugin page to prevent conflicts with home page
wp_enqueue_style( $hvac_pages = [
'hvac-harmonized-framework', 'hvac-dashboard', 'community-login', 'trainer-registration', 'trainer-profile',
HVAC_CE_PLUGIN_URL . 'assets/css/hvac-harmonized.css', 'manage-event', 'event-summary', 'email-attendees', 'certificate-reports',
[], // No dependencies - this is the foundation 'generate-certificates', 'certificate-fix', 'hvac-documentation'
HVAC_CE_VERSION . '-v3.0.0' ];
);
// Enqueue the legacy common CSS file for backward compatibility $is_hvac_page = is_page($hvac_pages) || is_user_logged_in() && current_user_can('hvac_trainer');
wp_enqueue_style(
'hvac-common-style',
HVAC_CE_PLUGIN_URL . 'assets/css/hvac-common.css',
['hvac-harmonized-framework'], // Depends on harmonized framework
HVAC_CE_VERSION
);
// Enqueue animations CSS file // Only load framework styles globally (these are safe and minimal)
wp_enqueue_style( if ($is_hvac_page) {
'hvac-animations', // Enqueue the harmonized framework first - this provides the base styling
HVAC_CE_PLUGIN_URL . 'assets/css/hvac-animations.css', wp_enqueue_style(
['hvac-harmonized-framework'], // Depends on harmonized framework 'hvac-harmonized-framework',
HVAC_CE_VERSION HVAC_CE_PLUGIN_URL . 'assets/css/hvac-harmonized.css',
); [], // No dependencies - this is the foundation
HVAC_CE_VERSION . '-v3.0.0'
// Enqueue mobile navigation CSS file );
wp_enqueue_style(
'hvac-mobile-nav', // Enqueue the legacy common CSS file for backward compatibility
HVAC_CE_PLUGIN_URL . 'assets/css/hvac-mobile-nav.css', wp_enqueue_style(
['hvac-harmonized-framework'], // Depends on harmonized framework 'hvac-common-style',
HVAC_CE_VERSION HVAC_CE_PLUGIN_URL . 'assets/css/hvac-common.css',
); ['hvac-harmonized-framework'], // Depends on harmonized framework
HVAC_CE_VERSION
// Enqueue print stylesheet );
wp_enqueue_style(
'hvac-print-style', // Enqueue animations CSS file (ONLY on HVAC pages)
HVAC_CE_PLUGIN_URL . 'assets/css/hvac-print.css', wp_enqueue_style(
['hvac-harmonized-framework'], // Depends on harmonized framework 'hvac-animations',
HVAC_CE_VERSION, HVAC_CE_PLUGIN_URL . 'assets/css/hvac-animations.css',
'print' // Print media only ['hvac-harmonized-framework'], // Depends on harmonized framework
); HVAC_CE_VERSION
);
// Enqueue the accessibility helper JS for all pages
wp_enqueue_script( // Enqueue mobile navigation CSS file (ONLY on HVAC pages)
'hvac-accessibility-js', wp_enqueue_style(
HVAC_CE_PLUGIN_URL . 'assets/js/hvac-accessibility.js', 'hvac-mobile-nav',
[], // No dependencies HVAC_CE_PLUGIN_URL . 'assets/css/hvac-mobile-nav.css',
HVAC_CE_VERSION, ['hvac-harmonized-framework'], // Depends on harmonized framework
true // Load in footer HVAC_CE_VERSION
); );
// Enqueue animations JS for all pages // Enqueue print stylesheet
wp_enqueue_script( wp_enqueue_style(
'hvac-animations-js', 'hvac-print-style',
HVAC_CE_PLUGIN_URL . 'assets/js/hvac-animations.js', HVAC_CE_PLUGIN_URL . 'assets/css/hvac-print.css',
[], // No dependencies ['hvac-harmonized-framework'], // Depends on harmonized framework
HVAC_CE_VERSION, HVAC_CE_VERSION,
true // Load in footer 'print' // Print media only
); );
// Enqueue mobile navigation JS for all pages // Enqueue the accessibility helper JS (ONLY on HVAC pages)
wp_enqueue_script( wp_enqueue_script(
'hvac-mobile-nav-js', 'hvac-accessibility-js',
HVAC_CE_PLUGIN_URL . 'assets/js/hvac-mobile-nav.js', HVAC_CE_PLUGIN_URL . 'assets/js/hvac-accessibility.js',
[], // No dependencies [], // No dependencies
HVAC_CE_VERSION, HVAC_CE_VERSION,
true // Load in footer true // Load in footer
); );
// Enqueue animations JS (ONLY on HVAC pages)
wp_enqueue_script(
'hvac-animations-js',
HVAC_CE_PLUGIN_URL . 'assets/js/hvac-animations.js',
[], // No dependencies
HVAC_CE_VERSION,
true // Load in footer
);
// Enqueue mobile navigation JS (ONLY on HVAC pages)
wp_enqueue_script(
'hvac-mobile-nav-js',
HVAC_CE_PLUGIN_URL . 'assets/js/hvac-mobile-nav.js',
[], // No dependencies
HVAC_CE_VERSION,
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')) {

View file

@ -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;
} }
} }