init_all_tests(); } class PHP_WP_Info { public const VERSION = '1.6.2'; private bool $debug_mode = true; private $php_version = '≥7.4'; private $mysql_version = '8.0'; // TODO: Min MariaDB version ? private $curl_version = '7.38'; private $redis_version = '3.0'; // TODO: Check vs plugin ? private $db_infos = array(); private $db_link = false; private $redis_infos = array(); private $redis_link = false; public function __construct() { // Use file sessions: php.ini may use Redis without AUTH in save_path, which throws RedisException NOAUTH. $handler = ini_get( 'session.save_handler' ); if ( in_array( $handler, array( 'redis', 'rediscluster' ), true ) ) { $session_dir = sys_get_temp_dir() . '/phpwpinfo_sessions'; if ( ! is_dir( $session_dir ) ) { @mkdir( $session_dir, 0700, true ); } ini_set( 'session.save_handler', 'files' ); ini_set( 'session.save_path', $session_dir ); } @session_start(); if ( $this->debug_mode === true ) { ini_set( 'display_errors', 1 ); ini_set( 'log_errors', 1 ); ini_set( 'error_log', __DIR__ . '/error_log.txt' ); error_reporting( E_ALL ); } // Check GET for phpinfo if ( isset( $_GET['phpinfo'] ) && $_GET['phpinfo'] === 'true' ) { phpinfo(); exit(); } // Check GET for self-destruction if ( isset( $_GET['self-destruction'] ) && $_GET['self-destruction'] === 'true' ) { @unlink( __FILE__ ); clearstatcache(); if ( is_file( __FILE__ ) ) { die( 'Self-destruction KO ! Sorry, but you must remove me manually !' ); } die( 'Self-destruction OK !' ); } $this->_check_request_database(); $this->_check_request_redis(); $this->_check_request_adminer(); $this->_check_request_wordpress(); } public function init_all_tests() { $this->get_header(); $this->test_versions(); $this->test_php_config(); $this->test_php_extensions(); $this->test_database_config(); $this->test_apache_modules(); $this->test_apache_directory_indexes(); $this->test_form_mail(); $this->test_form_redis(); $this->test_form_connectivity(); $this->get_footer(); } /** * Main test, check if php/databse/git are installed and right version for WP */ public function test_versions() { $this->html_table_open( 'General informations & tests PHP/Database Version', '', 'Required', 'Recommended', 'Current' ); // Webserver used $this->html_table_row( 'Web server', $this->_get_current_webserver(), '', '', 'info', 3 ); // Test PHP Version if ( strpos( PHP_SAPI, 'cgi' ) !== false ) { $this->html_table_row( 'PHP Type', 'CGI with Apache Worker or another webserver', '', '', 'success', 3 ); } else { $this->html_table_row( 'PHP Type', 'Apache Module (low performance)', '', '', 'warning', 3 ); } // Test PHP Version $php_version = PHP_VERSION; if ( version_compare( $php_version, $this->php_version, '>=' ) ) { $this->html_table_row( 'PHP Version', $this->php_version, '> 7.3', $php_version, 'success' ); } else { $this->html_table_row( 'PHP Version', $this->php_version, '> 7.3', $php_version, 'error' ); } // Test Database Client extensions/version. if ( ! extension_loaded( 'mysqli' ) || ! is_callable( 'mysqli_connect' ) ) { $this->html_table_row( 'PHP MySQLi Extension', 'Yes', 'Yes', 'Not installed', 'error' ); } else { $this->html_table_row( 'PHP MySQLi Extension', 'Yes', 'Yes', 'Installed', 'success' ); $this->html_table_row( 'PHP MySQLi Client Version', $this->mysql_version, '> 5.5', mysqli_get_client_info(), 'info' ); } // Test Databse Server Version if ( $this->db_link !== false && is_callable( 'mysqli_get_server_info' ) ) { $mysql_version = preg_replace( '/[^0-9.].*/', '', mysqli_get_server_info( $this->db_link ) ); if ( version_compare( $mysql_version, $this->mysql_version, '>=' ) ) { $this->html_table_row( 'Database Version', $this->mysql_version, '> 5.5', $mysql_version, 'success' ); } else { $this->html_table_row( 'Database Version', $this->mysql_version, '> 5.5', $mysql_version, 'error' ); } } else { // Show Database Form $this->html_form_database( $this->db_infos === false ); $this->html_table_row( 'Database Version', $this->mysql_version, '-', 'Not available, needs database credentials.', 'warning' ); } // Test if the server is connected to the server by attempt to find the IP(v4) of www.google.fr if ( gethostbyname( 'www.google.fr' ) !== 'www.google.fr' ) { $this->html_table_row( 'Internet connectivity (Google)', 'No', 'Yes', 'Yes', 'success' ); } else { $this->html_table_row( 'Internet connectivity (Google)', 'No', 'Yes', 'No', 'error' ); } // Test if the command 'git' exists, so it tests if Git is installed if ( $this->_command_exists( 'git' ) === true ) { $this->html_table_row( 'GIT is installed?', 'No', 'Yes', 'Yes' ); } else { $this->html_table_row( 'GIT is installed?', 'No', 'Yes', 'No', 'error' ); } $this->html_table_row( 'Remote IP via $_SERVER["REMOTE_ADDR"]', '', '', $_SERVER['REMOTE_ADDR'], 'info' ); if ( isset( $_SERVER['HTTP_X_FORWARDED_FOR'] ) ) { $this->html_table_row( 'Remote IP via $_SERVER["HTTP_X_FORWARDED_FOR"]', '', '', $_SERVER['HTTP_X_FORWARDED_FOR'], 'info' ); } if ( isset( $_SERVER['HTTP_X_FORWARDED'] ) ) { $this->html_table_row( 'Remote IP via $_SERVER["HTTP_X_FORWARDED"]', '', '', $_SERVER['HTTP_X_FORWARDED'], 'info' ); } if ( isset( $_SERVER['HTTP_CLIENT_IP'] ) ) { $this->html_table_row( 'Remote IP via $_SERVER["HTTP_CLIENT_IP"]', '', '', $_SERVER['HTTP_CLIENT_IP'], 'info' ); } $this->html_table_row( 'Public IP via browser fetch (api.ipify.org). May not work if Content-Security-Policy blocks connect-src to that host.', '', '', 'Loading…', 'warning realip' ); } public function test_php_extensions() { $this->html_table_open( 'PHP Extensions', '', 'Required', 'Recommended', 'Current' ); $extensions = array( // Higly recommanded 'json' => 'error', 'curl' => 'error', 'dom' => 'error', 'exif' => 'info', 'fileinfo' => 'info', 'igbinary' => 'info', 'intl' => 'error', 'mbstring' => 'error', 'openssl' => 'error', 'pcre' => 'error', 'zlib' => 'error', 'iconv' => 'error', 'xml' => 'error', 'zip' => 'info', // Optional 'xmlreader' => 'error', // TO DELETE? (Not in handbook) // Cache 'apcu' => 'info', 'memcache' => 'info', // TO DELETE? (Not in handbook) 'memcached' => 'info', 'redis' => 'info', // Others 'ftp' => 'info', 'ssh2' => 'info', 'sockets' => 'info', // Debug 'blackfire' => 'info', 'newrelic' => 'info', 'xdebug' => 'info', // Deprecated ? 'suhosin' => 'info', // TO DELETE? (Not in handbook + Deprecated) 'tidy' => 'info', // TO DELETE? (Not in handbook) ); foreach ( $extensions as $extension => $status ) { if ( ! extension_loaded( $extension ) ) { $is_wp_requirements = ( 'error' === $status ) ? 'Yes' : 'No'; $this->html_table_row( $extension, $is_wp_requirements, 'Yes', 'Not installed', $status ); } else { $this->html_table_row( $extension, 'Yes', 'Yes', 'Installed', 'success' ); } } /** * Check GD and Imagick like WordPress does. */ $gd = extension_loaded( 'gd' ) && function_exists( 'gd_info' ); $imagick = extension_loaded( 'imagick' ) && class_exists( 'Imagick', false ) && class_exists( 'ImagickPixel', false ) && version_compare( phpversion( 'imagick' ), '2.2.0', '>=' ); // GD/Imagick lib. if ( $gd ) { $this->html_table_row( 'Image manipulation (GD)', 'Yes', 'Yes', 'Installed', 'success' ); } if ( $imagick ) { $this->html_table_row( 'Image manipulation (Imagick)', 'Yes', 'Yes', 'Installed', 'success' ); } if ( ! $gd && ! $imagick ) { $this->html_table_row( 'Image manipulation (GD, Imagick)', 'Yes', 'Yes', 'Not installed', 'error' ); } if ( is_callable( 'opcache_reset' ) ) { $this->html_table_row( 'Opcode (Zend OPcache, APC, Xcache, eAccelerator or Zend Optimizer)', 'No', 'Yes', 'Zend OPcache Installed', 'success' ); } elseif ( is_callable( 'eaccelerator_put' ) ) { $this->html_table_row( 'Opcode (Zend OPcache, APC, Xcache, eAccelerator or Zend Optimizer)', 'No', 'Yes', 'eAccelerator Installed', 'success' ); } elseif ( is_callable( 'xcache_set' ) ) { $this->html_table_row( 'Opcode (Zend OPcache, APC, Xcache, eAccelerator or Zend Optimizer)', 'No', 'Yes', 'XCache Installed', 'success' ); } elseif ( is_callable( 'apc_store' ) ) { $this->html_table_row( 'Opcode (Zend OPcache, APC, Xcache, eAccelerator or Zend Optimizer)', 'No', 'Yes', 'APC Installed', 'success' ); } elseif ( is_callable( 'zend_optimizer_version' ) ) { $this->html_table_row( 'Opcode (Zend OPcache, APC, Xcache, eAccelerator or Zend Optimizerr)', 'No', 'Yes', 'Zend Optimizer Installed', 'success' ); } else { $this->html_table_row( 'Opcode (Zend OPcache, APC, Xcache, eAccelerator or Zend Optimizer)', 'No', 'Yes', 'Not installed', 'warning' ); } if ( ! is_callable( 'finfo_open' ) && ! is_callable( 'mime_content_type' ) ) { $this->html_table_row( 'Mime type', 'Yes*', 'Yes', 'Not installed', 'warning' ); } else { $this->html_table_row( 'Mime type', 'Yes*', 'Yes', 'Installed', 'success' ); } if ( ! is_callable( 'hash' ) && ! is_callable( 'mhash' ) ) { $this->html_table_row( 'Hash', 'No', 'Yes', 'Not installed', 'info' ); } else { $this->html_table_row( 'Hash', 'No', 'Yes', 'Installed', 'success' ); } if ( ! is_callable( 'set_time_limit' ) ) { $this->html_table_row( 'set_time_limit', 'No', 'Yes', 'Not Available', 'info' ); } else { $this->html_table_row( 'set_time_limit', 'No', 'Yes', 'Available', 'success' ); } if ( extension_loaded( 'curl' ) ) { $curl = curl_version(); $this->html_table_row( 'Curl version', '-', $this->curl_version, sprintf( '%s %s', $curl['version'], $curl['ssl_version'] ), 'info' ); } $this->html_table_close( '(*) Items with an asterisk are not required by WordPress, but it is highly recommended by me!' ); } public function test_apache_modules() { if ( $this->_get_current_webserver() !== 'Apache' ) { return false; } $current_modules = (array) $this->_get_apache_modules(); $modules = array( 'mod_deflate' => false, 'mod_env' => false, 'mod_expires' => false, 'mod_headers' => false, 'mod_filter' => false, 'mod_mime' => false, 'mod_rewrite' => true, 'mod_setenvif' => false, ); $this->html_table_open( 'Apache Modules', '', 'Required', 'Recommended', 'Current' ); foreach ( $modules as $module => $is_required ) { $is_required = ( $is_required === true ) ? 'Yes' : 'No'; // Boolean to Yes/NO $name = ucfirst( str_replace( 'mod_', '', $module ) ); if ( ! in_array( $module, $current_modules, true ) ) { $this->html_table_row( $name, $is_required, 'Recommended', 'Not installed', 'error' ); } else { $this->html_table_row( $name, $is_required, 'Recommended', 'Installed', 'success' ); } } $this->html_table_close(); return true; } /** * Probe whether Apache directory listing (Options +Indexes / mod_autoindex) is effective for a folder without an index file. */ public function test_apache_directory_indexes() { if ( $this->_get_current_webserver() !== 'Apache' ) { return false; } $this->html_table_open( 'Apache directory listing (Options Indexes)', '', 'Required', 'Recommended', 'Current' ); $probe_dir = __DIR__ . '/indexes_probe'; if ( ! is_dir( $probe_dir ) ) { $this->html_table_row( 'indexes_probe/', '-', '-', 'Missing (ship indexes_probe/ with phpwpinfo.php)', 'info' ); $this->html_table_close( 'This check requests indexes_probe/ (no index file). If directory listing is enabled, Apache returns an "Index of" page — a security risk on production sites.' ); return false; } if ( ! function_exists( 'curl_init' ) ) { $this->html_table_row( 'Directory listing (autoindex)', 'Off', 'Off', 'cURL extension required', 'info' ); $this->html_table_close(); return false; } $url = $this->_get_indexes_probe_url(); $result = $this->_http_get_local_url( $url ); if ( $result['error'] !== null ) { $this->html_table_row( 'Directory listing (autoindex)', 'Off', 'Off', htmlspecialchars( $result['error'], ENT_QUOTES, 'UTF-8' ), 'info' ); $this->html_table_close(); return false; } $body = is_string( $result['body'] ) ? $result['body'] : ''; $listing = $this->_response_looks_like_apache_directory_listing( $body ); if ( $listing ) { $this->html_table_row( 'Directory listing (autoindex)', 'Off', 'Off', 'Enabled (Options +Indexes or equivalent)', 'error' ); } else { $this->html_table_row( 'Directory listing (autoindex)', 'Off', 'Off', 'Not shown (HTTP ' . (int) $result['code'] . ')', 'success' ); } $this->html_table_close( 'Uses an HTTP GET to ' . htmlspecialchars( $url, ENT_QUOTES, 'UTF-8' ) . ' and detects typical mod_autoindex HTML ("Index of" in title or h1).' ); return true; } public function test_php_config() { $this->html_table_open( 'PHP Configuration', '', 'Required', 'Recommended', 'Current' ); $value = date_default_timezone_get(); if ( empty( $value ) ) { $this->html_table_row( 'date_default_timezone ', '-', '-', 'Not empty value', 'warning' ); } else { $this->html_table_row( 'date_default_timezone ', '-', '-', $value, 'info' ); } $value = ini_get( 'register_argc_argv ' ); if ( strtolower( $value ) === 'on' ) { $this->html_table_row( 'register_argc_argv ', '-', 'Off', 'On', 'warning' ); } else { $this->html_table_row( 'register_argc_argv ', '-', 'Off', 'Off', 'success' ); } $value = $this->return_bytes( ini_get( 'memory_limit' ) ); if ( $value !== '-1' && (int) $value < $this->return_bytes( '64M' ) ) { $this->html_table_row( 'memory_limit', '64 MB', '256 MB', $this->_format_bytes( $value ), 'error' ); } else { $status = ( (int) $value >= $this->return_bytes( '256M' ) || $value === '-1' ) ? 'success' : 'warning'; $this->html_table_row( 'memory_limit', '64 MB', '256 MB', $this->_format_bytes( $value ), $status ); } $value = ini_get( 'max_input_vars' ); if ( (int) $value < 5000 ) { $this->html_table_row( 'max_input_vars', '5000', '10000', $value, 'error' ); } else { $status = ( (int) $value >= 10000 ) ? 'success' : 'warning'; $this->html_table_row( 'max_input_vars', '5000', '10000', $value, $status ); } $value = ini_get( 'max_execution_time' ); if ( $value !== '-1' && (int) $value < 60 ) { $this->html_table_row( 'max_execution_time', '-', '300', $value, 'error' ); } else { $status = ( (int) $value >= 300 || $value === '-1' ) ? 'success' : 'warning'; $this->html_table_row( 'max_execution_time', '-', '300', $value, $status ); } $value = ini_get( 'max_input_time' ); if ( $value !== '-1' && (int) $value < 60 ) { $this->html_table_row( 'max_input_time', '-', '300', $value, 'error' ); } else { $status = ( (int) $value >= 300 || $value === '-1' ) ? 'success' : 'warning'; $this->html_table_row( 'max_input_time', '-', '300', $value, $status ); } $value = ini_get( 'file_uploads' ); if ( strtolower( $value ) === 'on' || $value === '1' ) { $this->html_table_row( 'file_uploads', 'On', 'On', 'On', 'success' ); } else { $this->html_table_row( 'file_uploads', 'On', 'On', 'Off', 'error' ); } $value = $this->return_bytes( ini_get( 'upload_max_filesize' ) ); if ( (int) $value < $this->return_bytes( '32M' ) ) { $this->html_table_row( 'upload_max_filesize', '32 MB', '128 MB', $this->_format_bytes( $value ), 'error' ); } else { $status = ( (int) $value >= $this->return_bytes( '128M' ) ) ? 'success' : 'warning'; $this->html_table_row( 'upload_max_filesize', '32 MB', '128 MB', $this->_format_bytes( $value ), $status ); } $value = $this->return_bytes( ini_get( 'post_max_size' ) ); if ( (int) $value < $this->return_bytes( '32M' ) ) { $this->html_table_row( 'post_max_size', '32 MB', '128 MB', $this->_format_bytes( $value ), 'warning' ); } else { $status = ( (int) $value >= $this->return_bytes( '128M' ) ) ? 'success' : 'warning'; $this->html_table_row( 'post_max_size', '32 MB', '128 MB', $this->_format_bytes( $value ), $status ); } $value = ini_get( 'short_open_tag' ); if ( strtolower( $value ) === 'on' ) { $this->html_table_row( 'short_open_tag', '-', 'Off', 'On', 'warning' ); } else { $this->html_table_row( 'short_open_tag', '-', 'Off', 'Off', 'success' ); } $value = ini_get( 'open_basedir' ); $this->html_table_row( 'open_basedir', $value, '', '', 'info', 3 ); $value = ini_get( 'zlib.output_compression' ); $this->html_table_row( 'zlib.output_compression', $value, '', '', 'info', 3 ); $value = ini_get( 'output_handler' ); $this->html_table_row( 'output_handler', $value, '', '', 'info', 3 ); $value = ini_get( 'disable_functions' ); $this->html_table_row( 'disable_functions', $value, '', '', 'info', 3 ); $value = ini_get( 'expose_php' ); if ( $value === '0' || strtolower( $value ) === 'off' || empty( $value ) ) { $this->html_table_row( 'expose_php', '-', '0 or Off', $value, 'success' ); } else { $this->html_table_row( 'expose_php', '-', '0 or Off', $value, 'error' ); } $value = ini_get( 'upload_tmp_dir' ); $this->html_table_row( 'upload_tmp_dir', $value, '', '', 'info', 3 ); if ( is_dir( $value ) && @is_writable( $value ) ) { $this->html_table_row( 'upload_tmp_dir writable ?', '-', 'Yes', 'Yes', 'success' ); } else { $this->html_table_row( 'upload_tmp_dir writable ?', '-', 'Yes', 'No', 'error' ); } $value = '/tmp/'; $this->html_table_row( 'System temp dir', $value, '', '', 'info', 3 ); if ( is_dir( $value ) && @is_writable( $value ) ) { $this->html_table_row( 'System temp dir writable ?', '-', 'Yes', 'Yes', 'success' ); } else { $this->html_table_row( 'System temp dir writable ?', '-', 'Yes', 'No', 'error' ); } $value = __DIR__; $this->html_table_row( 'Current dir', $value, '', '', 'info', 3 ); if ( is_dir( $value ) && @is_writable( $value ) ) { $this->html_table_row( 'Current dir writable ?', 'Yes', 'Yes', 'Yes', 'success' ); } else { $this->html_table_row( 'Current dir writable ?', 'Yes', 'Yes', 'No', 'error' ); } if ( is_callable( 'apc_store' ) ) { $value = $this->return_bytes( ini_get( 'apc.shm_size' ) ); if ( (int) $value < $this->return_bytes( '32M' ) ) { $this->html_table_row( 'apc.shm_size', '32 MB', '128 MB', $this->_format_bytes( $value ), 'error' ); } else { $status = ( (int) $value >= $this->return_bytes( '128M' ) ) ? 'success' : 'warning'; $this->html_table_row( 'apc.shm_size', '32 MB', '128 MB', $this->_format_bytes( $value ), $status ); } } $this->html_table_close(); } /** * Convert PHP variable (G/M/K) to bytes * Source: https://php.net/manual/fr/function.ini-get.php * @return int|string * * @param $val */ public function return_bytes( $val ) { $val = trim( $val ); $last = strtolower( $val[ strlen( $val ) - 1 ] ); $val = (int) $val; switch ( $last ) { // Le modifieur 'G' est disponible depuis PHP 5.1.0 case 'g': $val *= 1024; case 'm': $val *= 1024; case 'k': $val *= 1024; } return $val; } /** * SQL query cache was removed in MySQL 8.0+ and MariaDB 10.5.2+. * * @return bool */ private function _db_supports_sql_query_cache() { if ( $this->db_link === false || ! is_callable( 'mysqli_get_server_version' ) ) { return false; } $version_int = mysqli_get_server_version( $this->db_link ); if ( ! is_int( $version_int ) || $version_int <= 0 ) { return false; } $major = intdiv( $version_int, 10000 ); $minor = intdiv( $version_int % 10000, 100 ); $patch = $version_int % 100; $server_info = is_callable( 'mysqli_get_server_info' ) ? mysqli_get_server_info( $this->db_link ) : ''; $is_mariadb = is_string( $server_info ) && stripos( $server_info, 'mariadb' ) !== false; // MariaDB 10.x+ uses the same numeric encoding; MySQL never shipped 10.x. if ( ! $is_mariadb && $major >= 10 ) { $is_mariadb = true; } if ( $is_mariadb ) { if ( $major > 10 ) { return false; } if ( $major === 10 && ( $minor > 5 || ( $minor === 5 && $patch >= 2 ) ) ) { return false; } return true; } return $major < 8; } /** * @return void */ public function test_database_config() { if ( $this->db_link === false ) { return; } $this->html_table_open( 'Database Configuration', '', 'Required', 'Recommended', 'Current' ); if ( $this->_db_supports_sql_query_cache() ) { $result = mysqli_query( $this->db_link, "SHOW VARIABLES LIKE 'have_query_cache'" ); if ( $result !== false ) { while ( $row = mysqli_fetch_assoc( $result ) ) { if ( strtolower( $row['Value'] ) === 'yes' ) { $this->html_table_row( 'Query cache', '-', 'False', $row['Value'], 'error' ); } else { $this->html_table_row( 'Query cache', '-', 'False', $row['Value'], 'success' ); } } } $result = mysqli_query( $this->db_link, "SHOW VARIABLES LIKE 'query_cache_size'" ); if ( $result !== false ) { while ( $row = mysqli_fetch_assoc( $result ) ) { if ( (int) $row['Value'] >= $this->return_bytes( '8M' ) ) { $status = ( (int) $row['Value'] >= $this->return_bytes( '64M' ) ) ? 'success' : 'warning'; $this->html_table_row( 'Query cache size', '8M', '64MB', $this->_format_bytes( (int) $row['Value'] ), $status ); } else { $this->html_table_row( 'Query cache size', '8M', '64MB', $this->_format_bytes( (int) $row['Value'] ), 'error' ); } } } $result = mysqli_query( $this->db_link, "SHOW VARIABLES LIKE 'query_cache_type'" ); if ( $result !== false ) { while ( $row = mysqli_fetch_assoc( $result ) ) { if ( strtolower( $row['Value'] ) === 'on' || strtolower( $row['Value'] ) === '1' ) { $this->html_table_row( 'Query cache type', '0 or off', '1 or on', strtolower( $row['Value'] ), 'error' ); } else { $this->html_table_row( 'Query cache type', '0', $row['Value'], strtolower( $row['Value'] ), 'success' ); } } } } $is_log_slow_queries = false; $result = mysqli_query( $this->db_link, "SHOW VARIABLES LIKE 'log_slow_queries'" ); if ( $result !== false ) { while ( $row = mysqli_fetch_assoc( $result ) ) { if ( strtolower( $row['Value'] ) === 'yes' || strtolower( $row['Value'] ) === 'on' ) { $is_log_slow_queries = true; $this->html_table_row( 'Log slow queries', 'No', 'Yes', 'Yes', 'success' ); } else { $is_log_slow_queries = false; $this->html_table_row( 'Log slow queries', 'No', 'Yes', 'False', 'error' ); } } } $result = mysqli_query( $this->db_link, "SHOW VARIABLES LIKE 'long_query_time'" ); if ( $is_log_slow_queries === true && $result !== false ) { while ( $row = mysqli_fetch_assoc( $result ) ) { if ( (int) $row['Value'] <= 2 ) { $this->html_table_row( 'Long query time (sec)', '2', '1', ( (int) $row['Value'] ), 'success' ); } else { $this->html_table_row( 'Long query time (sec)', '2', '1', ( (int) $row['Value'] ), 'error' ); } } } // $this->html_table_close( '(*) Items with an asterisk are not required by WordPress, but it is highly recommended by me!' ); } public function test_form_mail() { $this->html_table_open( 'Email Configuration', '', '', '' ); $this->html_form_email(); $this->html_table_close(); } /** * Start HTML with inline CSS (no external stylesheets). * TODO: Add links to Codex/WP.org * TODO: Add colors legend */ public function get_header() { $output = ''; $output .= '' . "\n"; $output .= '' . "\n"; $output .= '
' . "\n"; $output .= '' . "\n"; $output .= '' . "\n"; $output .= '| ' . $col1 . ' | ' . "\n"; if ( ! empty( $col4 ) ) { $output .= '' . $col2 . ' | ' . "\n"; $output .= '' . $col3 . ' | ' . "\n"; $output .= '' . $col4 . ' | ' . "\n"; } else { $output .= '' . $col2 . ' | ' . "\n"; $output .= '' . $col3 . ' | ' . "\n"; } $output .= '
|---|
' . $description . '
' . "\n"; } echo $output; } /** * Add table row * Status available : success, error, warning, info * * @param string $col1 * @param string $col2 * @param string $col3 * @param string $col4 * @param string $status * @param bool $colspan */ public function html_table_row( $col1, $col2, $col3, $col4, $status = 'success', $colspan = false ) { $output = ''; $output .= '| Key | Value |
|---|---|
| $key | $value |