'; echo '

' . __('System Check for AI Content Wizard', 'ai-content-wizard') . '

'; ai_content_wizard_display_system_check(); echo ''; } function ai_content_wizard_display_system_check() { $results = ai_content_wizard_system_check(); echo '

' . esc_html__('System Check', 'ai-content-wizard') . '

'; echo ''; echo ''; echo ''; foreach ($results as $result) { $color = $result[3] ? 'green' : ($result[3] === 'warning' ? 'orange' : 'red'); echo ''; echo ''; echo ''; echo ''; echo ''; $helpMessage = ai_content_wizard_get_help_message($result[5]); echo ''; // Добавить для отладки echo ''; echo ''; } echo '
' . esc_html__('Requirement', 'ai-content-wizard') . '' . esc_html__('Current Value', 'ai-content-wizard') . '' . esc_html__('Required Value', 'ai-content-wizard') . '' . esc_html__('Status', 'ai-content-wizard') . '' . esc_html__('Recommendation', 'ai-content-wizard') . '
' . esc_html($result[0]) . '' . esc_html($result[1]) . '' . esc_html($result[2]) . '' . ($result[3] ? esc_html__('OK', 'ai-content-wizard') : esc_html__('Fail', 'ai-content-wizard')) . '' . esc_html($result[4]) . ' ' . esc_html__('Need help contacting your host?', 'ai-content-wizard') . '
'; // Всплывающее окно с подсказками echo ''; } function ai_content_wizard_get_help_message($helpId) { switch ($helpId) { case 'php-version': return __('Dear Hosting Provider,

I am writing to request an upgrade to the PHP version on my server. My website requires PHP version 7.1 or higher for optimal performance and security. Could you please assist with upgrading the PHP version on my server?

Thank you for your support.', 'ai-content-wizard'); case 'memory-limit': return __('Dear Hosting Provider,

My website requires at least 256M of PHP memory limit to operate efficiently. I kindly ask for your assistance in increasing the PHP memory limit on my server to meet this requirement.

Thank you for your help.', 'ai-content-wizard'); case 'max-execution-time': return __('Dear Hosting Provider,

I am encountering issues with timeouts on my website. To resolve this, I need the PHP maximum execution time to be at least 300 seconds. Could you please increase this limit on my server?

Your assistance is greatly appreciated.', 'ai-content-wizard'); case 'seo-plugin': return __('Dear Plugin Developer,

I am using the AI Content Wizard plugin on my WordPress website and noticed it recommends having an SEO plugin like Yoast, Rank Math, or All in One SEO for optimal features. Can you please provide guidance or assistance in selecting and installing the right SEO plugin for my site?

Thank you for your support.', 'ai-content-wizard'); case 'uploads-directory': return __('Dear Hosting Provider,

My website requires the ability to upload files and generate media, but currently, the uploads directory is not writable. Can you please assist in ensuring that the uploads directory on my server is writable?

Thank you for your help.', 'ai-content-wizard'); case 'http-timeout': return __('Dear Hosting Provider,

I am experiencing issues with HTTP request timeouts on my website. To resolve this, I need the server to handle HTTP requests with a timeout of at least 15 seconds. Could you please assist in adjusting this setting?

Your help is much appreciated.', 'ai-content-wizard'); default: error_log('Returning default message for unknown ID: ' . $helpId); // Для отладки return __('No specific help message available for this issue.', 'ai-content-wizard'); } } function ai_content_wizard_system_check() { $results = []; // Проверка версии PHP $results[] = [ 'PHP Version >= 7.1', phpversion(), '7.1', phpversion() >= '7.1', 'Ensure your server is running PHP version 7.1 or higher for optimal performance and security.', 'php-version' ]; // Проверка памяти $memory_limit = ini_get('memory_limit'); $required_memory = '256M'; $results[] = [ 'Memory Limit >= 256M', $memory_limit, $required_memory, ai_content_wizard_compare_memory($memory_limit, $required_memory), 'Increase the PHP memory limit to at least 256M to handle intensive operations.', 'memory-limit' ]; // Проверка таймаута $max_execution_time = ini_get('max_execution_time'); $execution_status = $max_execution_time < 100 ? 'Fail' : ($max_execution_time < 300 ? 'warning' : 'OK'); $execution_color = $execution_status === 'OK' ? 'green' : ($execution_status === 'warning' ? 'orange' : 'red'); $results[] = [ 'Max Execution Time', $max_execution_time . ' seconds', '>= 300 seconds', $execution_status, 'Set the PHP maximum execution time to at least 300 seconds to prevent timeouts during resource-intensive tasks.', 'max-execution-time' ]; // Проверка наличия SEO плагинов $seo_plugin_status = ai_content_wizard_is_seo_plugin_active() ? 'OK' : 'warning'; $results[] = [ 'SEO Plugin Installed', ai_content_wizard_get_seo_plugins_list(), 'Yoast, Rank Math, or All in One SEO', $seo_plugin_status, 'Having an SEO plugin like Yoast, Rank Math, or All in One SEO is recommended for optimal SEO features.', 'seo-plugin' ]; // Проверка возможности записи в директорию $upload_dir = wp_upload_dir(); $upload_dir_writable = is_writable($upload_dir['basedir']); $results[] = [ 'Writable Uploads Directory', $upload_dir_writable ? 'Writable' : 'Not Writable', 'Writable', $upload_dir_writable, 'Ensure the uploads directory is writable to allow file uploads and media generation.', 'uploads-directory' ]; // Проверка таймаута HTTP-запросов $http_timeout_ok = ai_content_wizard_check_http_timeout(); $results[] = [ 'HTTP Request Timeout', $http_timeout_ok ? 'OK' : 'Fail', 'OK', $http_timeout_ok, 'Ensure the server can handle HTTP requests with a timeout of at least 15 seconds.', 'http-timeout' ]; return $results; } function ai_content_wizard_is_seo_plugin_active() { include_once(ABSPATH . 'wp-admin/includes/plugin.php'); return is_plugin_active('wordpress-seo/wp-seo.php') || is_plugin_active('seo-by-rank-math/rank-math.php') || is_plugin_active('all-in-one-seo-pack/all_in_one_seo_pack.php'); } function ai_content_wizard_get_seo_plugins_list() { $plugins = []; if (is_plugin_active('wordpress-seo/wp-seo.php')) { $plugins[] = 'Yoast SEO'; } if (is_plugin_active('seo-by-rank-math/rank-math.php')) { $plugins[] = 'Rank Math SEO'; } if (is_plugin_active('all-in-one-seo-pack/all_in_one_seo_pack.php')) { $plugins[] = 'All in One SEO Pack'; } return implode(', ', $plugins) ?: 'None'; } function ai_content_wizard_compare_memory($current_limit, $required_limit) { $current_bytes = ai_content_wizard_convert_to_bytes($current_limit); $required_bytes = ai_content_wizard_convert_to_bytes($required_limit); return $current_bytes >= $required_bytes; } function ai_content_wizard_convert_to_bytes($value) { $value = trim($value); $last = strtolower($value[strlen($value) - 1]); $value = (int) $value; switch($last) { case 'g': $value *= 1024; case 'm': $value *= 1024; case 'k': $value *= 1024; } return $value; } function ai_content_wizard_check_http_timeout() { // Устанавливаем рекомендуемый таймаут $recommended_timeout = 15; // секунды // Делаем тестовый запрос для проверки таймаута $response = wp_remote_post('https://example.com', ['timeout' => $recommended_timeout]); if (is_wp_error($response)) { $error_message = $response->get_error_message(); // Проверяем, не связана ли ошибка с таймаутом return strpos($error_message, 'timed out') === false; } return true; }