upskill-event-manager/includes/class-hvac-page-content-fixer.php
bengizmo 00b3b2008b fix: Resolve event manage page CSS override and duplicate header issues
- Scoped all CSS rules to .hvac-event-manage-wrapper to prevent theme conflicts
- Moved navigation header directly into page template to avoid duplication
- Disabled duplicate header hook in HVAC_Event_Manage_Header class
- Added theme override styles to enforce 1200px max-width and 20px padding
- Updated CSS methodology to use consistent spacing and remove CSS variables
- Added HVAC_Page_Content_Fixer class to clean escaped HTML comments
- Updated documentation with CSS architecture details
- Enhanced theme compatibility with higher specificity selectors

The event manage page now displays correctly with:
- Single navigation header (no duplicates)
- Proper white background and shadows
- Consistent button styling matching other pages
- Clean 1200px max-width layout with 20px padding

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-07-30 15:36:39 -03:00

77 lines
No EOL
2.2 KiB
PHP

<?php
/**
* HVAC Page Content Fixer
*
* Fixes common content issues in HVAC pages
*
* @package HVAC_Community_Events
* @since 2.0.0
*/
if (!defined('ABSPATH')) {
exit;
}
class HVAC_Page_Content_Fixer {
/**
* Fix escaped HTML comments in page content
*/
public static function fix_escaped_html_comments() {
global $wpdb;
// Find all pages with escaped HTML comments
$pages_with_escaped_comments = $wpdb->get_results(
"SELECT ID, post_content
FROM {$wpdb->posts}
WHERE post_type = 'page'
AND post_content LIKE '%<\\\\!--%'
AND post_status = 'publish'"
);
foreach ($pages_with_escaped_comments as $page) {
// Remove escaped HTML comments
$clean_content = str_replace(
array('<\!-- wp:shortcode -->', '<\!-- /wp:shortcode -->'),
'',
$page->post_content
);
// Also handle any other escaped variations
$clean_content = preg_replace('/<\\\\!--.*?-->/', '', $clean_content);
// Update the page if content changed
if ($clean_content !== $page->post_content) {
wp_update_post(array(
'ID' => $page->ID,
'post_content' => $clean_content
));
error_log("HVAC: Fixed escaped HTML comments in page ID {$page->ID}");
}
}
// Clear caches
wp_cache_flush();
}
/**
* Run all content fixes
*/
public static function run_all_fixes() {
self::fix_escaped_html_comments();
}
}
// Hook into activation
add_action('hvac_plugin_activated', array('HVAC_Page_Content_Fixer', 'run_all_fixes'));
// Also run on admin init to catch any issues
add_action('admin_init', function() {
// Only run once per day to avoid performance impact
$last_run = get_transient('hvac_content_fixes_last_run');
if (!$last_run) {
HVAC_Page_Content_Fixer::run_all_fixes();
set_transient('hvac_content_fixes_last_run', time(), DAY_IN_SECONDS);
}
});