upskill-event-manager/test-theme-independence.php
Ben c19b909296 refactor: remove all theme-specific code for WordPress compliance
BREAKING CHANGE: Removed Astra theme integration and all theme-specific code

- Removed class-hvac-astra-integration.php (584 lines of theme-specific code)
- Removed 500+ theme-specific CSS files (ast-*, astra-*, divi-*)
- Removed 15+ theme-specific JavaScript files
- Created theme-agnostic HVAC_Layout_Manager class
- Added generic hvac-layout.css with universal styling
- Plugin now works with ANY WordPress theme

This refactoring ensures the plugin complies with WordPress.org plugin
guidelines which require plugins to be theme-independent. The new layout
system uses standard WordPress hooks and filters that work universally.

Key changes:
- Body classes: hvac-plugin-page, hvac-no-sidebar, hvac-full-width
- Generic post meta: _sidebar_layout, page_layout (widely supported)
- Standard WordPress hooks: body_class, wp_enqueue_scripts, is_active_sidebar
- CSS uses generic selectors: .site-content, .content-area, #primary

Removed monitoring infrastructure files that were causing PHP segfaults:
- class-hvac-background-jobs.php
- class-hvac-health-monitor.php
- class-hvac-error-recovery.php
- class-hvac-security-monitor.php
- class-hvac-performance-monitor.php
- class-hvac-backup-manager.php
- class-hvac-cache-optimizer.php

🤖 Generated with Claude Code

Co-Authored-By: Claude <noreply@anthropic.com>
2025-08-20 18:38:52 -03:00

166 lines
No EOL
5.2 KiB
PHP

<?php
/**
* Test Theme Independence
*
* Verifies that the HVAC plugin works without any specific theme
*
* Usage: wp eval-file test-theme-independence.php
*/
// Check if running in WordPress context
if (!defined('ABSPATH')) {
die('This script must be run within WordPress context using wp-cli');
}
echo "Testing HVAC Plugin Theme Independence...\n";
echo "=========================================\n\n";
// Test 1: Check for theme-specific constants
echo "Test 1: Checking for theme-specific constants...\n";
$theme_constants = ['ASTRA_THEME_VERSION', 'DIVI_VERSION', 'ET_BUILDER_VERSION'];
$found_constants = [];
foreach ($theme_constants as $constant) {
if (defined($constant)) {
$found_constants[] = $constant;
}
}
if (empty($found_constants)) {
echo "✓ No theme-specific constants found in environment\n";
} else {
echo "✗ Found theme constants: " . implode(', ', $found_constants) . "\n";
}
// Test 2: Check for theme-specific classes
echo "\nTest 2: Checking for theme-specific classes...\n";
$plugin_dir = plugin_dir_path(__FILE__);
$theme_classes = [];
// Check if Astra integration class exists
if (file_exists($plugin_dir . 'includes/class-hvac-astra-integration.php')) {
$theme_classes[] = 'class-hvac-astra-integration.php';
}
// Check if any Divi integration exists
$includes_files = glob($plugin_dir . 'includes/*.php');
foreach ($includes_files as $file) {
$content = file_get_contents($file);
if (stripos($content, 'divi') !== false || stripos($content, 'et_builder') !== false) {
$theme_classes[] = basename($file);
}
}
if (empty($theme_classes)) {
echo "✓ No theme-specific classes found\n";
} else {
echo "✗ Found theme-specific files: " . implode(', ', $theme_classes) . "\n";
}
// Test 3: Check for theme-specific hooks
echo "\nTest 3: Checking for theme-specific hooks...\n";
$theme_hooks = [];
$all_filters = $wp_filter;
$theme_prefixes = ['astra_', 'ast_', 'divi_', 'et_'];
foreach ($all_filters as $hook_name => $callbacks) {
foreach ($theme_prefixes as $prefix) {
if (strpos($hook_name, $prefix) === 0) {
// Check if any HVAC classes are hooked to this
foreach ($callbacks as $priority => $functions) {
foreach ($functions as $function) {
if (is_array($function['function']) &&
is_object($function['function'][0]) &&
strpos(get_class($function['function'][0]), 'HVAC') !== false) {
$theme_hooks[] = $hook_name;
break 2;
}
}
}
}
}
}
if (empty($theme_hooks)) {
echo "✓ No HVAC hooks attached to theme-specific filters\n";
} else {
echo "✗ Found HVAC hooks on theme filters: " . implode(', ', array_unique($theme_hooks)) . "\n";
}
// Test 4: Check Layout Manager
echo "\nTest 4: Checking Layout Manager...\n";
if (class_exists('HVAC_Layout_Manager')) {
echo "✓ Theme-agnostic Layout Manager is loaded\n";
// Check if it's working
$layout_manager = HVAC_Layout_Manager::instance();
if (is_object($layout_manager)) {
echo "✓ Layout Manager instance created successfully\n";
}
} else {
echo "✗ Layout Manager class not found\n";
}
// Test 5: Check CSS files
echo "\nTest 5: Checking for theme-specific CSS files...\n";
$css_dir = $plugin_dir . 'assets/css/';
$theme_css_files = [];
if (is_dir($css_dir)) {
$css_files = glob($css_dir . '*.css');
foreach ($css_files as $file) {
$filename = basename($file);
if (stripos($filename, 'astra') !== false ||
stripos($filename, 'ast-') !== false ||
stripos($filename, 'divi') !== false) {
$theme_css_files[] = $filename;
}
}
}
if (empty($theme_css_files)) {
echo "✓ No theme-specific CSS files found\n";
} else {
echo "✗ Found theme CSS files: " . implode(', ', $theme_css_files) . "\n";
}
// Test 6: Check JS files
echo "\nTest 6: Checking for theme-specific JS files...\n";
$js_dir = $plugin_dir . 'assets/js/';
$theme_js_files = [];
if (is_dir($js_dir)) {
$js_files = glob($js_dir . '*.js');
foreach ($js_files as $file) {
$filename = basename($file);
if (stripos($filename, 'astra') !== false ||
stripos($filename, 'ast-') !== false ||
stripos($filename, 'divi') !== false) {
$theme_js_files[] = $filename;
}
}
}
if (empty($theme_js_files)) {
echo "✓ No theme-specific JS files found\n";
} else {
echo "✗ Found theme JS files: " . implode(', ', $theme_js_files) . "\n";
}
// Summary
echo "\n=========================================\n";
echo "THEME INDEPENDENCE TEST SUMMARY\n";
echo "=========================================\n";
$total_issues = count($found_constants) + count($theme_classes) + count($theme_hooks) +
count($theme_css_files) + count($theme_js_files);
if ($total_issues === 0) {
echo "✓ PASSED: Plugin is theme-independent!\n";
echo "The HVAC plugin can work with any WordPress theme.\n";
} else {
echo "✗ FAILED: Found $total_issues theme-specific issues\n";
echo "The plugin still has dependencies on specific themes.\n";
}
echo "\n";