Health Check - Version 1.3.2

Version Description

Download this release

Release Info

Developer Clorith
Plugin Icon 128x128 Health Check
Version 1.3.2
Comparing to
See all releases

Code changes from version 1.3.1 to 1.3.2

health-check.php CHANGED
@@ -9,7 +9,7 @@
9
  * Plugin URI: https://wordpress.org/plugins/health-check/
10
  * Description: Checks the health of your WordPress install.
11
  * Author: The WordPress.org community
12
- * Version: 1.3.1
13
  * Author URI: https://wordpress.org/plugins/health-check/
14
  * Text Domain: health-check
15
  */
@@ -35,7 +35,7 @@ define( 'HEALTH_CHECK_MYSQL_MIN_VERSION', '5.0' );
35
  define( 'HEALTH_CHECK_MYSQL_REC_VERSION', '5.6' );
36
 
37
  // Set the plugin version.
38
- define( 'HEALTH_CHECK_PLUGIN_VERSION', '1.3.1' );
39
 
40
  // Set the absolute path for the plugin.
41
  define( 'HEALTH_CHECK_PLUGIN_DIRECTORY', plugin_dir_path( __FILE__ ) );
9
  * Plugin URI: https://wordpress.org/plugins/health-check/
10
  * Description: Checks the health of your WordPress install.
11
  * Author: The WordPress.org community
12
+ * Version: 1.3.2
13
  * Author URI: https://wordpress.org/plugins/health-check/
14
  * Text Domain: health-check
15
  */
35
  define( 'HEALTH_CHECK_MYSQL_REC_VERSION', '5.6' );
36
 
37
  // Set the plugin version.
38
+ define( 'HEALTH_CHECK_PLUGIN_VERSION', '1.3.2' );
39
 
40
  // Set the absolute path for the plugin.
41
  define( 'HEALTH_CHECK_PLUGIN_DIRECTORY', plugin_dir_path( __FILE__ ) );
includes/class-health-check-debug-data.php CHANGED
@@ -1123,6 +1123,50 @@ class Health_Check_Debug_Data {
1123
  return (int) $size;
1124
  }
1125
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1126
  /**
1127
  * Fetch the sizes of the WordPress directories: `wordpress` (ABSPATH), `plugins`, `themes`, and `uploads`.
1128
  * Intended to supplement the array returned by `WP_Debug_Data::debug_data()`.
@@ -1156,6 +1200,15 @@ class Health_Check_Debug_Data {
1156
  $max_execution_time -= 2;
1157
  }
1158
 
 
 
 
 
 
 
 
 
 
1159
  // Go through the various installation directories and calculate their sizes.
1160
  // No trailing slashes.
1161
  $paths = array(
@@ -1182,9 +1235,17 @@ class Health_Check_Debug_Data {
1182
 
1183
  if ( microtime( true ) - WP_START_TIMESTAMP < $max_execution_time ) {
1184
  if ( 'wordpress_size' === $name ) {
1185
- $dir_size = recurse_dirsize( $path, $exclude, $max_execution_time );
 
 
 
 
1186
  } else {
1187
- $dir_size = recurse_dirsize( $path, null, $max_execution_time );
 
 
 
 
1188
  }
1189
  }
1190
 
@@ -1248,4 +1309,71 @@ class Health_Check_Debug_Data {
1248
 
1249
  return $all_sizes;
1250
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1251
  }
1123
  return (int) $size;
1124
  }
1125
 
1126
+ public static function ajax_get_sizes() {
1127
+ check_ajax_referer( 'health-check-site-status-result' );
1128
+
1129
+ if ( ! current_user_can( 'install_plugins' ) || is_multisite() ) {
1130
+ wp_send_json_error();
1131
+ }
1132
+
1133
+ $sizes_data = Health_Check_Debug_Data::get_sizes();
1134
+ $all_sizes = array( 'raw' => 0 );
1135
+
1136
+ foreach ( $sizes_data as $name => $value ) {
1137
+ $name = sanitize_text_field( $name );
1138
+ $data = array();
1139
+
1140
+ if ( isset( $value['size'] ) ) {
1141
+ if ( is_string( $value['size'] ) ) {
1142
+ $data['size'] = sanitize_text_field( $value['size'] );
1143
+ } else {
1144
+ $data['size'] = (int) $value['size'];
1145
+ }
1146
+ }
1147
+
1148
+ if ( isset( $value['debug'] ) ) {
1149
+ if ( is_string( $value['debug'] ) ) {
1150
+ $data['debug'] = sanitize_text_field( $value['debug'] );
1151
+ } else {
1152
+ $data['debug'] = (int) $value['debug'];
1153
+ }
1154
+ }
1155
+
1156
+ if ( ! empty( $value['raw'] ) ) {
1157
+ $data['raw'] = (int) $value['raw'];
1158
+ }
1159
+
1160
+ $all_sizes[ $name ] = $data;
1161
+ }
1162
+
1163
+ if ( isset( $all_sizes['total_size']['debug'] ) && 'not available' === $all_sizes['total_size']['debug'] ) {
1164
+ wp_send_json_error( $all_sizes );
1165
+ }
1166
+
1167
+ wp_send_json_success( $all_sizes );
1168
+ }
1169
+
1170
  /**
1171
  * Fetch the sizes of the WordPress directories: `wordpress` (ABSPATH), `plugins`, `themes`, and `uploads`.
1172
  * Intended to supplement the array returned by `WP_Debug_Data::debug_data()`.
1200
  $max_execution_time -= 2;
1201
  }
1202
 
1203
+ if ( ! defined( 'WP_START_TIMESTAMP' ) ) {
1204
+ global $timestart;
1205
+ if ( version_compare( phpversion(), '5.4.0', '>=' ) && isset( $_SERVER['REQUEST_TIME_FLOAT'] ) ) {
1206
+ define( 'WP_START_TIMESTAMP', $_SERVER['REQUEST_TIME_FLOAT'] );
1207
+ } else {
1208
+ define( 'WP_START_TIMESTAMP', $timestart );
1209
+ }
1210
+ }
1211
+
1212
  // Go through the various installation directories and calculate their sizes.
1213
  // No trailing slashes.
1214
  $paths = array(
1235
 
1236
  if ( microtime( true ) - WP_START_TIMESTAMP < $max_execution_time ) {
1237
  if ( 'wordpress_size' === $name ) {
1238
+ if ( version_compare( get_bloginfo( 'version' ), '5.2.0', '<' ) ) {
1239
+ $dir_size = Health_Check_Debug_Data::recurse_dirsize( $path, $exclude, $max_execution_time );
1240
+ } else {
1241
+ $dir_size = recurse_dirsize( $path, $exclude, $max_execution_time );
1242
+ }
1243
  } else {
1244
+ if ( version_compare( get_bloginfo( 'version' ), '5.2.0', '<' ) ) {
1245
+ $dir_size = Health_Check_Debug_Data::recurse_dirsize( $path, null, $max_execution_time );
1246
+ } else {
1247
+ $dir_size = recurse_dirsize( $path, null, $max_execution_time );
1248
+ }
1249
  }
1250
  }
1251
 
1309
 
1310
  return $all_sizes;
1311
  }
1312
+
1313
+ /**
1314
+ * Fallback function for directory size calculation on sites running WordPress <5.2
1315
+ *
1316
+ * @param string $directory Full path of a directory.
1317
+ * @param string|array $exclude Optional. Full path of a subdirectory to exclude from the total, or array of paths.
1318
+ * Expected without trailing slash(es).
1319
+ * @param int $max_execution_time Maximum time to run before giving up. In seconds.
1320
+ * The timeout is global and is measured from the moment WordPress started to load.
1321
+ * @return int|false|null Size in bytes if a valid directory. False if not. Null if timeout.
1322
+ */
1323
+ static function recurse_dirsize( $directory, $exclude = null, $max_execution_time = null ) {
1324
+ $size = 0;
1325
+
1326
+ $directory = untrailingslashit( $directory );
1327
+
1328
+ if ( ! file_exists( $directory ) || ! is_dir( $directory ) || ! is_readable( $directory ) ) {
1329
+ return false;
1330
+ }
1331
+
1332
+ if (
1333
+ ( is_string( $exclude ) && $directory === $exclude ) ||
1334
+ ( is_array( $exclude ) && in_array( $directory, $exclude, true ) )
1335
+ ) {
1336
+ return false;
1337
+ }
1338
+
1339
+ if ( null === $max_execution_time ) {
1340
+ // Keep the previous behavior but attempt to prevent fatal errors from timeout if possible.
1341
+ if ( function_exists( 'ini_get' ) ) {
1342
+ $max_execution_time = ini_get( 'max_execution_time' );
1343
+ } else {
1344
+ // Disable...
1345
+ $max_execution_time = 0;
1346
+ }
1347
+
1348
+ // Leave 1 second "buffer" for other operations if $max_execution_time has reasonable value.
1349
+ if ( $max_execution_time > 10 ) {
1350
+ $max_execution_time -= 1;
1351
+ }
1352
+ }
1353
+
1354
+ $handle = opendir( $directory );
1355
+ if ( $handle ) {
1356
+ while ( ( $file = readdir( $handle ) ) !== false ) {
1357
+ $path = $directory . '/' . $file;
1358
+ if ( '.' != $file && '..' != $file ) {
1359
+ if ( is_file( $path ) ) {
1360
+ $size += filesize( $path );
1361
+ } elseif ( is_dir( $path ) ) {
1362
+ $handlesize = Health_Check_Debug_Data::recurse_dirsize( $path, $exclude, $max_execution_time );
1363
+ if ( $handlesize > 0 ) {
1364
+ $size += $handlesize;
1365
+ }
1366
+ }
1367
+
1368
+ if ( $max_execution_time > 0 && microtime( true ) - WP_START_TIMESTAMP > $max_execution_time ) {
1369
+ // Time exceeded. Give up instead of risking a fatal timeout.
1370
+ $size = null;
1371
+ break;
1372
+ }
1373
+ }
1374
+ }
1375
+ closedir( $handle );
1376
+ }
1377
+ return $size;
1378
+ }
1379
  }
includes/class-health-check-mail-check.php CHANGED
@@ -51,7 +51,8 @@ class Health_Check_Mail_Check {
51
  $wp_name,
52
  $wp_address,
53
  $date,
54
- $time
 
55
  );
56
 
57
  if ( ! empty( $email_message ) ) {
51
  $wp_name,
52
  $wp_address,
53
  $date,
54
+ $time,
55
+ $email_message
56
  );
57
 
58
  if ( ! empty( $email_message ) ) {
includes/class-health-check.php CHANGED
@@ -67,6 +67,7 @@ class Health_Check {
67
  add_action( 'wp_ajax_health-check-files-integrity-check', array( 'Health_Check_Files_Integrity', 'run_files_integrity_check' ) );
68
  add_action( 'wp_ajax_health-check-view-file-diff', array( 'Health_Check_Files_Integrity', 'view_file_diff' ) );
69
  add_action( 'wp_ajax_health-check-mail-check', array( 'Health_Check_Mail_Check', 'run_mail_check' ) );
 
70
 
71
  add_filter( 'health_check_tools_tab', array( 'Health_Check_Files_Integrity', 'tools_tab' ) );
72
  add_filter( 'health_check_tools_tab', array( 'Health_Check_Mail_Check', 'tools_tab' ) );
67
  add_action( 'wp_ajax_health-check-files-integrity-check', array( 'Health_Check_Files_Integrity', 'run_files_integrity_check' ) );
68
  add_action( 'wp_ajax_health-check-view-file-diff', array( 'Health_Check_Files_Integrity', 'view_file_diff' ) );
69
  add_action( 'wp_ajax_health-check-mail-check', array( 'Health_Check_Mail_Check', 'run_mail_check' ) );
70
+ add_action( 'wp_ajax_health-check-get-sizes', array( 'Health_Check_Debug_Data', 'ajax_get_sizes' ) );
71
 
72
  add_filter( 'health_check_tools_tab', array( 'Health_Check_Files_Integrity', 'tools_tab' ) );
73
  add_filter( 'health_check_tools_tab', array( 'Health_Check_Mail_Check', 'tools_tab' ) );
pages/debug-data.php CHANGED
@@ -113,7 +113,7 @@ foreach ( $info as $section => $details ) {
113
  <?php
114
  printf(
115
  '<a href="%s" class="button button-primary">%s</a>',
116
- esc_url( admin_url( '?page=health-check&tab=phpinfo' ) ),
117
  esc_html__( 'View extended PHP information', 'health-check' )
118
  );
119
  ?>
113
  <?php
114
  printf(
115
  '<a href="%s" class="button button-primary">%s</a>',
116
+ esc_url( admin_url( 'tools.php?page=health-check&tab=phpinfo' ) ),
117
  esc_html__( 'View extended PHP information', 'health-check' )
118
  );
119
  ?>
readme.txt CHANGED
@@ -2,8 +2,9 @@
2
  Tags: health check
3
  Contributors: wordpressdotorg, westi, pento, Clorith
4
  Requires at least: 4.0
 
5
  Tested up to: 5.2
6
- Stable tag: 1.3.1
7
  License: GPLv2
8
  License URI: https://www.gnu.org/licenses/gpl-2.0.html
9
 
@@ -11,6 +12,8 @@ Health Check identifies common problems, and helps you troubleshoot plugin and t
11
 
12
  == Description ==
13
 
 
 
14
  This plugin will perform a number of checks on your WordPress install to detect common configuration errors and known issues.
15
 
16
  It currently checks your PHP and MySQL versions, some extensions which are needed or may improve WordPress, and that the WordPress.org services are accessible to you.
@@ -35,10 +38,15 @@ Are you unfamiliar with how to clear your cookies? No worries, you may also clos
35
 
36
  1. The health check screen after the automated tests have gone over the system.
37
  2. The debug information, with the copy and paste field expanded.
38
- 3. The generic PHP information tab, when more detailed information is required.
 
39
 
40
  == Changelog ==
41
 
 
 
 
 
42
  = v1.3.1 =
43
  * Include missing dependency for JavaScript files, first introduced in WordPress 5.2
44
 
2
  Tags: health check
3
  Contributors: wordpressdotorg, westi, pento, Clorith
4
  Requires at least: 4.0
5
+ Requires PHP: 5.2
6
  Tested up to: 5.2
7
+ Stable tag: 1.3.2
8
  License: GPLv2
9
  License URI: https://www.gnu.org/licenses/gpl-2.0.html
10
 
12
 
13
  == Description ==
14
 
15
+ *The plugins menu position has changed, and can now be found under **Tools** > **Site Health**, where it replaces the Site Health feature included with WordPress 5.2*
16
+
17
  This plugin will perform a number of checks on your WordPress install to detect common configuration errors and known issues.
18
 
19
  It currently checks your PHP and MySQL versions, some extensions which are needed or may improve WordPress, and that the WordPress.org services are accessible to you.
38
 
39
  1. The health check screen after the automated tests have gone over the system.
40
  2. The debug information, with the copy and paste field expanded.
41
+ 3. A selection of tools that can be ran on your site.
42
+ 4. Troubleshooting mode enabled, showing your website Dashboard
43
 
44
  == Changelog ==
45
 
46
+ = v1.3.2 =
47
+ * Add polyfill for directory size calculations for sites running WordPress versions older than 5.2.0
48
+ * Fix link for the extended PHP information
49
+
50
  = v1.3.1 =
51
  * Include missing dependency for JavaScript files, first introduced in WordPress 5.2
52