$this->get_system_info(), ) ); } public function add_menu() { add_submenu_page( 'aica-smart-ai-commerce-assistant', __( 'System Status', 'aica-smart-ai-commerce-assistant' ), __( 'System Status', 'aica-smart-ai-commerce-assistant' ), 'manage_options', 'aica-smart-ai-commerce-assistant-health', array( $this, 'render_page' ) ); } public function render_page() { $checks = $this->run_checks(); $all_pass = !in_array( 'error', array_column( $checks, 'status' ) ); ?>

🏥

✓

⚠

🔍

● ● ●

🖥️

get_system_info(); foreach ( $info as $label => $value ) : ?>
'WordPress Version', 'status' => version_compare( $wp_version, '6.0', '>=' ) ? 'pass' : 'error', 'message' => $wp_version . ' ' . ( version_compare( $wp_version, '6.0', '>=' ) ? '(OK)' : '(Requires 6.0+)' ), ); // WooCommerce if ( class_exists( 'WooCommerce' ) ) { $wc_version = WC()->version; $checks[] = array( 'label' => 'WooCommerce', 'status' => version_compare( $wc_version, '7.0', '>=' ) ? 'pass' : 'warning', 'message' => $wc_version . ' ' . ( version_compare( $wc_version, '7.0', '>=' ) ? '(OK)' : '(Update recommended)' ), ); } else { $checks[] = array( 'label' => 'WooCommerce', 'status' => 'error', 'message' => 'Not installed', ); } // PHP version $php_version = PHP_VERSION; $checks[] = array( 'label' => 'PHP Version', 'status' => version_compare( $php_version, '7.4', '>=' ) ? 'pass' : 'error', 'message' => $php_version . ' ' . ( version_compare( $php_version, '7.4', '>=' ) ? '(OK)' : '(Requires 7.4+)' ), ); // Database tables $tables_exist = AICA_Installer::tables_exist(); $checks[] = array( 'label' => 'Database Tables', 'status' => $tables_exist ? 'pass' : 'error', 'message' => $tables_exist ? 'All tables created' : 'Tables missing - try deactivating and reactivating', ); // API Key $settings = get_option( 'aica_settings', array() ); $provider = $settings['ai_provider'] ?? 'openai'; $key_field = $provider . '_api_key'; $has_key = !empty( $settings[ $key_field ] ); $checks[] = array( 'label' => 'AI API Key', 'status' => $has_key ? 'pass' : 'warning', 'message' => $has_key ? ucfirst( $provider ) . ' configured' : 'No API key configured', ); // Indexed products global $wpdb; $indexed_count = wp_cache_get( 'aica_indexed_products_count', 'aica_system_health' ); if ( false === $indexed_count ) { // phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching $indexed_count = $wpdb->get_var( "SELECT COUNT(*) FROM {$wpdb->prefix}aica_indexed_products" ); wp_cache_set( 'aica_indexed_products_count', $indexed_count, 'aica_system_health', HOUR_IN_SECONDS ); } $total_products = wp_count_posts( 'product' )->publish; $checks[] = array( 'label' => 'Product Index', 'status' => $indexed_count > 0 ? 'pass' : 'warning', 'message' => sprintf( '%d of %d products indexed', $indexed_count, $total_products ), ); // Memory limit $memory_limit = ini_get( 'memory_limit' ); $memory_bytes = wp_convert_hr_to_bytes( $memory_limit ); $checks[] = array( 'label' => 'PHP Memory Limit', 'status' => $memory_bytes >= 134217728 ? 'pass' : 'warning', // 128MB 'message' => $memory_limit . ' ' . ( $memory_bytes >= 134217728 ? '(OK)' : '(256M recommended)' ), ); // Max execution time $max_exec = ini_get( 'max_execution_time' ); $checks[] = array( 'label' => 'Max Execution Time', 'status' => $max_exec >= 60 || $max_exec == 0 ? 'pass' : 'warning', 'message' => ( $max_exec == 0 ? 'Unlimited' : $max_exec . 's' ) . ' ' . ( $max_exec >= 60 || $max_exec == 0 ? '(OK)' : '(60s+ recommended)' ), ); // cURL $checks[] = array( 'label' => 'cURL Extension', 'status' => function_exists( 'curl_version' ) ? 'pass' : 'error', 'message' => function_exists( 'curl_version' ) ? 'Installed' : 'Not installed (required for API calls)', ); // Widget enabled $widget_enabled = isset( $settings['enable_widget'] ) && $settings['enable_widget'] === 'yes'; $checks[] = array( 'label' => 'Widget Status', 'status' => $widget_enabled ? 'pass' : 'warning', 'message' => $widget_enabled ? 'Enabled' : 'Disabled in settings', ); return $checks; } private function get_system_info() { global $wpdb; $settings = get_option( 'aica_settings', array() ); return array( 'Plugin Version' => AICA_VERSION, 'WordPress Version' => get_bloginfo( 'version' ), 'WooCommerce Version' => class_exists( 'WooCommerce' ) ? WC()->version : 'Not installed', 'PHP Version' => PHP_VERSION, 'MySQL Version' => $wpdb->db_version(), 'Server Software' => sanitize_text_field( $_SERVER['SERVER_SOFTWARE'] ?? 'Unknown' ), 'Memory Limit' => ini_get( 'memory_limit' ), 'Max Execution Time' => ini_get( 'max_execution_time' ) . 's', 'AI Provider' => ucfirst( $settings['ai_provider'] ?? 'Not configured' ), 'Active Theme' => wp_get_theme()->get( 'Name' ), 'Active Plugins' => count( get_option( 'active_plugins', array() ) ), 'Site URL' => get_site_url(), ); } } // Initialize // AICA_System_Health::get_instance(); // Removed, handled by main plugin class