array( 'name' => 'LiteSpeed Cache', 'features' => 'Page cache, CSS/JS optimization', ), 'wp-rocket/wp-rocket.php' => array( 'name' => 'WP Rocket', 'features' => 'Full-suite caching & optimization', ), 'w3-total-cache/w3-total-cache.php' => array( 'name' => 'W3 Total Cache', 'features' => 'Page, database & object caching', ), 'wp-super-cache/wp-cache.php' => array( 'name' => 'WP Super Cache', 'features' => 'Static page caching', ), 'wp-fastest-cache/wpFastestCache.php' => array( 'name' => 'WP Fastest Cache', 'features' => 'Page caching & asset minification', ), 'autoptimize/autoptimize.php' => array( 'name' => 'Autoptimize', 'features' => 'CSS/JS minification & aggregation', ), 'fast-velocity-minify/fvm.php' => array( 'name' => 'Fast Velocity Minify', 'features' => 'CSS/JS aggregation', ), 'hummingbird-performance/wp-hummingbird.php' => array( 'name' => 'Hummingbird', 'features' => 'Caching & asset optimization', ), 'wp-asset-clean-up/wpacu.php' => array( 'name' => 'Asset CleanUp', 'features' => 'Script and style management', ), ); /** * Detect active third-party caching/performance plugins. * * @return array List of detected active plugins. */ public static function detect_active_cache_plugins() { if ( ! function_exists( 'is_plugin_active' ) ) { include_once ABSPATH . 'wp-admin/includes/plugin.php'; } $detected = array(); foreach ( self::$known_plugins as $plugin_file => $meta ) { if ( is_plugin_active( $plugin_file ) ) { $detected[ $plugin_file ] = $meta; } } return $detected; } /** * Run full compatibility diagnostic audit. * * @return array */ public static function run_diagnostics() { $system = AWVB_Environment::get_system_info(); $active_conflicts = self::detect_active_cache_plugins(); $checks = array(); // 1. PHP Version $php_ok = version_compare( PHP_VERSION, '7.4', '>=' ); $checks[] = array( 'title' => 'PHP Version (' . PHP_VERSION . ')', 'status' => $php_ok ? 'pass' : 'fail', 'message' => $php_ok ? 'PHP 7.4+ is active. High performance and modern features supported.' : 'Please upgrade your PHP version to 7.4 or higher.', ); // 2. DOMDocument $checks[] = array( 'title' => 'DOMDocument Extension', 'status' => $system['dom_loaded'] ? 'pass' : 'warning', 'message' => $system['dom_loaded'] ? 'DOM parser is available for safe HTML attribute injections.' : 'DOM extension missing; fallback string parsers will be used.', ); // 3. OPcache $checks[] = array( 'title' => 'OPcache Status', 'status' => $system['opcache_enabled'] ? 'pass' : 'info', 'message' => $system['opcache_enabled'] ? 'Zend OPcache is active, speeding up PHP execution.' : 'OPcache is not detected. Enabling OPcache on your server is recommended.', ); // 4. Cache Plugin Conflicts if ( ! empty( $active_conflicts ) ) { $names = wp_list_pluck( $active_conflicts, 'name' ); $checks[] = array( 'title' => 'Existing Optimization Plugins Detected', 'status' => 'warning', 'message' => 'Found active: ' . implode( ', ', $names ) . '. To prevent duplicate caching or JS conflicts, ensure overlapping options are not enabled simultaneously.', ); } else { $checks[] = array( 'title' => 'Cache Conflict Check', 'status' => 'pass', 'message' => 'No conflicting caching plugins detected. Full optimization access available.', ); } // 5. Memory Limit $mem = (int) $system['memory_limit']; $mem_ok = $mem >= 128 || -1 === $mem; $checks[] = array( 'title' => 'PHP Memory Limit (' . $system['memory_limit'] . ')', 'status' => $mem_ok ? 'pass' : 'warning', 'message' => $mem_ok ? 'Memory limit is sufficient for speed optimizations.' : 'Recommended memory limit is 128M or higher.', ); return array( 'timestamp' => current_time( 'mysql' ), 'system' => $system, 'conflicts' => $active_conflicts, 'checks' => $checks, ); } /** * Generate formatted text report for export. * * @return string */ public static function generate_export_report() { $diag = self::run_diagnostics(); $out = "=== Ahtesham Web Vitals Booster - Diagnostic Report ===\n"; $out .= 'Generated: ' . $diag['timestamp'] . "\n\n"; $out .= "-- System Information --\n"; foreach ( $diag['system'] as $key => $val ) { $val_str = is_bool( $val ) ? ( $val ? 'Yes' : 'No' ) : (string) $val; $out .= str_pad( $key, 22, ' ' ) . ': ' . $val_str . "\n"; } $out .= "\n-- Optimization Audit --\n"; foreach ( $diag['checks'] as $c ) { $out .= '[' . strtoupper( $c['status'] ) . '] ' . $c['title'] . ': ' . $c['message'] . "\n"; } return $out; } }