Changeset 1198492 for health-check
- Timestamp:
- 07/14/2015 04:39:37 AM (10 years ago)
- Location:
- health-check/trunk
- Files:
-
- 2 edited
-
health-check.php (modified) (3 diffs)
-
readme.txt (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
health-check/trunk/health-check.php
r405385 r1198492 3 3 Plugin Name: Health Check 4 4 Plugin URI: http://wordpress.org/extend/plugins/health-check/ 5 Description: Checks the health of your WordPress install 5 Description: Checks the health of your WordPress install. 6 6 Author: The WordPress.org community 7 7 Version: 0.3-alpha 8 8 Author URI: http://wordpress.org/extend/plugins/health-check/ 9 9 */ 10 define('HEALTH_CHECK_PHP_VERSION', '5.2.4'); 11 define('HEALTH_CHECK_MYSQL_VERSION', '5.0'); 10 define( 'HEALTH_CHECK_PHP_MIN_VERSION', '5.2.4' ); 11 define( 'HEALTH_CHECK_PHP_REC_VERSION', '5.6' ); 12 define( 'HEALTH_CHECK_MYSQL_MIN_VERSION', '5.0' ); 13 define( 'HEALTH_CHECK_MYSQL_REC_VERSION', '5.5' ); 12 14 13 15 class HealthCheck { 14 16 15 function action_plugins_loaded() { 16 if ( get_transient( 'health-check-version-test' ) ) 17 add_action('admin_notices', array('HealthCheck', 'action_admin_notice')); 18 17 static function action_plugins_loaded() { 19 18 add_action( 'admin_menu', array( 'HealthCheck', 'action_admin_menu' ) ); 19 add_filter( 'plugin_row_meta', array( 'HealthCheck', 'settings_link' ), 10, 2 ); 20 20 } 21 21 22 function action_activate() {23 set_transient( 'health-check-version-test', '1', 300);22 static function action_admin_menu() { 23 add_dashboard_page( __( 'Heath Check', 'health-check' ), __( 'Heath Check', 'health-check' ), 'manage_options', 'health-check', array( 'HealthCheck', 'dashboard_page' ) ); 24 24 } 25 25 26 function action_admin_notice() { 27 echo HealthCheck::get_message(); 28 delete_transient( 'health-check-version-test' ); 26 static function settings_link( $meta, $name ) { 27 if ( plugin_basename( __FILE__ ) === $name ) { 28 $meta[] = sprintf( '<a href="%s">' . __( 'Health Check', 'health-check' ) . '</a>', menu_page_url( 'health-check', false ) ); 29 } 30 31 return $meta; 29 32 } 30 33 31 function action_admin_menu() { 32 add_dashboard_page( __( 'Heath Check', 'health-check' ), __( 'Heath Check', 'health-check' ), 'manage_options', 'health-check', array( 'HealthCheck', 'dashboard_page' ) ); 33 } 34 35 function dashboard_page() { 34 static function dashboard_page() { 36 35 ?> 37 36 <div class="wrap"><?php screen_icon(); ?> … … 42 41 } 43 42 44 function get_message() {43 static function get_message() { 45 44 global $wpdb; 46 $php_version_check = version_compare(HEALTH_CHECK_PHP_VERSION, PHP_VERSION, '<='); 47 $mysql_version_check = version_compare(HEALTH_CHECK_MYSQL_VERSION, $wpdb->db_version(), '<='); 45 46 $all_pass = true; 47 48 $php_min_version_check = version_compare( HEALTH_CHECK_PHP_MIN_VERSION, PHP_VERSION, '<=' ); 49 $php_rec_version_check = version_compare( HEALTH_CHECK_PHP_REC_VERSION, PHP_VERSION, '<=' ); 50 51 $mysql_min_version_check = version_compare( HEALTH_CHECK_MYSQL_MIN_VERSION, $wpdb->db_version(), '<=' ); 52 $mysql_rec_version_check = version_compare( HEALTH_CHECK_MYSQL_REC_VERSION, $wpdb->db_version(), '<=' ); 53 48 54 $json_check = HealthCheck::json_check(); 49 55 $db_dropin = file_exists( WP_CONTENT_DIR . '/db.php' ); 50 $message =''; 51 52 if ( !$php_version_check ) 53 $message .= "<p><strong>".__('Warning:', 'health-check')."</strong> ".sprintf(__('Your server is running PHP version %1$s. WordPress 3.2 will require PHP version %2$s.', 'health-check'), PHP_VERSION, HEALTH_CHECK_PHP_VERSION)."</p>"; 54 if ( !$mysql_version_check ) { 55 $message .= "<p><strong>".__('Warning:', 'health-check')."</strong> ".sprintf(__('Your server is running MySQL version %1$s. WordPress 3.2 will require MySQL version %2$s', 'health-check'), $wpdb->db_version(), HEALTH_CHECK_MYSQL_VERSION)."</p>"; 56 57 if ( $db_dropin ) 58 $message .= "<p><strong>".__('Note:', 'health-check')."</strong> ".__('You are using a <code>wp-content/db.php</code> drop-in which may not being using a MySQL database.', 'health-check')."</p>"; 56 57 $message = '<p>' . sprintf( __( 'Your server is running PHP version <strong>%1$s</strong> and MySQL version <strong>%2$s</strong>.', 'health-check' ), PHP_VERSION, $wpdb->db_version() ) . '</p>'; 58 $success = ''; 59 $warning = ''; 60 $error = ''; 61 62 if ( ! $php_min_version_check ) { 63 $error .= "<p><strong>" . __( 'Error:', 'health-check' ) . "</strong> " . sprintf( __( 'WordPress 3.2+ requires PHP version %s.', 'health-check' ), HEALTH_CHECK_PHP_MIN_VERSION ) . "</p>"; 64 $all_pass = false; 65 } 66 67 if ( ! $mysql_min_version_check ) { 68 $error .= "<p><strong>" . __( 'Error:', 'health-check' ) . "</strong> " . sprintf( __( 'WordPress 3.2+ requires MySQL version %s', 'health-check' ), HEALTH_CHECK_MYSQL_MIN_VERSION ) . "</p>"; 69 $all_pass = false; 70 71 if ( $db_dropin ) { 72 $error .= "<p><strong>" . __( 'Note:', 'health-check' ) . "</strong> " . __( 'You are using a <code>wp-content/db.php</code> drop-in which may not being using a MySQL database.', 'health-check' ) . "</p>"; 73 } 59 74 } 60 75 61 76 if ( ! $json_check ) { 62 $message .= "<p><strong>".__('Note:', 'health-check')."</strong> ".__('The PHP install on your server has the JSON extension disabled and is therefore not compatible with WordPress 3.2.', 'health-check')."</p>"; 77 $error .= "<p><strong>".__('Note:', 'health-check')."</strong> ".__('The PHP install on your server has the JSON extension disabled and is therefore not compatible with WordPress 3.2.', 'health-check')."</p>"; 78 $all_pass = false; 63 79 } 64 80 65 if ( $php_version_check && $mysql_version_check && $json_check) { 66 $message .= "<p><strong>".__('Excellent:', 'health-check')."</strong> ".sprintf(__('Your server is running PHP version %1$s and MySQL version %2$s which will be great for WordPress 3.2 onward.', 'health-check'), PHP_VERSION, $wpdb->db_version())."</p>"; 67 $message = "<div id='health-check-warning' class='updated'>" . $message . "</div>"; 81 if ( version_compare( $wpdb->db_version(), '5.5.3', '<' ) ) { 82 $warning .= "<p><strong>" . __( 'Error:', 'health-check' ) . "</strong> " . sprintf( __( "WordPress' utf8mb4 support requires MySQL version %s", 'health-check' ), $wpdb->db_version(), '5.5.3' ) . "</p>"; 83 $all_pass = false; 84 } 85 86 if ( $wpdb->use_mysqli ) { 87 $mysql_client_version = mysqli_get_client_info(); 68 88 } else { 69 $message .= "<p>". sprintf( __('Once your host has upgraded your server you can visit <a href=%s>Dashboard > Health Check</a> to check your compatibility again.', 'health-check' ), menu_page_url( 'health-check', false ) ) ."</p>"; 70 $message = "<div id='health-check-warning' class='error'>" . $message . "</div>"; 89 $mysql_client_version = mysql_get_client_info(); 71 90 } 72 91 92 /* 93 * libmysql has supported utf8mb4 since 5.5.3, same as the MySQL server. 94 * mysqlnd has supported utf8mb4 since 5.0.9. 95 */ 96 if ( false !== strpos( $mysql_client_version, 'mysqlnd' ) ) { 97 $mysql_client_version = preg_replace( '/^\D+([\d.]+).*/', '$1', $mysql_client_version ); 98 if ( version_compare( $mysql_client_version, '5.0.9', '<' ) ) { 99 $warning .= "<p><strong>" . __( 'Warning:', 'health-check' ) . "</strong> " . sprintf( __( 'WordPress\' utf8mb4 support requires MySQL client library (%1$s) version %2$s.', 'health-check' ), 'mysqlnd', '5.0.9' ) . "</p>"; 100 $all_pass = false; 101 } 102 } else { 103 if ( version_compare( $mysql_client_version, '5.5.3', '<' ) ) { 104 $warning .= "<p><strong>" . __( 'Warning:', 'health-check' ) . "</strong> " . sprintf( __( 'WordPress\' utf8mb4 support requires MySQL client library (%1$s) version %2$s.', 'health-check' ), 'libmysql', '5.5.3' ) . "</p>"; 105 $all_pass = false; 106 } 107 } 108 109 if ( ! $php_rec_version_check ) { 110 $warning .= "<p><strong>" . __( 'Warning:', 'health-check' ) . "</strong> " . sprintf( __( 'For performance and security reasons, we strongly recommend running PHP version %s or higher.', 'health-check' ), HEALTH_CHECK_PHP_REC_VERSION ) . "</p>"; 111 $all_pass = false; 112 } 113 114 if ( ! $mysql_rec_version_check ) { 115 $error .= "<p><strong>" . __( 'Error:', 'health-check' ) . "</strong> " . sprintf( __( 'For performance and security reasons, we strongly recommend running MySQL version %s or higher.', 'health-check' ), HEALTH_CHECK_MYSQL_REC_VERSION ) . "</p>"; 116 $all_pass = false; 117 118 if ( $db_dropin ) { 119 $error .= "<p><strong>" . __( 'Note:', 'health-check' ) . "</strong> " . __( 'You are using a <code>wp-content/db.php</code> drop-in which may not being using a MySQL database.', 'health-check' ) . "</p>"; 120 } 121 } 122 123 if ( $all_pass ) { 124 $success = "<p><strong>" . __( 'Excellent:', 'health-check' ) . "</strong> " . __( 'Everything is up to date!', 'health-check' ) . "</p>"; 125 } 126 127 if ( $error ) { 128 $message .= "<div id='health-check-warning' class='notice notice-error'>" . $error . "</div>"; 129 } 130 131 if ( $warning ) { 132 $message .= "<div id='health-check-warning' class='notice notice-warning'>" . $warning . "</div>"; 133 } 134 135 if ( $success ) { 136 $message .= "<div id='health-check-warning' class='notice notice-success'>" . $success . "</div>"; 137 } 138 139 if ( $error || $warning ) { 140 $message .= "<p>". sprintf( __('Once your host has upgraded your server you can visit <a href="%s">Dashboard > Health Check</a> to check your compatibility again.', 'health-check' ), menu_page_url( 'health-check', false ) ) ."</p>"; 141 } 73 142 74 143 return $message; 75 144 } 76 77 function json_check() {145 146 static function json_check() { 78 147 $extension_loaded = extension_loaded( 'json' ); 79 148 $functions_exist = function_exists( 'json_encode' ) && function_exists( 'json_decode' ); … … 85 154 /* Initialize ourselves */ 86 155 add_action('plugins_loaded', array('HealthCheck','action_plugins_loaded')); 87 register_activation_hook( __FILE__, array( 'HealthCheck', 'action_activate' ) );88 156 ?> -
health-check/trunk/readme.txt
r405386 r1198492 1 1 === Health Check === 2 2 Tags: health check 3 Contributors: westi 3 Contributors: westi, pento 4 4 Requires at least: 2.9.2 5 Tested up to: 3.25 Tested up to: 4.3 6 6 Stable tag: 0.2.1 7 7 … … 23 23 1. Upload to your plugins folder, usually `wp-content/plugins/` 24 24 2. Activate the plugin on the plugin screen. 25 3. See if your server is prepared for WordPress 3.225 3. See if your server is prepared for WordPress 26 26 27 27 == Screenshots == … … 30 30 31 31 == Changelog == 32 33 = v 0.3 = 34 * Added recommended PHP and MySQL versions 35 * Check for utf8mb4 support 36 * Fixed a bunch of PHP warnings 32 37 33 38 = v 0.2.1 =
Note: See TracChangeset
for help on using the changeset viewer.