Health Check - Version 1.5.0

Version Description

Download this release

Release Info

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

Code changes from version 1.4.5 to 1.5.0

Files changed (43) hide show
  1. includes/class-health-check-debug-data.php → HealthCheck/BackCompat/class-wp-debug-data.php +1237 -1473
  2. HealthCheck/BackCompat/class-wp-site-health.php +149 -0
  3. {includes/tools → HealthCheck/Tools}/class-health-check-files-integrity.php +0 -0
  4. {includes/tools → HealthCheck/Tools}/class-health-check-mail-check.php +2 -2
  5. HealthCheck/Tools/class-health-check-phpinfo.php +87 -0
  6. {includes/tools → HealthCheck/Tools}/class-health-check-plugin-compatibility.php +155 -131
  7. {includes/tools → HealthCheck/Tools}/class-health-check-tool.php +0 -0
  8. includes/class-health-check-wp-cli.php → HealthCheck/WP_CLI/class-status.php +13 -40
  9. HealthCheck/class-cli.php +50 -0
  10. {includes → HealthCheck}/class-health-check-loopback.php +0 -0
  11. {includes → HealthCheck}/class-health-check-troubleshoot.php +3 -3
  12. {includes → HealthCheck}/class-health-check.php +62 -223
  13. LICENSE +339 -0
  14. README.md +28 -0
  15. assets/css/health-check.css +0 -2
  16. assets/javascript/clipboard.min.js +0 -7
  17. assets/javascript/health-check.js +0 -8
  18. assets/javascript/troubleshooting-mode.js +0 -1
  19. build/health-check-tools.asset.php +1 -0
  20. build/health-check-tools.js +1 -0
  21. build/health-check.asset.php +1 -0
  22. build/health-check.css +1 -0
  23. build/health-check.js +1 -0
  24. build/troubleshooting-mode.asset.php +1 -0
  25. build/troubleshooting-mode.js +1 -0
  26. includes/compat.php → compat.php +84 -0
  27. health-check.php +36 -45
  28. includes/class-health-check-auto-updates.php +0 -453
  29. includes/class-health-check-dashboard-widget.php +0 -101
  30. includes/class-health-check-site-status.php +0 -2039
  31. includes/class-health-check-updates.php +0 -592
  32. includes/class-health-check-wp-cron.php +0 -143
  33. modals/js-result-warnings.php +0 -17
  34. {assets/mu-plugin → mu-plugin}/health-check-troubleshooting-mode.php +183 -99
  35. package.json +59 -0
  36. pages/debug-data.php +93 -90
  37. pages/phpinfo.php +5 -8
  38. pages/site-health-header.php +13 -17
  39. pages/site-status.php +21 -72
  40. pages/tools.php +46 -45
  41. pages/troubleshoot.php +24 -23
  42. readme.txt +107 -97
  43. uninstall.php +1 -1
includes/class-health-check-debug-data.php → HealthCheck/BackCompat/class-wp-debug-data.php RENAMED
@@ -1,1473 +1,1237 @@
1
- <?php
2
- /**
3
- * Class for providing debug data based on a users WordPress environment.
4
- *
5
- * @package Health Check
6
- */
7
-
8
- // Make sure the file is not directly accessible.
9
- if ( ! defined( 'ABSPATH' ) ) {
10
- die( 'We\'re sorry, but you can not directly access this file.' );
11
- }
12
-
13
- /**
14
- * Class Health_Check_Debug_Data
15
- */
16
- class Health_Check_Debug_Data {
17
-
18
- /**
19
- * Calls all core functions to check for updates
20
- *
21
- * @uses wp_version_check()
22
- * @uses wp_update_plugins()
23
- * @uses wp_update_themes()
24
- *
25
- * @return void
26
- */
27
- static function check_for_updates() {
28
-
29
- wp_version_check();
30
- wp_update_plugins();
31
- wp_update_themes();
32
-
33
- }
34
-
35
- /**
36
- * Static function for generating site debug data when required.
37
- *
38
- * @since 5.2.0
39
- *
40
- * @throws ImagickException
41
- * @global wpdb $wpdb WordPress database abstraction object.
42
- *
43
- * @return array The debug data for the site.
44
- */
45
- static function debug_data() {
46
- global $wpdb, $is_apache;
47
-
48
- // Save few function calls.
49
- $upload_dir = wp_get_upload_dir();
50
- $permalink_structure = get_option( 'permalink_structure' );
51
- $is_ssl = is_ssl();
52
- $users_can_register = get_option( 'users_can_register' );
53
- $default_comment_status = get_option( 'default_comment_status' );
54
- $is_multisite = is_multisite();
55
- $core_version = get_bloginfo( 'version' );
56
- $core_updates = get_core_updates();
57
- $core_update_needed = '';
58
-
59
- foreach ( $core_updates as $core => $update ) {
60
- if ( 'upgrade' === $update->response ) {
61
- // translators: %s: Latest WordPress version number.
62
- $core_update_needed = ' ' . sprintf( __( '(Latest version: %s)', 'health-check' ), $update->version );
63
- } else {
64
- $core_update_needed = '';
65
- }
66
- }
67
-
68
- // Set up the array that holds all debug information.
69
- $info = array();
70
-
71
- $info['wp-core'] = array(
72
- 'label' => __( 'WordPress', 'health-check' ),
73
- 'fields' => array(
74
- 'version' => array(
75
- 'label' => __( 'Version', 'health-check' ),
76
- 'value' => $core_version . $core_update_needed,
77
- 'debug' => $core_version,
78
- ),
79
- 'site_language' => array(
80
- 'label' => __( 'Site Language', 'health-check' ),
81
- 'value' => get_locale(),
82
- ),
83
- 'user_language' => array(
84
- 'label' => __( 'User Language', 'health-check' ),
85
- 'value' => get_user_locale(),
86
- ),
87
- 'home_url' => array(
88
- 'label' => __( 'Home URL', 'health-check' ),
89
- 'value' => get_bloginfo( 'url' ),
90
- 'private' => true,
91
- ),
92
- 'site_url' => array(
93
- 'label' => __( 'Site URL', 'health-check' ),
94
- 'value' => get_bloginfo( 'wpurl' ),
95
- 'private' => true,
96
- ),
97
- 'permalink' => array(
98
- 'label' => __( 'Permalink structure', 'health-check' ),
99
- 'value' => $permalink_structure ? $permalink_structure : __( 'No permalink structure set', 'health-check' ),
100
- 'debug' => $permalink_structure,
101
- ),
102
- 'https_status' => array(
103
- 'label' => __( 'Is this site using HTTPS?', 'health-check' ),
104
- 'value' => $is_ssl ? __( 'Yes', 'health-check' ) : __( 'No', 'health-check' ),
105
- 'debug' => $is_ssl,
106
- ),
107
- 'user_registration' => array(
108
- 'label' => __( 'Can anyone register on this site?', 'health-check' ),
109
- 'value' => $users_can_register ? __( 'Yes', 'health-check' ) : __( 'No', 'health-check' ),
110
- 'debug' => $users_can_register,
111
- ),
112
- 'default_comment_status' => array(
113
- 'label' => __( 'Default comment status', 'health-check' ),
114
- 'value' => 'open' === $default_comment_status ? _x( 'Open', 'comment status', 'health-check' ) : _x( 'Closed', 'comment status', 'health-check' ),
115
- 'debug' => $default_comment_status,
116
- ),
117
- 'multisite' => array(
118
- 'label' => __( 'Is this a multisite?', 'health-check' ),
119
- 'value' => $is_multisite ? __( 'Yes', 'health-check' ) : __( 'No', 'health-check' ),
120
- 'debug' => $is_multisite,
121
- ),
122
- ),
123
- );
124
-
125
- if ( ! $is_multisite ) {
126
- $info['wp-paths-sizes'] = array(
127
- 'label' => __( 'Directories and Sizes', 'health-check' ),
128
- 'fields' => array(),
129
- );
130
- }
131
-
132
- $info['wp-dropins'] = array(
133
- 'label' => __( 'Drop-ins', 'health-check' ),
134
- 'show_count' => true,
135
- 'description' => __( 'Drop-ins are single files that replace or enhance WordPress features in ways that are not possible for traditional plugins.', 'health-check' ),
136
- 'fields' => array(),
137
- );
138
-
139
- $info['wp-active-theme'] = array(
140
- 'label' => __( 'Active Theme', 'health-check' ),
141
- 'fields' => array(),
142
- );
143
-
144
- $info['wp-parent-theme'] = array(
145
- 'label' => __( 'Parent Theme', 'health-check' ),
146
- 'fields' => array(),
147
- );
148
-
149
- $info['wp-themes-inactive'] = array(
150
- 'label' => __( 'Inactive Themes', 'health-check' ),
151
- 'show_count' => true,
152
- 'fields' => array(),
153
- );
154
-
155
- $info['wp-mu-plugins'] = array(
156
- 'label' => __( 'Must Use Plugins', 'health-check' ),
157
- 'show_count' => true,
158
- 'fields' => array(),
159
- );
160
-
161
- $info['wp-plugins-active'] = array(
162
- 'label' => __( 'Active Plugins', 'health-check' ),
163
- 'show_count' => true,
164
- 'fields' => array(),
165
- );
166
-
167
- $info['wp-plugins-inactive'] = array(
168
- 'label' => __( 'Inactive Plugins', 'health-check' ),
169
- 'show_count' => true,
170
- 'fields' => array(),
171
- );
172
-
173
- $info['wp-media'] = array(
174
- 'label' => __( 'Media Handling', 'health-check' ),
175
- 'fields' => array(),
176
- );
177
-
178
- $info['wp-server'] = array(
179
- 'label' => __( 'Server', 'health-check' ),
180
- 'description' => __( 'The options shown below relate to your server setup. If changes are required, you may need your web host&#8217;s assistance.', 'health-check' ),
181
- 'fields' => array(),
182
- );
183
-
184
- $info['wp-database'] = array(
185
- 'label' => __( 'Database', 'health-check' ),
186
- 'fields' => array(),
187
- );
188
-
189
- // Check if WP_DEBUG_LOG is set.
190
- $wp_debug_log_value = __( 'Disabled', 'health-check' );
191
-
192
- if ( is_string( WP_DEBUG_LOG ) ) {
193
- $wp_debug_log_value = WP_DEBUG_LOG;
194
- } elseif ( WP_DEBUG_LOG ) {
195
- $wp_debug_log_value = __( 'Enabled', 'health-check' );
196
- }
197
-
198
- // Check CONCATENATE_SCRIPTS.
199
- if ( defined( 'CONCATENATE_SCRIPTS' ) ) {
200
- $concatenate_scripts = CONCATENATE_SCRIPTS ? __( 'Enabled', 'health-check' ) : __( 'Disabled', 'health-check' );
201
- $concatenate_scripts_debug = CONCATENATE_SCRIPTS ? 'true' : 'false';
202
- } else {
203
- $concatenate_scripts = __( 'Undefined', 'health-check' );
204
- $concatenate_scripts_debug = 'undefined';
205
- }
206
-
207
- // Check COMPRESS_SCRIPTS.
208
- if ( defined( 'COMPRESS_SCRIPTS' ) ) {
209
- $compress_scripts = COMPRESS_SCRIPTS ? __( 'Enabled', 'health-check' ) : __( 'Disabled', 'health-check' );
210
- $compress_scripts_debug = COMPRESS_SCRIPTS ? 'true' : 'false';
211
- } else {
212
- $compress_scripts = __( 'Undefined', 'health-check' );
213
- $compress_scripts_debug = 'undefined';
214
- }
215
-
216
- // Check COMPRESS_CSS.
217
- if ( defined( 'COMPRESS_CSS' ) ) {
218
- $compress_css = COMPRESS_CSS ? __( 'Enabled', 'health-check' ) : __( 'Disabled', 'health-check' );
219
- $compress_css_debug = COMPRESS_CSS ? 'true' : 'false';
220
- } else {
221
- $compress_css = __( 'Undefined', 'health-check' );
222
- $compress_css_debug = 'undefined';
223
- }
224
-
225
- // Check WP_LOCAL_DEV.
226
- if ( defined( 'WP_LOCAL_DEV' ) ) {
227
- $wp_local_dev = WP_LOCAL_DEV ? __( 'Enabled', 'health-check' ) : __( 'Disabled', 'health-check' );
228
- $wp_local_dev_debug = WP_LOCAL_DEV ? 'true' : 'false';
229
- } else {
230
- $wp_local_dev = __( 'Undefined', 'health-check' );
231
- $wp_local_dev_debug = 'undefined';
232
- }
233
-
234
- $info['wp-constants'] = array(
235
- 'label' => __( 'WordPress Constants', 'health-check' ),
236
- 'description' => __( 'These settings alter where and how parts of WordPress are loaded.', 'health-check' ),
237
- 'fields' => array(
238
- 'ABSPATH' => array(
239
- 'label' => 'ABSPATH',
240
- 'value' => ABSPATH,
241
- 'private' => true,
242
- ),
243
- 'WP_HOME' => array(
244
- 'label' => 'WP_HOME',
245
- 'value' => ( defined( 'WP_HOME' ) ? WP_HOME : __( 'Undefined', 'health-check' ) ),
246
- 'debug' => ( defined( 'WP_HOME' ) ? WP_HOME : 'undefined' ),
247
- ),
248
- 'WP_SITEURL' => array(
249
- 'label' => 'WP_SITEURL',
250
- 'value' => ( defined( 'WP_SITEURL' ) ? WP_SITEURL : __( 'Undefined', 'health-check' ) ),
251
- 'debug' => ( defined( 'WP_SITEURL' ) ? WP_SITEURL : 'undefined' ),
252
- ),
253
- 'WP_CONTENT_DIR' => array(
254
- 'label' => 'WP_CONTENT_DIR',
255
- 'value' => WP_CONTENT_DIR,
256
- ),
257
- 'WP_PLUGIN_DIR' => array(
258
- 'label' => 'WP_PLUGIN_DIR',
259
- 'value' => WP_PLUGIN_DIR,
260
- ),
261
- 'WP_MAX_MEMORY_LIMIT' => array(
262
- 'label' => 'WP_MAX_MEMORY_LIMIT',
263
- 'value' => WP_MAX_MEMORY_LIMIT,
264
- ),
265
- 'WP_DEBUG' => array(
266
- 'label' => 'WP_DEBUG',
267
- 'value' => WP_DEBUG ? __( 'Enabled', 'health-check' ) : __( 'Disabled', 'health-check' ),
268
- 'debug' => WP_DEBUG,
269
- ),
270
- 'WP_DEBUG_DISPLAY' => array(
271
- 'label' => 'WP_DEBUG_DISPLAY',
272
- 'value' => WP_DEBUG_DISPLAY ? __( 'Enabled', 'health-check' ) : __( 'Disabled', 'health-check' ),
273
- 'debug' => WP_DEBUG_DISPLAY,
274
- ),
275
- 'WP_DEBUG_LOG' => array(
276
- 'label' => 'WP_DEBUG_LOG',
277
- 'value' => $wp_debug_log_value,
278
- 'debug' => WP_DEBUG_LOG,
279
- ),
280
- 'SCRIPT_DEBUG' => array(
281
- 'label' => 'SCRIPT_DEBUG',
282
- 'value' => SCRIPT_DEBUG ? __( 'Enabled', 'health-check' ) : __( 'Disabled', 'health-check' ),
283
- 'debug' => SCRIPT_DEBUG,
284
- ),
285
- 'WP_CACHE' => array(
286
- 'label' => 'WP_CACHE',
287
- 'value' => WP_CACHE ? __( 'Enabled', 'health-check' ) : __( 'Disabled', 'health-check' ),
288
- 'debug' => WP_CACHE,
289
- ),
290
- 'CONCATENATE_SCRIPTS' => array(
291
- 'label' => 'CONCATENATE_SCRIPTS',
292
- 'value' => $concatenate_scripts,
293
- 'debug' => $concatenate_scripts_debug,
294
- ),
295
- 'COMPRESS_SCRIPTS' => array(
296
- 'label' => 'COMPRESS_SCRIPTS',
297
- 'value' => $compress_scripts,
298
- 'debug' => $compress_scripts_debug,
299
- ),
300
- 'COMPRESS_CSS' => array(
301
- 'label' => 'COMPRESS_CSS',
302
- 'value' => $compress_css,
303
- 'debug' => $compress_css_debug,
304
- ),
305
- 'WP_LOCAL_DEV' => array(
306
- 'label' => 'WP_LOCAL_DEV',
307
- 'value' => $wp_local_dev,
308
- 'debug' => $wp_local_dev_debug,
309
- ),
310
- ),
311
- );
312
-
313
- $is_writable_abspath = wp_is_writable( ABSPATH );
314
- $is_writable_wp_content_dir = wp_is_writable( WP_CONTENT_DIR );
315
- $is_writable_upload_dir = wp_is_writable( $upload_dir['basedir'] );
316
- $is_writable_wp_plugin_dir = wp_is_writable( WP_PLUGIN_DIR );
317
- $is_writable_template_directory = wp_is_writable( get_template_directory() . '/..' );
318
-
319
- $info['wp-filesystem'] = array(
320
- 'label' => __( 'Filesystem Permissions', 'health-check' ),
321
- 'description' => __( 'Shows whether WordPress is able to write to the directories it needs access to.', 'health-check' ),
322
- 'fields' => array(
323
- 'wordpress' => array(
324
- 'label' => __( 'The main WordPress directory', 'health-check' ),
325
- 'value' => ( $is_writable_abspath ? __( 'Writable', 'health-check' ) : __( 'Not writable', 'health-check' ) ),
326
- 'debug' => ( $is_writable_abspath ? 'writable' : 'not writable' ),
327
- ),
328
- 'wp-content' => array(
329
- 'label' => __( 'The wp-content directory', 'health-check' ),
330
- 'value' => ( $is_writable_wp_content_dir ? __( 'Writable', 'health-check' ) : __( 'Not writable', 'health-check' ) ),
331
- 'debug' => ( $is_writable_wp_content_dir ? 'writable' : 'not writable' ),
332
- ),
333
- 'uploads' => array(
334
- 'label' => __( 'The uploads directory', 'health-check' ),
335
- 'value' => ( $is_writable_upload_dir ? __( 'Writable', 'health-check' ) : __( 'Not writable', 'health-check' ) ),
336
- 'debug' => ( $is_writable_upload_dir ? 'writable' : 'not writable' ),
337
- ),
338
- 'plugins' => array(
339
- 'label' => __( 'The plugins directory', 'health-check' ),
340
- 'value' => ( $is_writable_wp_plugin_dir ? __( 'Writable', 'health-check' ) : __( 'Not writable', 'health-check' ) ),
341
- 'debug' => ( $is_writable_wp_plugin_dir ? 'writable' : 'not writable' ),
342
- ),
343
- 'themes' => array(
344
- 'label' => __( 'The themes directory', 'health-check' ),
345
- 'value' => ( $is_writable_template_directory ? __( 'Writable', 'health-check' ) : __( 'Not writable', 'health-check' ) ),
346
- 'debug' => ( $is_writable_template_directory ? 'writable' : 'not writable' ),
347
- ),
348
- ),
349
- );
350
-
351
- // Conditionally add debug information for multisite setups.
352
- if ( is_multisite() ) {
353
- $network_query = new WP_Network_Query();
354
- $network_ids = $network_query->query(
355
- array(
356
- 'fields' => 'ids',
357
- 'number' => 100,
358
- 'no_found_rows' => false,
359
- )
360
- );
361
-
362
- $site_count = 0;
363
- foreach ( $network_ids as $network_id ) {
364
- $site_count += get_blog_count( $network_id );
365
- }
366
-
367
- $info['wp-core']['fields']['user_count'] = array(
368
- 'label' => __( 'User count', 'health-check' ),
369
- 'value' => get_user_count(),
370
- );
371
-
372
- $info['wp-core']['fields']['site_count'] = array(
373
- 'label' => __( 'Site count', 'health-check' ),
374
- 'value' => $site_count,
375
- );
376
-
377
- $info['wp-core']['fields']['network_count'] = array(
378
- 'label' => __( 'Network count', 'health-check' ),
379
- 'value' => $network_query->found_networks,
380
- );
381
- } else {
382
- $user_count = count_users();
383
-
384
- $info['wp-core']['fields']['user_count'] = array(
385
- 'label' => __( 'User count', 'health-check' ),
386
- 'value' => $user_count['total_users'],
387
- );
388
- }
389
-
390
- // WordPress features requiring processing.
391
- $wp_dotorg = wp_remote_get( 'https://api.wordpress.org', array( 'timeout' => 10 ) );
392
-
393
- if ( ! is_wp_error( $wp_dotorg ) ) {
394
- $info['wp-core']['fields']['dotorg_communication'] = array(
395
- 'label' => __( 'Communication with WordPress.org', 'health-check' ),
396
- 'value' => __( 'WordPress.org is reachable', 'health-check' ),
397
- 'debug' => 'true',
398
- );
399
- } else {
400
- $info['wp-core']['fields']['dotorg_communication'] = array(
401
- 'label' => __( 'Communication with WordPress.org', 'health-check' ),
402
- 'value' => sprintf(
403
- // translators: 1: The IP address WordPress.org resolves to. 2: The error returned by the lookup.
404
- __( 'Unable to reach WordPress.org at %1$s: %2$s', 'health-check' ),
405
- gethostbyname( 'api.wordpress.org' ),
406
- $wp_dotorg->get_error_message()
407
- ),
408
- 'debug' => $wp_dotorg->get_error_message(),
409
- );
410
- }
411
-
412
- // Remove accordion for Directories and Sizes if in Multisite.
413
- if ( ! $is_multisite ) {
414
- $loading = __( 'Loading&hellip;', 'health-check' );
415
-
416
- $info['wp-paths-sizes']['fields'] = array(
417
- 'wordpress_path' => array(
418
- 'label' => __( 'WordPress directory location', 'health-check' ),
419
- 'value' => untrailingslashit( ABSPATH ),
420
- ),
421
- 'wordpress_size' => array(
422
- 'label' => __( 'WordPress directory size', 'health-check' ),
423
- 'value' => $loading,
424
- 'debug' => 'loading...',
425
- ),
426
- 'uploads_path' => array(
427
- 'label' => __( 'Uploads directory location', 'health-check' ),
428
- 'value' => $upload_dir['basedir'],
429
- ),
430
- 'uploads_size' => array(
431
- 'label' => __( 'Uploads directory size', 'health-check' ),
432
- 'value' => $loading,
433
- 'debug' => 'loading...',
434
- ),
435
- 'themes_path' => array(
436
- 'label' => __( 'Themes directory location', 'health-check' ),
437
- 'value' => get_theme_root(),
438
- ),
439
- 'themes_size' => array(
440
- 'label' => __( 'Themes directory size', 'health-check' ),
441
- 'value' => $loading,
442
- 'debug' => 'loading...',
443
- ),
444
- 'plugins_path' => array(
445
- 'label' => __( 'Plugins directory location', 'health-check' ),
446
- 'value' => WP_PLUGIN_DIR,
447
- ),
448
- 'plugins_size' => array(
449
- 'label' => __( 'Plugins directory size', 'health-check' ),
450
- 'value' => $loading,
451
- 'debug' => 'loading...',
452
- ),
453
- 'database_size' => array(
454
- 'label' => __( 'Database size', 'health-check' ),
455
- 'value' => $loading,
456
- 'debug' => 'loading...',
457
- ),
458
- 'total_size' => array(
459
- 'label' => __( 'Total installation size', 'health-check' ),
460
- 'value' => $loading,
461
- 'debug' => 'loading...',
462
- ),
463
- );
464
- }
465
-
466
- // Get a list of all drop-in replacements.
467
- $dropins = get_dropins();
468
-
469
- // Get dropins descriptions.
470
- $dropin_descriptions = _get_dropins();
471
-
472
- // Spare few function calls.
473
- $not_available = __( 'Not available', 'health-check' );
474
-
475
- foreach ( $dropins as $dropin_key => $dropin ) {
476
- $info['wp-dropins']['fields'][ sanitize_text_field( $dropin_key ) ] = array(
477
- 'label' => $dropin_key,
478
- 'value' => $dropin_descriptions[ $dropin_key ][0],
479
- 'debug' => 'true',
480
- );
481
- }
482
-
483
- // Populate the media fields.
484
- $info['wp-media']['fields']['image_editor'] = array(
485
- 'label' => __( 'Active editor', 'health-check' ),
486
- 'value' => _wp_image_editor_choose(),
487
- );
488
-
489
- // Get ImageMagic information, if available.
490
- if ( class_exists( 'Imagick' ) ) {
491
- // Save the Imagick instance for later use.
492
- $imagick = new Imagick();
493
- $imagick_version = $imagick->getVersion();
494
- } else {
495
- $imagick_version = __( 'Not available', 'health-check' );
496
- }
497
-
498
- $info['wp-media']['fields']['imagick_module_version'] = array(
499
- 'label' => __( 'ImageMagick version number', 'health-check' ),
500
- 'value' => ( is_array( $imagick_version ) ? $imagick_version['versionNumber'] : $imagick_version ),
501
- );
502
-
503
- $info['wp-media']['fields']['imagemagick_version'] = array(
504
- 'label' => __( 'ImageMagick version string', 'health-check' ),
505
- 'value' => ( is_array( $imagick_version ) ? $imagick_version['versionString'] : $imagick_version ),
506
- );
507
-
508
- // If Imagick is used as our editor, provide some more information about its limitations.
509
- if ( 'WP_Image_Editor_Imagick' === _wp_image_editor_choose() && isset( $imagick ) && $imagick instanceof Imagick ) {
510
- $limits = array(
511
- 'area' => ( defined( 'imagick::RESOURCETYPE_AREA' ) ? size_format( $imagick->getResourceLimit( imagick::RESOURCETYPE_AREA ) ) : $not_available ),
512
- 'disk' => ( defined( 'imagick::RESOURCETYPE_DISK' ) ? $imagick->getResourceLimit( imagick::RESOURCETYPE_DISK ) : $not_available ),
513
- 'file' => ( defined( 'imagick::RESOURCETYPE_FILE' ) ? $imagick->getResourceLimit( imagick::RESOURCETYPE_FILE ) : $not_available ),
514
- 'map' => ( defined( 'imagick::RESOURCETYPE_MAP' ) ? size_format( $imagick->getResourceLimit( imagick::RESOURCETYPE_MAP ) ) : $not_available ),
515
- 'memory' => ( defined( 'imagick::RESOURCETYPE_MEMORY' ) ? size_format( $imagick->getResourceLimit( imagick::RESOURCETYPE_MEMORY ) ) : $not_available ),
516
- 'thread' => ( defined( 'imagick::RESOURCETYPE_THREAD' ) ? $imagick->getResourceLimit( imagick::RESOURCETYPE_THREAD ) : $not_available ),
517
- );
518
-
519
- $limits_debug = array(
520
- 'imagick::RESOURCETYPE_AREA' => ( defined( 'imagick::RESOURCETYPE_AREA' ) ? size_format( $imagick->getResourceLimit( imagick::RESOURCETYPE_AREA ) ) : 'not available' ),
521
- 'imagick::RESOURCETYPE_DISK' => ( defined( 'imagick::RESOURCETYPE_DISK' ) ? $imagick->getResourceLimit( imagick::RESOURCETYPE_DISK ) : 'not available' ),
522
- 'imagick::RESOURCETYPE_FILE' => ( defined( 'imagick::RESOURCETYPE_FILE' ) ? $imagick->getResourceLimit( imagick::RESOURCETYPE_FILE ) : 'not available' ),
523
- 'imagick::RESOURCETYPE_MAP' => ( defined( 'imagick::RESOURCETYPE_MAP' ) ? size_format( $imagick->getResourceLimit( imagick::RESOURCETYPE_MAP ) ) : 'not available' ),
524
- 'imagick::RESOURCETYPE_MEMORY' => ( defined( 'imagick::RESOURCETYPE_MEMORY' ) ? size_format( $imagick->getResourceLimit( imagick::RESOURCETYPE_MEMORY ) ) : 'not available' ),
525
- 'imagick::RESOURCETYPE_THREAD' => ( defined( 'imagick::RESOURCETYPE_THREAD' ) ? $imagick->getResourceLimit( imagick::RESOURCETYPE_THREAD ) : 'not available' ),
526
- );
527
-
528
- $info['wp-media']['fields']['imagick_limits'] = array(
529
- 'label' => __( 'Imagick Resource Limits', 'health-check' ),
530
- 'value' => $limits,
531
- 'debug' => $limits_debug,
532
- );
533
- }
534
-
535
- // Get GD information, if available.
536
- if ( function_exists( 'gd_info' ) ) {
537
- $gd = gd_info();
538
- } else {
539
- $gd = false;
540
- }
541
-
542
- $info['wp-media']['fields']['gd_version'] = array(
543
- 'label' => __( 'GD version', 'health-check' ),
544
- 'value' => ( is_array( $gd ) ? $gd['GD Version'] : $not_available ),
545
- 'debug' => ( is_array( $gd ) ? $gd['GD Version'] : 'not available' ),
546
- );
547
-
548
- // Get Ghostscript information, if available.
549
- if ( function_exists( 'exec' ) ) {
550
- $gs = exec( 'gs --version' );
551
-
552
- if ( empty( $gs ) ) {
553
- $gs = $not_available;
554
- $gs_debug = 'not available';
555
- } else {
556
- $gs_debug = $gs;
557
- }
558
- } else {
559
- $gs = __( 'Unable to determine if Ghostscript is installed', 'health-check' );
560
- $gs_debug = 'unknown';
561
- }
562
-
563
- $info['wp-media']['fields']['ghostscript_version'] = array(
564
- 'label' => __( 'Ghostscript version', 'health-check' ),
565
- 'value' => $gs,
566
- 'debug' => $gs_debug,
567
- );
568
-
569
- // Populate the server debug fields.
570
- if ( function_exists( 'php_uname' ) ) {
571
- $server_architecture = sprintf( '%s %s %s', php_uname( 's' ), php_uname( 'r' ), php_uname( 'm' ) );
572
- } else {
573
- $server_architecture = 'unknown';
574
- }
575
-
576
- if ( function_exists( 'phpversion' ) ) {
577
- $php_version_debug = phpversion();
578
- // Whether PHP supports 64bit
579
- $php64bit = ( PHP_INT_SIZE * 8 === 64 );
580
-
581
- $php_version = sprintf(
582
- '%s %s',
583
- $php_version_debug,
584
- ( $php64bit ? __( '(Supports 64bit values)', 'health-check' ) : __( '(Does not support 64bit values)', 'health-check' ) )
585
- );
586
-
587
- if ( $php64bit ) {
588
- $php_version_debug .= ' 64bit';
589
- }
590
- } else {
591
- $php_version = __( 'Unable to determine PHP version', 'health-check' );
592
- $php_version_debug = 'unknown';
593
- }
594
-
595
- if ( function_exists( 'php_sapi_name' ) ) {
596
- $php_sapi = php_sapi_name();
597
- } else {
598
- $php_sapi = 'unknown';
599
- }
600
-
601
- if ( function_exists( 'get_current_user' ) && function_exists( 'getmyuid' ) ) {
602
- $php_getuid = sprintf(
603
- '%s (%s)',
604
- get_current_user(),
605
- getmyuid()
606
- );
607
- } else {
608
- $php_getuid = 'unknown';
609
- }
610
-
611
- $info['wp-server']['fields']['server_architecture'] = array(
612
- 'label' => __( 'Server architecture', 'health-check' ),
613
- 'value' => ( 'unknown' !== $server_architecture ? $server_architecture : __( 'Unable to determine server architecture', 'health-check' ) ),
614
- 'debug' => $server_architecture,
615
- );
616
- $info['wp-server']['fields']['php-uid'] = array(
617
- 'label' => __( 'Website server user', 'health-check' ),
618
- 'value' => ( 'unknown' !== $php_getuid ? $php_getuid : __( 'Unable to determine the websites server user', 'health-check' ) ),
619
- 'debug' => $php_getuid,
620
- 'private' => true,
621
- );
622
- $info['wp-server']['fields']['httpd_software'] = array(
623
- 'label' => __( 'Web server', 'health-check' ),
624
- 'value' => ( isset( $_SERVER['SERVER_SOFTWARE'] ) ? $_SERVER['SERVER_SOFTWARE'] : __( 'Unable to determine what web server software is used', 'health-check' ) ),
625
- 'debug' => ( isset( $_SERVER['SERVER_SOFTWARE'] ) ? $_SERVER['SERVER_SOFTWARE'] : 'unknown' ),
626
- );
627
- $info['wp-server']['fields']['php_version'] = array(
628
- 'label' => __( 'PHP version', 'health-check' ),
629
- 'value' => $php_version,
630
- 'debug' => $php_version_debug,
631
- );
632
- $info['wp-server']['fields']['php_sapi'] = array(
633
- 'label' => __( 'PHP SAPI', 'health-check' ),
634
- 'value' => ( 'unknown' !== $php_sapi ? $php_sapi : __( 'Unable to determine PHP SAPI', 'health-check' ) ),
635
- 'debug' => $php_sapi,
636
- );
637
-
638
- // Some servers disable `ini_set()` and `ini_get()`, we check this before trying to get configuration values.
639
- if ( ! function_exists( 'ini_get' ) ) {
640
- $info['wp-server']['fields']['ini_get'] = array(
641
- 'label' => __( 'Server settings', 'health-check' ),
642
- 'value' => __( 'Unable to determine some settings, as the ini_get() function has been disabled.', 'health-check' ),
643
- 'debug' => 'ini_get() is disabled',
644
- );
645
- } else {
646
- $info['wp-server']['fields']['max_input_variables'] = array(
647
- 'label' => __( 'PHP max input variables', 'health-check' ),
648
- 'value' => ini_get( 'max_input_vars' ),
649
- );
650
- $info['wp-server']['fields']['time_limit'] = array(
651
- 'label' => __( 'PHP time limit', 'health-check' ),
652
- 'value' => ini_get( 'max_execution_time' ),
653
- );
654
- $info['wp-server']['fields']['memory_limit'] = array(
655
- 'label' => __( 'PHP memory limit', 'health-check' ),
656
- 'value' => ini_get( 'memory_limit' ),
657
- );
658
- $info['wp-server']['fields']['max_input_time'] = array(
659
- 'label' => __( 'Max input time', 'health-check' ),
660
- 'value' => ini_get( 'max_input_time' ),
661
- );
662
- $info['wp-server']['fields']['upload_max_size'] = array(
663
- 'label' => __( 'Upload max filesize', 'health-check' ),
664
- 'value' => ini_get( 'upload_max_filesize' ),
665
- );
666
- $info['wp-server']['fields']['php_post_max_size'] = array(
667
- 'label' => __( 'PHP post max size', 'health-check' ),
668
- 'value' => ini_get( 'post_max_size' ),
669
- );
670
- }
671
-
672
- if ( function_exists( 'curl_version' ) ) {
673
- $curl = curl_version();
674
-
675
- $info['wp-server']['fields']['curl_version'] = array(
676
- 'label' => __( 'cURL version', 'health-check' ),
677
- 'value' => sprintf( '%s %s', $curl['version'], $curl['ssl_version'] ),
678
- );
679
- } else {
680
- $info['wp-server']['fields']['curl_version'] = array(
681
- 'label' => __( 'cURL version', 'health-check' ),
682
- 'value' => $not_available,
683
- 'debug' => 'not available',
684
- );
685
- }
686
-
687
- // SUHOSIN
688
- $suhosin_loaded = ( extension_loaded( 'suhosin' ) || ( defined( 'SUHOSIN_PATCH' ) && constant( 'SUHOSIN_PATCH' ) ) );
689
-
690
- $info['wp-server']['fields']['suhosin'] = array(
691
- 'label' => __( 'Is SUHOSIN installed?', 'health-check' ),
692
- 'value' => ( $suhosin_loaded ? __( 'Yes', 'health-check' ) : __( 'No', 'health-check' ) ),
693
- 'debug' => $suhosin_loaded,
694
- );
695
-
696
- // Imagick
697
- $imagick_loaded = extension_loaded( 'imagick' );
698
-
699
- $info['wp-server']['fields']['imagick_availability'] = array(
700
- 'label' => __( 'Is the Imagick library available?', 'health-check' ),
701
- 'value' => ( $imagick_loaded ? __( 'Yes', 'health-check' ) : __( 'No', 'health-check' ) ),
702
- 'debug' => $imagick_loaded,
703
- );
704
-
705
- $cookies = wp_unslash( $_COOKIE );
706
- $timeout = 10;
707
- $headers = array(
708
- 'Cache-Control' => 'no-cache',
709
- 'X-WP-Nonce' => wp_create_nonce( 'wp_rest' ),
710
- );
711
- if ( isset( $_SERVER['PHP_AUTH_USER'] ) && isset( $_SERVER['PHP_AUTH_PW'] ) ) {
712
- $headers['Authorization'] = 'Basic ' . base64_encode( wp_unslash( $_SERVER['PHP_AUTH_USER'] ) . ':' . wp_unslash( $_SERVER['PHP_AUTH_PW'] ) );
713
- }
714
-
715
- $server_request = wp_remote_get( site_url(), compact( 'cookies', 'headers', 'timeout' ) );
716
- if ( is_wp_error( $server_request ) ) {
717
- $info['wp-server']['fields']['server-headers'] = array(
718
- 'label' => __( 'Server headers', 'health-check' ),
719
- 'value' => __( 'Could not retrieve server headers', 'health-check' ),
720
- 'debug' => 'unknown',
721
- );
722
- } else {
723
- $server_headers = wp_remote_retrieve_headers( $server_request );
724
-
725
- $info['wp-server']['fields']['server-headers'] = array(
726
- 'label' => __( 'Server headers', 'health-check' ),
727
- 'value' => ( $server_headers instanceof \Requests_Utility_CaseInsensitiveDictionary ? $server_headers->getAll() : $server_headers ),
728
- 'debug' => ( $server_headers instanceof \Requests_Utility_CaseInsensitiveDictionary ? $server_headers->getAll() : $server_headers ),
729
- );
730
- }
731
-
732
- // Check if a .htaccess file exists.
733
- if ( $is_apache && is_file( ABSPATH . '.htaccess' ) ) {
734
- // If the file exists, grab the content of it.
735
- $htaccess_content = file_get_contents( ABSPATH . '.htaccess' );
736
-
737
- // Filter away the core WordPress rules.
738
- $filtered_htaccess_content = trim( preg_replace( '/\# BEGIN WordPress[\s\S]+?# END WordPress/si', '', $htaccess_content ) );
739
- $filtered_htaccess_content = ! empty( $filtered_htaccess_content );
740
-
741
- $info['wp-server']['fields']['htaccess_extra_rules'] = array(
742
- 'label' => __( '.htaccess rules', 'health-check' ),
743
- 'value' => ( $filtered_htaccess_content ? __( 'Custom rules have been added to your .htaccess file.', 'health-check' ) : __( 'Your .htaccess file contains only core WordPress features.', 'health-check' ) ),
744
- 'debug' => $filtered_htaccess_content,
745
- );
746
- }
747
-
748
- // Populate the database debug fields.
749
- if ( is_resource( $wpdb->dbh ) ) {
750
- // Old mysql extension.
751
- $extension = 'mysql';
752
- } elseif ( is_object( $wpdb->dbh ) ) {
753
- // mysqli or PDO.
754
- $extension = get_class( $wpdb->dbh );
755
- } else {
756
- // Unknown sql extension.
757
- $extension = null;
758
- }
759
-
760
- $server = $wpdb->get_var( 'SELECT VERSION()' );
761
-
762
- if ( isset( $wpdb->use_mysqli ) && $wpdb->use_mysqli ) {
763
- $client_version = $wpdb->dbh->client_info;
764
- } else {
765
- // phpcs:ignore WordPress.DB.RestrictedFunctions.mysql_mysql_get_client_info
766
- if ( preg_match( '|[0-9]{1,2}\.[0-9]{1,2}\.[0-9]{1,2}|', mysql_get_client_info(), $matches ) ) {
767
- $client_version = $matches[0];
768
- } else {
769
- $client_version = null;
770
- }
771
- }
772
-
773
- $info['wp-database']['fields']['extension'] = array(
774
- 'label' => __( 'Extension', 'health-check' ),
775
- 'value' => $extension,
776
- );
777
-
778
- $info['wp-database']['fields']['server_version'] = array(
779
- 'label' => __( 'Server version', 'health-check' ),
780
- 'value' => $server,
781
- );
782
-
783
- $info['wp-database']['fields']['client_version'] = array(
784
- 'label' => __( 'Client version', 'health-check' ),
785
- 'value' => $client_version,
786
- );
787
-
788
- $info['wp-database']['fields']['database_user'] = array(
789
- 'label' => __( 'Database user', 'health-check' ),
790
- 'value' => $wpdb->dbuser,
791
- 'private' => true,
792
- );
793
-
794
- $info['wp-database']['fields']['database_host'] = array(
795
- 'label' => __( 'Database host', 'health-check' ),
796
- 'value' => $wpdb->dbhost,
797
- 'private' => true,
798
- );
799
-
800
- $info['wp-database']['fields']['database_name'] = array(
801
- 'label' => __( 'Database name', 'health-check' ),
802
- 'value' => $wpdb->dbname,
803
- 'private' => true,
804
- );
805
-
806
- $info['wp-database']['fields']['database_prefix'] = array(
807
- 'label' => __( 'Database prefix', 'health-check' ),
808
- 'value' => $wpdb->prefix,
809
- 'private' => true,
810
- );
811
-
812
- // List must use plugins if there are any.
813
- $mu_plugins = get_mu_plugins();
814
-
815
- foreach ( $mu_plugins as $plugin_path => $plugin ) {
816
- $plugin_version = $plugin['Version'];
817
- $plugin_author = $plugin['Author'];
818
-
819
- $plugin_version_string = __( 'No version or author information is available.', 'health-check' );
820
- $plugin_version_string_debug = 'author: (undefined), version: (undefined)';
821
-
822
- if ( ! empty( $plugin_version ) && ! empty( $plugin_author ) ) {
823
- // translators: 1: Plugin version number. 2: Plugin author name.
824
- $plugin_version_string = sprintf( __( 'Version %1$s by %2$s', 'health-check' ), $plugin_version, $plugin_author );
825
- $plugin_version_string_debug = sprintf( 'version: %s, author: %s', $plugin_version, $plugin_author );
826
- } else {
827
- if ( ! empty( $plugin_author ) ) {
828
- // translators: %s: Plugin author name.
829
- $plugin_version_string = sprintf( __( 'By %s', 'health-check' ), $plugin_author );
830
- $plugin_version_string_debug = sprintf( 'author: %s, version: (undefined)', $plugin_author );
831
- }
832
-
833
- if ( ! empty( $plugin_version ) ) {
834
- // translators: %s: Plugin version number.
835
- $plugin_version_string = sprintf( __( 'Version %s', 'health-check' ), $plugin_version );
836
- $plugin_version_string_debug = sprintf( 'author: (undefined), version: %s', $plugin_version );
837
- }
838
- }
839
-
840
- $info['wp-mu-plugins']['fields'][ sanitize_text_field( $plugin['Name'] ) ] = array(
841
- 'label' => $plugin['Name'],
842
- 'value' => $plugin_version_string,
843
- 'debug' => $plugin_version_string_debug,
844
- );
845
- }
846
-
847
- // List all available plugins.
848
- $plugins = get_plugins();
849
- $plugin_updates = get_plugin_updates();
850
-
851
- foreach ( $plugins as $plugin_path => $plugin ) {
852
- $plugin_part = ( is_plugin_active( $plugin_path ) ) ? 'wp-plugins-active' : 'wp-plugins-inactive';
853
-
854
- $plugin_version = $plugin['Version'];
855
- $plugin_author = $plugin['Author'];
856
-
857
- $plugin_version_string = __( 'No version or author information is available.', 'health-check' );
858
- $plugin_version_string_debug = 'author: (undefined), version: (undefined)';
859
-
860
- if ( ! empty( $plugin_version ) && ! empty( $plugin_author ) ) {
861
- // translators: 1: Plugin version number. 2: Plugin author name.
862
- $plugin_version_string = sprintf( __( 'Version %1$s by %2$s', 'health-check' ), $plugin_version, $plugin_author );
863
- $plugin_version_string_debug = sprintf( 'version: %s, author: %s', $plugin_version, $plugin_author );
864
- } else {
865
- if ( ! empty( $plugin_author ) ) {
866
- // translators: %s: Plugin author name.
867
- $plugin_version_string = sprintf( __( 'By %s', 'health-check' ), $plugin_author );
868
- $plugin_version_string_debug = sprintf( 'author: %s, version: (undefined)', $plugin_author );
869
- }
870
-
871
- if ( ! empty( $plugin_version ) ) {
872
- // translators: %s: Plugin version number.
873
- $plugin_version_string = sprintf( __( 'Version %s', 'health-check' ), $plugin_version );
874
- $plugin_version_string_debug = sprintf( 'author: (undefined), version: %s', $plugin_version );
875
- }
876
- }
877
-
878
- if ( array_key_exists( $plugin_path, $plugin_updates ) ) {
879
- // translators: %s: Latest plugin version number.
880
- $plugin_version_string .= ' ' . sprintf( __( '(Latest version: %s)', 'health-check' ), $plugin_updates[ $plugin_path ]->update->new_version );
881
- $plugin_version_string_debug .= sprintf( ' (latest version: %s)', $plugin_updates[ $plugin_path ]->update->new_version );
882
- }
883
-
884
- $info[ $plugin_part ]['fields'][ sanitize_text_field( $plugin['Name'] ) ] = array(
885
- 'label' => $plugin['Name'],
886
- 'value' => $plugin_version_string,
887
- 'debug' => $plugin_version_string_debug,
888
- );
889
- }
890
-
891
- // Populate the section for the currently active theme.
892
- global $_wp_theme_features;
893
- $theme_features = array();
894
-
895
- if ( ! empty( $_wp_theme_features ) ) {
896
- foreach ( $_wp_theme_features as $feature => $options ) {
897
- $theme_features[] = $feature;
898
- }
899
- }
900
-
901
- $active_theme = wp_get_theme();
902
- $theme_updates = get_theme_updates();
903
-
904
- // phpcs:ignore WordPress.NamingConventions.ValidVariableName.UsedPropertyNotSnakeCase
905
- $active_theme_version = $active_theme->Version;
906
- $active_theme_version_debug = $active_theme_version;
907
-
908
- if ( array_key_exists( $active_theme->stylesheet, $theme_updates ) ) {
909
- $theme_update_new_version = $theme_updates[ $active_theme->stylesheet ]->update['new_version'];
910
-
911
- // translators: %s: Latest theme version number.
912
- $active_theme_version .= ' ' . sprintf( __( '(Latest version: %s)', 'health-check' ), $theme_update_new_version );
913
- $active_theme_version_debug .= sprintf( ' (latest version: %s)', $theme_update_new_version );
914
- }
915
-
916
- $active_theme_author_uri = $active_theme->offsetGet( 'Author URI' );
917
-
918
- $info['wp-active-theme']['fields'] = array(
919
- 'name' => array(
920
- 'label' => __( 'Name', 'health-check' ),
921
- 'value' => sprintf(
922
- // translators: 1: Parent theme name. 2: Parent theme slug.
923
- __( '%1$s (%2$s)', 'health-check' ),
924
- // phpcs:ignore WordPress.NamingConventions.ValidVariableName.UsedPropertyNotSnakeCase
925
- $active_theme->Name,
926
- $active_theme->stylesheet
927
- ),
928
- ),
929
- 'version' => array(
930
- 'label' => __( 'Version', 'health-check' ),
931
- 'value' => $active_theme_version,
932
- 'debug' => $active_theme_version_debug,
933
- ),
934
- 'author' => array(
935
- 'label' => __( 'Author', 'health-check' ),
936
- // phpcs:ignore WordPress.NamingConventions.ValidVariableName.UsedPropertyNotSnakeCase
937
- 'value' => wp_kses( $active_theme->Author, array() ),
938
- ),
939
- 'author_website' => array(
940
- 'label' => __( 'Author website', 'health-check' ),
941
- 'value' => ( $active_theme_author_uri ? $active_theme_author_uri : __( 'Undefined', 'health-check' ) ),
942
- 'debug' => ( $active_theme_author_uri ? $active_theme_author_uri : '(undefined)' ),
943
- ),
944
- 'parent_theme' => array(
945
- 'label' => __( 'Parent theme', 'health-check' ),
946
- 'value' => ( $active_theme->parent_theme ? $active_theme->parent_theme . ' (' . $active_theme->template . ')' : __( 'None', 'health-check' ) ),
947
- 'debug' => ( $active_theme->parent_theme ? $active_theme->parent_theme . ' (' . $active_theme->template . ')' : 'none' ),
948
- ),
949
- 'theme_features' => array(
950
- 'label' => __( 'Theme features', 'health-check' ),
951
- 'value' => implode( ', ', $theme_features ),
952
- ),
953
- 'theme_path' => array(
954
- 'label' => __( 'Theme directory location', 'health-check' ),
955
- 'value' => get_stylesheet_directory(),
956
- ),
957
- );
958
-
959
- $parent_theme = $active_theme->parent();
960
-
961
- if ( $parent_theme ) {
962
- // phpcs:ignore WordPress.NamingConventions.ValidVariableName.UsedPropertyNotSnakeCase
963
- $parent_theme_version = $parent_theme->Version;
964
- $parent_theme_version_debug = $parent_theme_version;
965
-
966
- if ( array_key_exists( $parent_theme->stylesheet, $theme_updates ) ) {
967
- $parent_theme_update_new_version = $theme_updates[ $parent_theme->stylesheet ]->update['new_version'];
968
-
969
- // translators: %s: Latest theme version number.
970
- $parent_theme_version .= ' ' . sprintf( __( '(Latest version: %s)', 'health-check' ), $parent_theme_update_new_version );
971
- $parent_theme_version_debug .= sprintf( ' (latest version: %s)', $parent_theme_update_new_version );
972
- }
973
-
974
- $parent_theme_author_uri = $parent_theme->offsetGet( 'Author URI' );
975
-
976
- $info['wp-parent-theme']['fields'] = array(
977
- 'name' => array(
978
- 'label' => __( 'Name', 'health-check' ),
979
- 'value' => sprintf(
980
- // translators: 1: Parent theme name. 2: Parent theme slug.
981
- __( '%1$s (%2$s)', 'health-check' ),
982
- // phpcs:ignore WordPress.NamingConventions.ValidVariableName.UsedPropertyNotSnakeCase
983
- $parent_theme->Name,
984
- $parent_theme->stylesheet
985
- ),
986
- ),
987
- 'version' => array(
988
- 'label' => __( 'Version', 'health-check' ),
989
- 'value' => $parent_theme_version,
990
- 'debug' => $parent_theme_version_debug,
991
- ),
992
- 'author' => array(
993
- 'label' => __( 'Author', 'health-check' ),
994
- // phpcs:ignore WordPress.NamingConventions.ValidVariableName.UsedPropertyNotSnakeCase
995
- 'value' => wp_kses( $parent_theme->Author, array() ),
996
- ),
997
- 'author_website' => array(
998
- 'label' => __( 'Author website', 'health-check' ),
999
- 'value' => ( $parent_theme_author_uri ? $parent_theme_author_uri : __( 'Undefined', 'health-check' ) ),
1000
- 'debug' => ( $parent_theme_author_uri ? $parent_theme_author_uri : '(undefined)' ),
1001
- ),
1002
- 'theme_path' => array(
1003
- 'label' => __( 'Theme directory location', 'health-check' ),
1004
- 'value' => get_template_directory(),
1005
- ),
1006
- );
1007
- }
1008
-
1009
- // Populate a list of all themes available in the install.
1010
- $all_themes = wp_get_themes();
1011
-
1012
- foreach ( $all_themes as $theme_slug => $theme ) {
1013
- // Ignore the currently active theme from the list of all themes.
1014
- if ( $active_theme->stylesheet === $theme_slug ) {
1015
- continue;
1016
- }
1017
-
1018
- // Ignore the currently active parent theme from the list of all themes.
1019
- if ( ! empty( $parent_theme ) && $parent_theme->stylesheet === $theme_slug ) {
1020
- continue;
1021
- }
1022
-
1023
- // phpcs:ignore WordPress.NamingConventions.ValidVariableName.UsedPropertyNotSnakeCase
1024
- $theme_version = $theme->Version;
1025
- // phpcs:ignore WordPress.NamingConventions.ValidVariableName.UsedPropertyNotSnakeCase
1026
- $theme_author = $theme->Author;
1027
-
1028
- // Sanitize
1029
- $theme_author = wp_kses( $theme_author, array() );
1030
-
1031
- $theme_version_string = __( 'No version or author information is available.', 'health-check' );
1032
- $theme_version_string_debug = 'undefined';
1033
-
1034
- if ( ! empty( $theme_version ) && ! empty( $theme_author ) ) {
1035
- // translators: 1: Theme version number. 2: Theme author name.
1036
- $theme_version_string = sprintf( __( 'Version %1$s by %2$s', 'health-check' ), $theme_version, $theme_author );
1037
- $theme_version_string_debug = sprintf( 'version: %s, author: %s', $theme_version, $theme_author );
1038
- } else {
1039
- if ( ! empty( $theme_author ) ) {
1040
- // translators: %s: Theme author name.
1041
- $theme_version_string = sprintf( __( 'By %s', 'health-check' ), $theme_author );
1042
- $theme_version_string_debug = sprintf( 'author: %s, version: (undefined)', $theme_author );
1043
- }
1044
-
1045
- if ( ! empty( $theme_version ) ) {
1046
- // translators: %s: Theme version number.
1047
- $theme_version_string = sprintf( __( 'Version %s', 'health-check' ), $theme_version );
1048
- $theme_version_string_debug = sprintf( 'author: (undefined), version: %s', $theme_version );
1049
- }
1050
- }
1051
-
1052
- if ( array_key_exists( $theme_slug, $theme_updates ) ) {
1053
- // translators: %s: Latest theme version number.
1054
- $theme_version_string .= ' ' . sprintf( __( '(Latest version: %s)', 'health-check' ), $theme_updates[ $theme_slug ]->update['new_version'] );
1055
- $theme_version_string_debug .= sprintf( ' (latest version: %s)', $theme_updates[ $theme_slug ]->update['new_version'] );
1056
- }
1057
-
1058
- // phpcs:ignore WordPress.NamingConventions.ValidVariableName.UsedPropertyNotSnakeCase
1059
- $info['wp-themes-inactive']['fields'][ sanitize_text_field( $theme->Name ) ] = array(
1060
- 'label' => sprintf(
1061
- // translators: 1: Theme name. 2: Theme slug.
1062
- __( '%1$s (%2$s)', 'health-check' ),
1063
- // phpcs:ignore WordPress.NamingConventions.ValidVariableName.UsedPropertyNotSnakeCase
1064
- $theme->Name,
1065
- $theme_slug
1066
- ),
1067
- 'value' => $theme_version_string,
1068
- 'debug' => $theme_version_string_debug,
1069
- );
1070
- }
1071
-
1072
- // Add more filesystem checks
1073
- if ( defined( 'WPMU_PLUGIN_DIR' ) && is_dir( WPMU_PLUGIN_DIR ) ) {
1074
- $is_writable_wpmu_plugin_dir = wp_is_writable( WPMU_PLUGIN_DIR );
1075
-
1076
- $info['wp-filesystem']['fields']['mu-plugins'] = array(
1077
- 'label' => __( 'The must use plugins directory', 'health-check' ),
1078
- 'value' => ( $is_writable_wpmu_plugin_dir ? __( 'Writable', 'health-check' ) : __( 'Not writable', 'health-check' ) ),
1079
- 'debug' => ( $is_writable_wpmu_plugin_dir ? 'writable' : 'not writable' ),
1080
- );
1081
- }
1082
-
1083
- /**
1084
- * Add or modify the debug information.
1085
- *
1086
- * Plugin or themes may wish to introduce their own debug information without creating additional admin pages
1087
- * they can utilize this filter to introduce their own sections or add more data to existing sections.
1088
- *
1089
- * Array keys for sections added by core are all prefixed with `wp-`, plugins and themes should use their own slug as
1090
- * a prefix, both for consistency as well as avoiding key collisions. Note that the array keys are used as labels
1091
- * for the copied data.
1092
- *
1093
- * All strings are expected to be plain text except $description that can contain inline HTML tags (see below).
1094
- *
1095
- * @since 5.2.0
1096
- *
1097
- * @param array $args {
1098
- * The debug information to be added to the core information page.
1099
- *
1100
- * This is an associative multi-dimensional array, up to three levels deep. The topmost array holds the sections.
1101
- * Each section has a `$fields` associative array (see below), and each `$value` in `$fields` can be
1102
- * another associative array of name/value pairs when there is more structured data to display.
1103
- *
1104
- * @type string $label The title for this section of the debug output.
1105
- * @type string $description Optional. A description for your information section which may contain basic HTML
1106
- * markup, inline tags only as it is outputted in a paragraph.
1107
- * @type boolean $show_count Optional. If set to `true` the amount of fields will be included in the title for
1108
- * this section.
1109
- * @type boolean $private Optional. If set to `true` the section and all associated fields will be excluded
1110
- * from the copied data.
1111
- * @type array $fields {
1112
- * An associative array containing the data to be displayed.
1113
- *
1114
- * @type string $label The label for this piece of information.
1115
- * @type string $value The output that is displayed for this field. Text should be translated. Can be
1116
- * an associative array that is displayed as name/value pairs.
1117
- * @type string $debug Optional. The output that is used for this field when the user copies the data.
1118
- * It should be more concise and not translated. If not set, the content of `$value` is used.
1119
- * Note that the array keys are used as labels for the copied data.
1120
- * @type boolean $private Optional. If set to `true` the field will not be included in the copied data
1121
- * allowing you to show, for example, API keys here.
1122
- * }
1123
- * }
1124
- */
1125
- $info = apply_filters( 'debug_information', $info );
1126
-
1127
- return $info;
1128
- }
1129
-
1130
- /**
1131
- * Format the information gathered for debugging, in a manner suitable for copying to a forum or support ticket.
1132
- *
1133
- * @since 5.2.0
1134
- *
1135
- * @param array $info_array Information gathered from the `WP_Debug_Data::debug_data` function.
1136
- * @param string $type The data type to return, either 'info' or 'debug'.
1137
- * @return string The formatted data.
1138
- */
1139
- public static function format( $info_array, $type ) {
1140
- $return = "`\n";
1141
-
1142
- foreach ( $info_array as $section => $details ) {
1143
- // Skip this section if there are no fields, or the section has been declared as private.
1144
- if ( empty( $details['fields'] ) || ( isset( $details['private'] ) && $details['private'] ) ) {
1145
- continue;
1146
- }
1147
-
1148
- $section_label = 'debug' === $type ? $section : $details['label'];
1149
-
1150
- $return .= sprintf(
1151
- "### %s%s ###\n\n",
1152
- $section_label,
1153
- ( isset( $details['show_count'] ) && $details['show_count'] ? sprintf( ' (%d)', count( $details['fields'] ) ) : '' )
1154
- );
1155
-
1156
- foreach ( $details['fields'] as $field_name => $field ) {
1157
- if ( isset( $field['private'] ) && true === $field['private'] ) {
1158
- continue;
1159
- }
1160
-
1161
- if ( 'debug' === $type && isset( $field['debug'] ) ) {
1162
- $debug_data = $field['debug'];
1163
- } else {
1164
- $debug_data = $field['value'];
1165
- }
1166
-
1167
- // Can be array, one level deep only.
1168
- if ( is_array( $debug_data ) ) {
1169
- $value = '';
1170
-
1171
- foreach ( $debug_data as $sub_field_name => $sub_field_value ) {
1172
- $value .= sprintf( "\n\t%s: %s", $sub_field_name, $sub_field_value );
1173
- }
1174
- } elseif ( is_bool( $debug_data ) ) {
1175
- $value = $debug_data ? 'true' : 'false';
1176
- } elseif ( empty( $debug_data ) && '0' !== $debug_data ) {
1177
- $value = 'undefined';
1178
- } else {
1179
- $value = $debug_data;
1180
- }
1181
-
1182
- if ( 'debug' === $type ) {
1183
- $label = $field_name;
1184
- } else {
1185
- $label = $field['label'];
1186
- }
1187
-
1188
- $return .= sprintf( "%s: %s\n", $label, $value );
1189
- }
1190
-
1191
- $return .= "\n";
1192
- }
1193
-
1194
- $return .= '`';
1195
-
1196
- return $return;
1197
- }
1198
-
1199
- /**
1200
- * Fetch the total size of all the database tables for the active database user.
1201
- *
1202
- * @since 5.2.0
1203
- *
1204
- * @return int The size of the database, in bytes.
1205
- */
1206
- public static function get_database_size() {
1207
- global $wpdb;
1208
- $size = 0;
1209
- $rows = $wpdb->get_results( 'SHOW TABLE STATUS', ARRAY_A );
1210
-
1211
- if ( $wpdb->num_rows > 0 ) {
1212
- foreach ( $rows as $row ) {
1213
- $size += $row['Data_length'] + $row['Index_length'];
1214
- }
1215
- }
1216
-
1217
- return (int) $size;
1218
- }
1219
-
1220
- public static function ajax_get_sizes() {
1221
- check_ajax_referer( 'health-check-site-status-result' );
1222
-
1223
- if ( ! current_user_can( 'view_site_health_checks' ) || is_multisite() ) {
1224
- wp_send_json_error();
1225
- }
1226
-
1227
- $sizes_data = Health_Check_Debug_Data::get_sizes();
1228
- $all_sizes = array( 'raw' => 0 );
1229
-
1230
- foreach ( $sizes_data as $name => $value ) {
1231
- $name = sanitize_text_field( $name );
1232
- $data = array();
1233
-
1234
- if ( isset( $value['size'] ) ) {
1235
- if ( is_string( $value['size'] ) ) {
1236
- $data['size'] = sanitize_text_field( $value['size'] );
1237
- } else {
1238
- $data['size'] = (int) $value['size'];
1239
- }
1240
- }
1241
-
1242
- if ( isset( $value['debug'] ) ) {
1243
- if ( is_string( $value['debug'] ) ) {
1244
- $data['debug'] = sanitize_text_field( $value['debug'] );
1245
- } else {
1246
- $data['debug'] = (int) $value['debug'];
1247
- }
1248
- }
1249
-
1250
- if ( ! empty( $value['raw'] ) ) {
1251
- $data['raw'] = (int) $value['raw'];
1252
- }
1253
-
1254
- $all_sizes[ $name ] = $data;
1255
- }
1256
-
1257
- if ( isset( $all_sizes['total_size']['debug'] ) && 'not available' === $all_sizes['total_size']['debug'] ) {
1258
- wp_send_json_error( $all_sizes );
1259
- }
1260
-
1261
- wp_send_json_success( $all_sizes );
1262
- }
1263
-
1264
- /**
1265
- * Fetch the sizes of the WordPress directories: `wordpress` (ABSPATH), `plugins`, `themes`, and `uploads`.
1266
- * Intended to supplement the array returned by `WP_Debug_Data::debug_data()`.
1267
- *
1268
- * @since 5.2.0
1269
- *
1270
- * @return array The sizes of the directories, also the database size and total installation size.
1271
- */
1272
- public static function get_sizes() {
1273
- $size_db = self::get_database_size();
1274
- $upload_dir = wp_get_upload_dir();
1275
-
1276
- /*
1277
- * We will be using the PHP max execution time to prevent the size calculations
1278
- * from causing a timeout. The default value is 30 seconds, and some
1279
- * hosts do not allow you to read configuration values.
1280
- */
1281
- if ( function_exists( 'ini_get' ) ) {
1282
- $max_execution_time = ini_get( 'max_execution_time' );
1283
- }
1284
-
1285
- // The max_execution_time defaults to 0 when PHP runs from cli.
1286
- // We still want to limit it below.
1287
- if ( empty( $max_execution_time ) ) {
1288
- $max_execution_time = 30;
1289
- }
1290
-
1291
- if ( $max_execution_time > 20 ) {
1292
- // If the max_execution_time is set to lower than 20 seconds, reduce it a bit to prevent
1293
- // edge-case timeouts that may happen after the size loop has finished running.
1294
- $max_execution_time -= 2;
1295
- }
1296
-
1297
- if ( ! defined( 'WP_START_TIMESTAMP' ) ) {
1298
- global $timestart;
1299
- if ( version_compare( phpversion(), '5.4.0', '>=' ) && isset( $_SERVER['REQUEST_TIME_FLOAT'] ) ) {
1300
- define( 'WP_START_TIMESTAMP', $_SERVER['REQUEST_TIME_FLOAT'] );
1301
- } else {
1302
- define( 'WP_START_TIMESTAMP', $timestart );
1303
- }
1304
- }
1305
-
1306
- // Go through the various installation directories and calculate their sizes.
1307
- // No trailing slashes.
1308
- $paths = array(
1309
- 'wordpress_size' => untrailingslashit( ABSPATH ),
1310
- 'themes_size' => get_theme_root(),
1311
- 'plugins_size' => WP_PLUGIN_DIR,
1312
- 'uploads_size' => $upload_dir['basedir'],
1313
- );
1314
-
1315
- $exclude = $paths;
1316
- unset( $exclude['wordpress_size'] );
1317
- $exclude = array_values( $exclude );
1318
-
1319
- $size_total = 0;
1320
- $all_sizes = array();
1321
-
1322
- // Loop over all the directories we want to gather the sizes for.
1323
- foreach ( $paths as $name => $path ) {
1324
- $dir_size = null; // Default to timeout.
1325
- $results = array(
1326
- 'path' => $path,
1327
- 'raw' => 0,
1328
- );
1329
-
1330
- if ( microtime( true ) - WP_START_TIMESTAMP < $max_execution_time ) {
1331
- if ( 'wordpress_size' === $name ) {
1332
- if ( version_compare( get_bloginfo( 'version' ), '5.2.0', '<' ) ) {
1333
- $dir_size = Health_Check_Debug_Data::recurse_dirsize( $path, $exclude, $max_execution_time );
1334
- } else {
1335
- $dir_size = recurse_dirsize( $path, $exclude, $max_execution_time );
1336
- }
1337
- } else {
1338
- if ( version_compare( get_bloginfo( 'version' ), '5.2.0', '<' ) ) {
1339
- $dir_size = Health_Check_Debug_Data::recurse_dirsize( $path, null, $max_execution_time );
1340
- } else {
1341
- $dir_size = recurse_dirsize( $path, null, $max_execution_time );
1342
- }
1343
- }
1344
- }
1345
-
1346
- if ( false === $dir_size ) {
1347
- // Error reading.
1348
- $results['size'] = __( 'The size cannot be calculated. The directory is not accessible. Usually caused by invalid permissions.', 'health-check' );
1349
- $results['debug'] = 'not accessible';
1350
-
1351
- // Stop total size calculation.
1352
- $size_total = null;
1353
- } elseif ( null === $dir_size ) {
1354
- // Timeout.
1355
- $results['size'] = __( 'The directory size calculation has timed out. Usually caused by a very large number of sub-directories and files.', 'health-check' );
1356
- $results['debug'] = 'timeout while calculating size';
1357
-
1358
- // Stop total size calculation.
1359
- $size_total = null;
1360
- } else {
1361
- if ( null !== $size_total ) {
1362
- $size_total += $dir_size;
1363
- }
1364
-
1365
- $results['raw'] = $dir_size;
1366
- $results['size'] = size_format( $dir_size, 2 );
1367
- $results['debug'] = $results['size'] . " ({$dir_size} bytes)";
1368
- }
1369
-
1370
- $all_sizes[ $name ] = $results;
1371
- }
1372
-
1373
- if ( $size_db > 0 ) {
1374
- $database_size = size_format( $size_db, 2 );
1375
-
1376
- $all_sizes['database_size'] = array(
1377
- 'raw' => $size_db,
1378
- 'size' => $database_size,
1379
- 'debug' => $database_size . " ({$size_db} bytes)",
1380
- );
1381
- } else {
1382
- $all_sizes['database_size'] = array(
1383
- 'size' => __( 'Not available', 'health-check' ),
1384
- 'debug' => 'not available',
1385
- );
1386
- }
1387
-
1388
- if ( null !== $size_total && $size_db > 0 ) {
1389
- $total_size = $size_total + $size_db;
1390
- $total_size_mb = size_format( $total_size, 2 );
1391
-
1392
- $all_sizes['total_size'] = array(
1393
- 'raw' => $total_size,
1394
- 'size' => $total_size_mb,
1395
- 'debug' => $total_size_mb . " ({$total_size} bytes)",
1396
- );
1397
- } else {
1398
- $all_sizes['total_size'] = array(
1399
- 'size' => __( 'Total size is not available. Some errors were encountered when determining the size of your installation.', 'health-check' ),
1400
- 'debug' => 'not available',
1401
- );
1402
- }
1403
-
1404
- return $all_sizes;
1405
- }
1406
-
1407
- /**
1408
- * Fallback function for directory size calculation on sites running WordPress <5.2
1409
- *
1410
- * @param string $directory Full path of a directory.
1411
- * @param string|array $exclude Optional. Full path of a subdirectory to exclude from the total, or array of paths.
1412
- * Expected without trailing slash(es).
1413
- * @param int $max_execution_time Maximum time to run before giving up. In seconds.
1414
- * The timeout is global and is measured from the moment WordPress started to load.
1415
- * @return int|false|null Size in bytes if a valid directory. False if not. Null if timeout.
1416
- */
1417
- static function recurse_dirsize( $directory, $exclude = null, $max_execution_time = null ) {
1418
- $size = 0;
1419
-
1420
- $directory = untrailingslashit( $directory );
1421
-
1422
- if ( ! file_exists( $directory ) || ! is_dir( $directory ) || ! is_readable( $directory ) ) {
1423
- return false;
1424
- }
1425
-
1426
- if (
1427
- ( is_string( $exclude ) && $directory === $exclude ) ||
1428
- ( is_array( $exclude ) && in_array( $directory, $exclude, true ) )
1429
- ) {
1430
- return false;
1431
- }
1432
-
1433
- if ( null === $max_execution_time ) {
1434
- // Keep the previous behavior but attempt to prevent fatal errors from timeout if possible.
1435
- if ( function_exists( 'ini_get' ) ) {
1436
- $max_execution_time = ini_get( 'max_execution_time' );
1437
- } else {
1438
- // Disable...
1439
- $max_execution_time = 0;
1440
- }
1441
-
1442
- // Leave 1 second "buffer" for other operations if $max_execution_time has reasonable value.
1443
- if ( $max_execution_time > 10 ) {
1444
- $max_execution_time -= 1;
1445
- }
1446
- }
1447
-
1448
- $handle = opendir( $directory );
1449
- if ( $handle ) {
1450
- while ( ( $file = readdir( $handle ) ) !== false ) {
1451
- $path = $directory . '/' . $file;
1452
- if ( '.' != $file && '..' != $file ) {
1453
- if ( is_file( $path ) ) {
1454
- $size += filesize( $path );
1455
- } elseif ( is_dir( $path ) ) {
1456
- $handlesize = Health_Check_Debug_Data::recurse_dirsize( $path, $exclude, $max_execution_time );
1457
- if ( $handlesize > 0 ) {
1458
- $size += $handlesize;
1459
- }
1460
- }
1461
-
1462
- if ( $max_execution_time > 0 && microtime( true ) - WP_START_TIMESTAMP > $max_execution_time ) {
1463
- // Time exceeded. Give up instead of risking a fatal timeout.
1464
- $size = null;
1465
- break;
1466
- }
1467
- }
1468
- }
1469
- closedir( $handle );
1470
- }
1471
- return $size;
1472
- }
1473
- }
1
+ <?php
2
+ /**
3
+ * Class for providing debug data based on a users WordPress environment.
4
+ *
5
+ * @package WordPress
6
+ * @subpackage Site_Health
7
+ * @since 5.2.0
8
+ */
9
+
10
+ /**
11
+ * Class WP_Debug_Data
12
+ */
13
+ class WP_Debug_Data {
14
+ /**
15
+ * Calls all core functions to check for updates.
16
+ *
17
+ * @since 5.2.0
18
+ */
19
+ static function check_for_updates() {
20
+ wp_version_check();
21
+ wp_update_plugins();
22
+ wp_update_themes();
23
+ }
24
+
25
+ /**
26
+ * Static function for generating site debug data when required.
27
+ *
28
+ * @return array The debug data for the site.
29
+ * @throws ImagickException
30
+ * @since 5.5.0 Added pretty permalinks support information.
31
+ *
32
+ * @since 5.2.0
33
+ * @global wpdb $wpdb WordPress database abstraction object.
34
+ *
35
+ * @since 5.3.0 Added database charset, database collation,
36
+ * and timezone information.
37
+ */
38
+ static function debug_data() {
39
+ global $wpdb;
40
+
41
+ // Save few function calls.
42
+ $upload_dir = wp_upload_dir();
43
+ $permalink_structure = get_option( 'permalink_structure' );
44
+ $is_ssl = is_ssl();
45
+ $is_multisite = is_multisite();
46
+ $users_can_register = get_option( 'users_can_register' );
47
+ $blog_public = get_option( 'blog_public' );
48
+ $default_comment_status = get_option( 'default_comment_status' );
49
+ $environment_type = wp_get_environment_type();
50
+ $core_version = get_bloginfo( 'version' );
51
+ $core_updates = get_core_updates();
52
+ $core_update_needed = '';
53
+
54
+ if ( is_array( $core_updates ) ) {
55
+ foreach ( $core_updates as $core => $update ) {
56
+ if ( 'upgrade' === $update->response ) {
57
+ /* translators: %s: Latest WordPress version number. */
58
+ $core_update_needed = ' ' . sprintf( __( '(Latest version: %s)' ), $update->version );
59
+ } else {
60
+ $core_update_needed = '';
61
+ }
62
+ }
63
+ }
64
+
65
+ // Set up the array that holds all debug information.
66
+ $info = array();
67
+
68
+ $info['wp-core'] = array(
69
+ 'label' => __( 'WordPress' ),
70
+ 'fields' => array(
71
+ 'version' => array(
72
+ 'label' => __( 'Version' ),
73
+ 'value' => $core_version . $core_update_needed,
74
+ 'debug' => $core_version,
75
+ ),
76
+ 'site_language' => array(
77
+ 'label' => __( 'Site Language' ),
78
+ 'value' => get_locale(),
79
+ ),
80
+ 'user_language' => array(
81
+ 'label' => __( 'User Language' ),
82
+ 'value' => get_user_locale(),
83
+ ),
84
+ 'timezone' => array(
85
+ 'label' => __( 'Timezone' ),
86
+ 'value' => wp_timezone_string(),
87
+ ),
88
+ 'home_url' => array(
89
+ 'label' => __( 'Home URL' ),
90
+ 'value' => get_bloginfo( 'url' ),
91
+ 'private' => true,
92
+ ),
93
+ 'site_url' => array(
94
+ 'label' => __( 'Site URL' ),
95
+ 'value' => get_bloginfo( 'wpurl' ),
96
+ 'private' => true,
97
+ ),
98
+ 'permalink' => array(
99
+ 'label' => __( 'Permalink structure' ),
100
+ 'value' => $permalink_structure ? $permalink_structure : __( 'No permalink structure set' ),
101
+ 'debug' => $permalink_structure,
102
+ ),
103
+ 'https_status' => array(
104
+ 'label' => __( 'Is this site using HTTPS?' ),
105
+ 'value' => $is_ssl ? __( 'Yes' ) : __( 'No' ),
106
+ 'debug' => $is_ssl,
107
+ ),
108
+ 'multisite' => array(
109
+ 'label' => __( 'Is this a multisite?' ),
110
+ 'value' => $is_multisite ? __( 'Yes' ) : __( 'No' ),
111
+ 'debug' => $is_multisite,
112
+ ),
113
+ 'user_registration' => array(
114
+ 'label' => __( 'Can anyone register on this site?' ),
115
+ 'value' => $users_can_register ? __( 'Yes' ) : __( 'No' ),
116
+ 'debug' => $users_can_register,
117
+ ),
118
+ 'blog_public' => array(
119
+ 'label' => __( 'Is this site discouraging search engines?' ),
120
+ 'value' => $blog_public ? __( 'No' ) : __( 'Yes' ),
121
+ 'debug' => $blog_public,
122
+ ),
123
+ 'default_comment_status' => array(
124
+ 'label' => __( 'Default comment status' ),
125
+ 'value' => 'open' === $default_comment_status ? _x( 'Open', 'comment status' ) : _x( 'Closed', 'comment status' ),
126
+ 'debug' => $default_comment_status,
127
+ ),
128
+ 'environment_type' => array(
129
+ 'label' => __( 'Environment type' ),
130
+ 'value' => $environment_type,
131
+ 'debug' => $environment_type,
132
+ ),
133
+ ),
134
+ );
135
+
136
+ if ( ! $is_multisite ) {
137
+ $info['wp-paths-sizes'] = array(
138
+ 'label' => __( 'Directories and Sizes' ),
139
+ 'fields' => array(),
140
+ );
141
+ }
142
+
143
+ $info['wp-dropins'] = array(
144
+ 'label' => __( 'Drop-ins' ),
145
+ 'show_count' => true,
146
+ 'description' => sprintf(
147
+ /* translators: %s: wp-content directory name. */
148
+ __( 'Drop-ins are single files, found in the %s directory, that replace or enhance WordPress features in ways that are not possible for traditional plugins.' ),
149
+ '<code>' . str_replace( ABSPATH, '', WP_CONTENT_DIR ) . '</code>'
150
+ ),
151
+ 'fields' => array(),
152
+ );
153
+
154
+ $info['wp-active-theme'] = array(
155
+ 'label' => __( 'Active Theme' ),
156
+ 'fields' => array(),
157
+ );
158
+
159
+ $info['wp-parent-theme'] = array(
160
+ 'label' => __( 'Parent Theme' ),
161
+ 'fields' => array(),
162
+ );
163
+
164
+ $info['wp-themes-inactive'] = array(
165
+ 'label' => __( 'Inactive Themes' ),
166
+ 'show_count' => true,
167
+ 'fields' => array(),
168
+ );
169
+
170
+ $info['wp-mu-plugins'] = array(
171
+ 'label' => __( 'Must Use Plugins' ),
172
+ 'show_count' => true,
173
+ 'fields' => array(),
174
+ );
175
+
176
+ $info['wp-plugins-active'] = array(
177
+ 'label' => __( 'Active Plugins' ),
178
+ 'show_count' => true,
179
+ 'fields' => array(),
180
+ );
181
+
182
+ $info['wp-plugins-inactive'] = array(
183
+ 'label' => __( 'Inactive Plugins' ),
184
+ 'show_count' => true,
185
+ 'fields' => array(),
186
+ );
187
+
188
+ $info['wp-media'] = array(
189
+ 'label' => __( 'Media Handling' ),
190
+ 'fields' => array(),
191
+ );
192
+
193
+ $info['wp-server'] = array(
194
+ 'label' => __( 'Server' ),
195
+ 'description' => __( 'The options shown below relate to your server setup. If changes are required, you may need your web host&#8217;s assistance.' ),
196
+ 'fields' => array(),
197
+ );
198
+
199
+ $info['wp-database'] = array(
200
+ 'label' => __( 'Database' ),
201
+ 'fields' => array(),
202
+ );
203
+
204
+ // Check if WP_DEBUG_LOG is set.
205
+ $wp_debug_log_value = __( 'Disabled' );
206
+
207
+ if ( is_string( WP_DEBUG_LOG ) ) {
208
+ $wp_debug_log_value = WP_DEBUG_LOG;
209
+ } elseif ( WP_DEBUG_LOG ) {
210
+ $wp_debug_log_value = __( 'Enabled' );
211
+ }
212
+
213
+ // Check CONCATENATE_SCRIPTS.
214
+ if ( defined( 'CONCATENATE_SCRIPTS' ) ) {
215
+ $concatenate_scripts = CONCATENATE_SCRIPTS ? __( 'Enabled' ) : __( 'Disabled' );
216
+ $concatenate_scripts_debug = CONCATENATE_SCRIPTS ? 'true' : 'false';
217
+ } else {
218
+ $concatenate_scripts = __( 'Undefined' );
219
+ $concatenate_scripts_debug = 'undefined';
220
+ }
221
+
222
+ // Check COMPRESS_SCRIPTS.
223
+ if ( defined( 'COMPRESS_SCRIPTS' ) ) {
224
+ $compress_scripts = COMPRESS_SCRIPTS ? __( 'Enabled' ) : __( 'Disabled' );
225
+ $compress_scripts_debug = COMPRESS_SCRIPTS ? 'true' : 'false';
226
+ } else {
227
+ $compress_scripts = __( 'Undefined' );
228
+ $compress_scripts_debug = 'undefined';
229
+ }
230
+
231
+ // Check COMPRESS_CSS.
232
+ if ( defined( 'COMPRESS_CSS' ) ) {
233
+ $compress_css = COMPRESS_CSS ? __( 'Enabled' ) : __( 'Disabled' );
234
+ $compress_css_debug = COMPRESS_CSS ? 'true' : 'false';
235
+ } else {
236
+ $compress_css = __( 'Undefined' );
237
+ $compress_css_debug = 'undefined';
238
+ }
239
+
240
+ // Check WP_LOCAL_DEV.
241
+ if ( defined( 'WP_LOCAL_DEV' ) ) {
242
+ $wp_local_dev = WP_LOCAL_DEV ? __( 'Enabled' ) : __( 'Disabled' );
243
+ $wp_local_dev_debug = WP_LOCAL_DEV ? 'true' : 'false';
244
+ } else {
245
+ $wp_local_dev = __( 'Undefined' );
246
+ $wp_local_dev_debug = 'undefined';
247
+ }
248
+
249
+ $info['wp-constants'] = array(
250
+ 'label' => __( 'WordPress Constants' ),
251
+ 'description' => __( 'These settings alter where and how parts of WordPress are loaded.' ),
252
+ 'fields' => array(
253
+ 'ABSPATH' => array(
254
+ 'label' => 'ABSPATH',
255
+ 'value' => ABSPATH,
256
+ 'private' => true,
257
+ ),
258
+ 'WP_HOME' => array(
259
+ 'label' => 'WP_HOME',
260
+ 'value' => ( defined( 'WP_HOME' ) ? WP_HOME : __( 'Undefined' ) ),
261
+ 'debug' => ( defined( 'WP_HOME' ) ? WP_HOME : 'undefined' ),
262
+ ),
263
+ 'WP_SITEURL' => array(
264
+ 'label' => 'WP_SITEURL',
265
+ 'value' => ( defined( 'WP_SITEURL' ) ? WP_SITEURL : __( 'Undefined' ) ),
266
+ 'debug' => ( defined( 'WP_SITEURL' ) ? WP_SITEURL : 'undefined' ),
267
+ ),
268
+ 'WP_CONTENT_DIR' => array(
269
+ 'label' => 'WP_CONTENT_DIR',
270
+ 'value' => WP_CONTENT_DIR,
271
+ ),
272
+ 'WP_PLUGIN_DIR' => array(
273
+ 'label' => 'WP_PLUGIN_DIR',
274
+ 'value' => WP_PLUGIN_DIR,
275
+ ),
276
+ 'WP_MEMORY_LIMIT' => array(
277
+ 'label' => 'WP_MEMORY_LIMIT',
278
+ 'value' => WP_MEMORY_LIMIT,
279
+ ),
280
+ 'WP_MAX_MEMORY_LIMIT' => array(
281
+ 'label' => 'WP_MAX_MEMORY_LIMIT',
282
+ 'value' => WP_MAX_MEMORY_LIMIT,
283
+ ),
284
+ 'WP_DEBUG' => array(
285
+ 'label' => 'WP_DEBUG',
286
+ 'value' => WP_DEBUG ? __( 'Enabled' ) : __( 'Disabled' ),
287
+ 'debug' => WP_DEBUG,
288
+ ),
289
+ 'WP_DEBUG_DISPLAY' => array(
290
+ 'label' => 'WP_DEBUG_DISPLAY',
291
+ 'value' => WP_DEBUG_DISPLAY ? __( 'Enabled' ) : __( 'Disabled' ),
292
+ 'debug' => WP_DEBUG_DISPLAY,
293
+ ),
294
+ 'WP_DEBUG_LOG' => array(
295
+ 'label' => 'WP_DEBUG_LOG',
296
+ 'value' => $wp_debug_log_value,
297
+ 'debug' => WP_DEBUG_LOG,
298
+ ),
299
+ 'SCRIPT_DEBUG' => array(
300
+ 'label' => 'SCRIPT_DEBUG',
301
+ 'value' => SCRIPT_DEBUG ? __( 'Enabled' ) : __( 'Disabled' ),
302
+ 'debug' => SCRIPT_DEBUG,
303
+ ),
304
+ 'WP_CACHE' => array(
305
+ 'label' => 'WP_CACHE',
306
+ 'value' => WP_CACHE ? __( 'Enabled' ) : __( 'Disabled' ),
307
+ 'debug' => WP_CACHE,
308
+ ),
309
+ 'CONCATENATE_SCRIPTS' => array(
310
+ 'label' => 'CONCATENATE_SCRIPTS',
311
+ 'value' => $concatenate_scripts,
312
+ 'debug' => $concatenate_scripts_debug,
313
+ ),
314
+ 'COMPRESS_SCRIPTS' => array(
315
+ 'label' => 'COMPRESS_SCRIPTS',
316
+ 'value' => $compress_scripts,
317
+ 'debug' => $compress_scripts_debug,
318
+ ),
319
+ 'COMPRESS_CSS' => array(
320
+ 'label' => 'COMPRESS_CSS',
321
+ 'value' => $compress_css,
322
+ 'debug' => $compress_css_debug,
323
+ ),
324
+ 'WP_LOCAL_DEV' => array(
325
+ 'label' => 'WP_LOCAL_DEV',
326
+ 'value' => $wp_local_dev,
327
+ 'debug' => $wp_local_dev_debug,
328
+ ),
329
+ 'DB_CHARSET' => array(
330
+ 'label' => 'DB_CHARSET',
331
+ 'value' => ( defined( 'DB_CHARSET' ) ? DB_CHARSET : __( 'Undefined' ) ),
332
+ 'debug' => ( defined( 'DB_CHARSET' ) ? DB_CHARSET : 'undefined' ),
333
+ ),
334
+ 'DB_COLLATE' => array(
335
+ 'label' => 'DB_COLLATE',
336
+ 'value' => ( defined( 'DB_COLLATE' ) ? DB_COLLATE : __( 'Undefined' ) ),
337
+ 'debug' => ( defined( 'DB_COLLATE' ) ? DB_COLLATE : 'undefined' ),
338
+ ),
339
+ ),
340
+ );
341
+
342
+ $is_writable_abspath = wp_is_writable( ABSPATH );
343
+ $is_writable_wp_content_dir = wp_is_writable( WP_CONTENT_DIR );
344
+ $is_writable_upload_dir = wp_is_writable( $upload_dir['basedir'] );
345
+ $is_writable_wp_plugin_dir = wp_is_writable( WP_PLUGIN_DIR );
346
+ $is_writable_template_directory = wp_is_writable( get_theme_root( get_template() ) );
347
+
348
+ $info['wp-filesystem'] = array(
349
+ 'label' => __( 'Filesystem Permissions' ),
350
+ 'description' => __( 'Shows whether WordPress is able to write to the directories it needs access to.' ),
351
+ 'fields' => array(
352
+ 'wordpress' => array(
353
+ 'label' => __( 'The main WordPress directory' ),
354
+ 'value' => ( $is_writable_abspath ? __( 'Writable' ) : __( 'Not writable' ) ),
355
+ 'debug' => ( $is_writable_abspath ? 'writable' : 'not writable' ),
356
+ ),
357
+ 'wp-content' => array(
358
+ 'label' => __( 'The wp-content directory' ),
359
+ 'value' => ( $is_writable_wp_content_dir ? __( 'Writable' ) : __( 'Not writable' ) ),
360
+ 'debug' => ( $is_writable_wp_content_dir ? 'writable' : 'not writable' ),
361
+ ),
362
+ 'uploads' => array(
363
+ 'label' => __( 'The uploads directory' ),
364
+ 'value' => ( $is_writable_upload_dir ? __( 'Writable' ) : __( 'Not writable' ) ),
365
+ 'debug' => ( $is_writable_upload_dir ? 'writable' : 'not writable' ),
366
+ ),
367
+ 'plugins' => array(
368
+ 'label' => __( 'The plugins directory' ),
369
+ 'value' => ( $is_writable_wp_plugin_dir ? __( 'Writable' ) : __( 'Not writable' ) ),
370
+ 'debug' => ( $is_writable_wp_plugin_dir ? 'writable' : 'not writable' ),
371
+ ),
372
+ 'themes' => array(
373
+ 'label' => __( 'The themes directory' ),
374
+ 'value' => ( $is_writable_template_directory ? __( 'Writable' ) : __( 'Not writable' ) ),
375
+ 'debug' => ( $is_writable_template_directory ? 'writable' : 'not writable' ),
376
+ ),
377
+ ),
378
+ );
379
+
380
+ // Conditionally add debug information for multisite setups.
381
+ if ( is_multisite() ) {
382
+ $network_query = new WP_Network_Query();
383
+ $network_ids = $network_query->query(
384
+ array(
385
+ 'fields' => 'ids',
386
+ 'number' => 100,
387
+ 'no_found_rows' => false,
388
+ )
389
+ );
390
+
391
+ $site_count = 0;
392
+ foreach ( $network_ids as $network_id ) {
393
+ $site_count += get_blog_count( $network_id );
394
+ }
395
+
396
+ $info['wp-core']['fields']['user_count'] = array(
397
+ 'label' => __( 'User count' ),
398
+ 'value' => get_user_count(),
399
+ );
400
+
401
+ $info['wp-core']['fields']['site_count'] = array(
402
+ 'label' => __( 'Site count' ),
403
+ 'value' => $site_count,
404
+ );
405
+
406
+ $info['wp-core']['fields']['network_count'] = array(
407
+ 'label' => __( 'Network count' ),
408
+ 'value' => $network_query->found_networks,
409
+ );
410
+ } else {
411
+ $user_count = count_users();
412
+
413
+ $info['wp-core']['fields']['user_count'] = array(
414
+ 'label' => __( 'User count' ),
415
+ 'value' => $user_count['total_users'],
416
+ );
417
+ }
418
+
419
+ // WordPress features requiring processing.
420
+ $wp_dotorg = wp_remote_get( 'https://wordpress.org', array( 'timeout' => 10 ) );
421
+
422
+ if ( ! is_wp_error( $wp_dotorg ) ) {
423
+ $info['wp-core']['fields']['dotorg_communication'] = array(
424
+ 'label' => __( 'Communication with WordPress.org' ),
425
+ 'value' => __( 'WordPress.org is reachable' ),
426
+ 'debug' => 'true',
427
+ );
428
+ } else {
429
+ $info['wp-core']['fields']['dotorg_communication'] = array(
430
+ 'label' => __( 'Communication with WordPress.org' ),
431
+ 'value' => sprintf(
432
+ /* translators: 1: The IP address WordPress.org resolves to. 2: The error returned by the lookup. */
433
+ __( 'Unable to reach WordPress.org at %1$s: %2$s' ),
434
+ gethostbyname( 'wordpress.org' ),
435
+ $wp_dotorg->get_error_message()
436
+ ),
437
+ 'debug' => $wp_dotorg->get_error_message(),
438
+ );
439
+ }
440
+
441
+ // Get a list of all drop-in replacements.
442
+ $dropins = get_dropins();
443
+
444
+ // Get dropins descriptions.
445
+ $dropin_descriptions = _get_dropins();
446
+
447
+ // Spare few function calls.
448
+ $not_available = __( 'Not available' );
449
+
450
+ foreach ( $dropins as $dropin_key => $dropin ) {
451
+ $info['wp-dropins']['fields'][ sanitize_text_field( $dropin_key ) ] = array(
452
+ 'label' => $dropin_key,
453
+ 'value' => $dropin_descriptions[ $dropin_key ][0],
454
+ 'debug' => 'true',
455
+ );
456
+ }
457
+
458
+ // Populate the media fields.
459
+ $info['wp-media']['fields']['image_editor'] = array(
460
+ 'label' => __( 'Active editor' ),
461
+ 'value' => _wp_image_editor_choose(),
462
+ );
463
+
464
+ // Get ImageMagic information, if available.
465
+ if ( class_exists( 'Imagick' ) ) {
466
+ // Save the Imagick instance for later use.
467
+ $imagick = new Imagick();
468
+ $imagick_version = $imagick->getVersion();
469
+ } else {
470
+ $imagick_version = __( 'Not available' );
471
+ }
472
+
473
+ $info['wp-media']['fields']['imagick_module_version'] = array(
474
+ 'label' => __( 'ImageMagick version number' ),
475
+ 'value' => ( is_array( $imagick_version ) ? $imagick_version['versionNumber'] : $imagick_version ),
476
+ );
477
+
478
+ $info['wp-media']['fields']['imagemagick_version'] = array(
479
+ 'label' => __( 'ImageMagick version string' ),
480
+ 'value' => ( is_array( $imagick_version ) ? $imagick_version['versionString'] : $imagick_version ),
481
+ );
482
+
483
+ if ( ! function_exists( 'ini_get' ) ) {
484
+ $info['wp-media']['fields']['ini_get'] = array(
485
+ 'label' => __( 'File upload settings' ),
486
+ 'value' => sprintf(
487
+ /* translators: %s: ini_get() */
488
+ __( 'Unable to determine some settings, as the %s function has been disabled.' ),
489
+ 'ini_get()'
490
+ ),
491
+ 'debug' => 'ini_get() is disabled',
492
+ );
493
+ } else {
494
+ // Get the PHP ini directive values.
495
+ $post_max_size = ini_get( 'post_max_size' );
496
+ $upload_max_filesize = ini_get( 'upload_max_filesize' );
497
+ $max_file_uploads = ini_get( 'max_file_uploads' );
498
+ $effective = min( wp_convert_hr_to_bytes( $post_max_size ), wp_convert_hr_to_bytes( $upload_max_filesize ) );
499
+
500
+ // Add info in Media section.
501
+ $info['wp-media']['fields']['file_uploads'] = array(
502
+ 'label' => __( 'File uploads' ),
503
+ 'value' => empty( ini_get( 'file_uploads' ) ) ? __( 'Disabled' ) : __( 'Enabled' ),
504
+ 'debug' => 'File uploads is turned off',
505
+ );
506
+ $info['wp-media']['fields']['post_max_size'] = array(
507
+ 'label' => __( 'Max size of post data allowed' ),
508
+ 'value' => $post_max_size,
509
+ );
510
+ $info['wp-media']['fields']['upload_max_filesize'] = array(
511
+ 'label' => __( 'Max size of an uploaded file' ),
512
+ 'value' => $upload_max_filesize,
513
+ );
514
+ $info['wp-media']['fields']['max_effective_size'] = array(
515
+ 'label' => __( 'Max effective file size' ),
516
+ 'value' => size_format( $effective ),
517
+ );
518
+ $info['wp-media']['fields']['max_file_uploads'] = array(
519
+ 'label' => __( 'Max number of files allowed' ),
520
+ 'value' => number_format( $max_file_uploads ),
521
+ );
522
+ }
523
+
524
+ // If Imagick is used as our editor, provide some more information about its limitations.
525
+ if ( 'WP_Image_Editor_Imagick' === _wp_image_editor_choose() && isset( $imagick ) && $imagick instanceof Imagick ) {
526
+ $limits = array(
527
+ 'area' => ( defined( 'imagick::RESOURCETYPE_AREA' ) ? size_format( $imagick->getResourceLimit( imagick::RESOURCETYPE_AREA ) ) : $not_available ),
528
+ 'disk' => ( defined( 'imagick::RESOURCETYPE_DISK' ) ? $imagick->getResourceLimit( imagick::RESOURCETYPE_DISK ) : $not_available ),
529
+ 'file' => ( defined( 'imagick::RESOURCETYPE_FILE' ) ? $imagick->getResourceLimit( imagick::RESOURCETYPE_FILE ) : $not_available ),
530
+ 'map' => ( defined( 'imagick::RESOURCETYPE_MAP' ) ? size_format( $imagick->getResourceLimit( imagick::RESOURCETYPE_MAP ) ) : $not_available ),
531
+ 'memory' => ( defined( 'imagick::RESOURCETYPE_MEMORY' ) ? size_format( $imagick->getResourceLimit( imagick::RESOURCETYPE_MEMORY ) ) : $not_available ),
532
+ 'thread' => ( defined( 'imagick::RESOURCETYPE_THREAD' ) ? $imagick->getResourceLimit( imagick::RESOURCETYPE_THREAD ) : $not_available ),
533
+ );
534
+
535
+ $limits_debug = array(
536
+ 'imagick::RESOURCETYPE_AREA' => ( defined( 'imagick::RESOURCETYPE_AREA' ) ? size_format( $imagick->getResourceLimit( imagick::RESOURCETYPE_AREA ) ) : 'not available' ),
537
+ 'imagick::RESOURCETYPE_DISK' => ( defined( 'imagick::RESOURCETYPE_DISK' ) ? $imagick->getResourceLimit( imagick::RESOURCETYPE_DISK ) : 'not available' ),
538
+ 'imagick::RESOURCETYPE_FILE' => ( defined( 'imagick::RESOURCETYPE_FILE' ) ? $imagick->getResourceLimit( imagick::RESOURCETYPE_FILE ) : 'not available' ),
539
+ 'imagick::RESOURCETYPE_MAP' => ( defined( 'imagick::RESOURCETYPE_MAP' ) ? size_format( $imagick->getResourceLimit( imagick::RESOURCETYPE_MAP ) ) : 'not available' ),
540
+ 'imagick::RESOURCETYPE_MEMORY' => ( defined( 'imagick::RESOURCETYPE_MEMORY' ) ? size_format( $imagick->getResourceLimit( imagick::RESOURCETYPE_MEMORY ) ) : 'not available' ),
541
+ 'imagick::RESOURCETYPE_THREAD' => ( defined( 'imagick::RESOURCETYPE_THREAD' ) ? $imagick->getResourceLimit( imagick::RESOURCETYPE_THREAD ) : 'not available' ),
542
+ );
543
+
544
+ $info['wp-media']['fields']['imagick_limits'] = array(
545
+ 'label' => __( 'Imagick Resource Limits' ),
546
+ 'value' => $limits,
547
+ 'debug' => $limits_debug,
548
+ );
549
+ }
550
+
551
+ // Get GD information, if available.
552
+ if ( function_exists( 'gd_info' ) ) {
553
+ $gd = gd_info();
554
+ } else {
555
+ $gd = false;
556
+ }
557
+
558
+ $info['wp-media']['fields']['gd_version'] = array(
559
+ 'label' => __( 'GD version' ),
560
+ 'value' => ( is_array( $gd ) ? $gd['GD Version'] : $not_available ),
561
+ 'debug' => ( is_array( $gd ) ? $gd['GD Version'] : 'not available' ),
562
+ );
563
+
564
+ // Get Ghostscript information, if available.
565
+ if ( function_exists( 'exec' ) ) {
566
+ $gs = exec( 'gs --version' );
567
+
568
+ if ( empty( $gs ) ) {
569
+ $gs = $not_available;
570
+ $gs_debug = 'not available';
571
+ } else {
572
+ $gs_debug = $gs;
573
+ }
574
+ } else {
575
+ $gs = __( 'Unable to determine if Ghostscript is installed' );
576
+ $gs_debug = 'unknown';
577
+ }
578
+
579
+ $info['wp-media']['fields']['ghostscript_version'] = array(
580
+ 'label' => __( 'Ghostscript version' ),
581
+ 'value' => $gs,
582
+ 'debug' => $gs_debug,
583
+ );
584
+
585
+ // Populate the server debug fields.
586
+ if ( function_exists( 'php_uname' ) ) {
587
+ $server_architecture = sprintf( '%s %s %s', php_uname( 's' ), php_uname( 'r' ), php_uname( 'm' ) );
588
+ } else {
589
+ $server_architecture = 'unknown';
590
+ }
591
+
592
+ if ( function_exists( 'phpversion' ) ) {
593
+ $php_version_debug = phpversion();
594
+ // Whether PHP supports 64-bit.
595
+ $php64bit = ( PHP_INT_SIZE * 8 === 64 );
596
+
597
+ $php_version = sprintf(
598
+ '%s %s',
599
+ $php_version_debug,
600
+ ( $php64bit ? __( '(Supports 64bit values)' ) : __( '(Does not support 64bit values)' ) )
601
+ );
602
+
603
+ if ( $php64bit ) {
604
+ $php_version_debug .= ' 64bit';
605
+ }
606
+ } else {
607
+ $php_version = __( 'Unable to determine PHP version' );
608
+ $php_version_debug = 'unknown';
609
+ }
610
+
611
+ if ( function_exists( 'php_sapi_name' ) ) {
612
+ $php_sapi = php_sapi_name();
613
+ } else {
614
+ $php_sapi = 'unknown';
615
+ }
616
+
617
+ $info['wp-server']['fields']['server_architecture'] = array(
618
+ 'label' => __( 'Server architecture' ),
619
+ 'value' => ( 'unknown' !== $server_architecture ? $server_architecture : __( 'Unable to determine server architecture' ) ),
620
+ 'debug' => $server_architecture,
621
+ );
622
+ $info['wp-server']['fields']['httpd_software'] = array(
623
+ 'label' => __( 'Web server' ),
624
+ 'value' => ( isset( $_SERVER['SERVER_SOFTWARE'] ) ? $_SERVER['SERVER_SOFTWARE'] : __( 'Unable to determine what web server software is used' ) ),
625
+ 'debug' => ( isset( $_SERVER['SERVER_SOFTWARE'] ) ? $_SERVER['SERVER_SOFTWARE'] : 'unknown' ),
626
+ );
627
+ $info['wp-server']['fields']['php_version'] = array(
628
+ 'label' => __( 'PHP version' ),
629
+ 'value' => $php_version,
630
+ 'debug' => $php_version_debug,
631
+ );
632
+ $info['wp-server']['fields']['php_sapi'] = array(
633
+ 'label' => __( 'PHP SAPI' ),
634
+ 'value' => ( 'unknown' !== $php_sapi ? $php_sapi : __( 'Unable to determine PHP SAPI' ) ),
635
+ 'debug' => $php_sapi,
636
+ );
637
+
638
+ // Some servers disable `ini_set()` and `ini_get()`, we check this before trying to get configuration values.
639
+ if ( ! function_exists( 'ini_get' ) ) {
640
+ $info['wp-server']['fields']['ini_get'] = array(
641
+ 'label' => __( 'Server settings' ),
642
+ 'value' => sprintf(
643
+ /* translators: %s: ini_get() */
644
+ __( 'Unable to determine some settings, as the %s function has been disabled.' ),
645
+ 'ini_get()'
646
+ ),
647
+ 'debug' => 'ini_get() is disabled',
648
+ );
649
+ } else {
650
+ $info['wp-server']['fields']['max_input_variables'] = array(
651
+ 'label' => __( 'PHP max input variables' ),
652
+ 'value' => ini_get( 'max_input_vars' ),
653
+ );
654
+ $info['wp-server']['fields']['time_limit'] = array(
655
+ 'label' => __( 'PHP time limit' ),
656
+ 'value' => ini_get( 'max_execution_time' ),
657
+ );
658
+
659
+ $info['wp-server']['fields']['memory_limit'] = array(
660
+ 'label' => __( 'PHP memory limit' ),
661
+ 'value' => ini_get( 'memory_limit' ),
662
+ );
663
+
664
+ $info['wp-server']['fields']['max_input_time'] = array(
665
+ 'label' => __( 'Max input time' ),
666
+ 'value' => ini_get( 'max_input_time' ),
667
+ );
668
+ $info['wp-server']['fields']['upload_max_filesize'] = array(
669
+ 'label' => __( 'Upload max filesize' ),
670
+ 'value' => ini_get( 'upload_max_filesize' ),
671
+ );
672
+ $info['wp-server']['fields']['php_post_max_size'] = array(
673
+ 'label' => __( 'PHP post max size' ),
674
+ 'value' => ini_get( 'post_max_size' ),
675
+ );
676
+ }
677
+
678
+ if ( function_exists( 'curl_version' ) ) {
679
+ $curl = curl_version();
680
+
681
+ $info['wp-server']['fields']['curl_version'] = array(
682
+ 'label' => __( 'cURL version' ),
683
+ 'value' => sprintf( '%s %s', $curl['version'], $curl['ssl_version'] ),
684
+ );
685
+ } else {
686
+ $info['wp-server']['fields']['curl_version'] = array(
687
+ 'label' => __( 'cURL version' ),
688
+ 'value' => $not_available,
689
+ 'debug' => 'not available',
690
+ );
691
+ }
692
+
693
+ // SUHOSIN.
694
+ $suhosin_loaded = ( extension_loaded( 'suhosin' ) || ( defined( 'SUHOSIN_PATCH' ) && constant( 'SUHOSIN_PATCH' ) ) );
695
+
696
+ $info['wp-server']['fields']['suhosin'] = array(
697
+ 'label' => __( 'Is SUHOSIN installed?' ),
698
+ 'value' => ( $suhosin_loaded ? __( 'Yes' ) : __( 'No' ) ),
699
+ 'debug' => $suhosin_loaded,
700
+ );
701
+
702
+ // Imagick.
703
+ $imagick_loaded = extension_loaded( 'imagick' );
704
+
705
+ $info['wp-server']['fields']['imagick_availability'] = array(
706
+ 'label' => __( 'Is the Imagick library available?' ),
707
+ 'value' => ( $imagick_loaded ? __( 'Yes' ) : __( 'No' ) ),
708
+ 'debug' => $imagick_loaded,
709
+ );
710
+
711
+ // Pretty permalinks.
712
+ $pretty_permalinks_supported = got_url_rewrite();
713
+
714
+ $info['wp-server']['fields']['pretty_permalinks'] = array(
715
+ 'label' => __( 'Are pretty permalinks supported?' ),
716
+ 'value' => ( $pretty_permalinks_supported ? __( 'Yes' ) : __( 'No' ) ),
717
+ 'debug' => $pretty_permalinks_supported,
718
+ );
719
+
720
+ // Check if a .htaccess file exists.
721
+ if ( is_file( ABSPATH . '.htaccess' ) ) {
722
+ // If the file exists, grab the content of it.
723
+ $htaccess_content = file_get_contents( ABSPATH . '.htaccess' );
724
+
725
+ // Filter away the core WordPress rules.
726
+ $filtered_htaccess_content = trim( preg_replace( '/\# BEGIN WordPress[\s\S]+?# END WordPress/si', '', $htaccess_content ) );
727
+ $filtered_htaccess_content = ! empty( $filtered_htaccess_content );
728
+
729
+ if ( $filtered_htaccess_content ) {
730
+ /* translators: %s: .htaccess */
731
+ $htaccess_rules_string = sprintf( __( 'Custom rules have been added to your %s file.' ), '.htaccess' );
732
+ } else {
733
+ /* translators: %s: .htaccess */
734
+ $htaccess_rules_string = sprintf( __( 'Your %s file contains only core WordPress features.' ), '.htaccess' );
735
+ }
736
+
737
+ $info['wp-server']['fields']['htaccess_extra_rules'] = array(
738
+ 'label' => __( '.htaccess rules' ),
739
+ 'value' => $htaccess_rules_string,
740
+ 'debug' => $filtered_htaccess_content,
741
+ );
742
+ }
743
+
744
+ // Populate the database debug fields.
745
+ if ( is_resource( $wpdb->dbh ) ) {
746
+ // Old mysql extension.
747
+ $extension = 'mysql';
748
+ } elseif ( is_object( $wpdb->dbh ) ) {
749
+ // mysqli or PDO.
750
+ $extension = get_class( $wpdb->dbh );
751
+ } else {
752
+ // Unknown sql extension.
753
+ $extension = null;
754
+ }
755
+
756
+ $server = $wpdb->get_var( 'SELECT VERSION()' );
757
+
758
+ if ( isset( $wpdb->use_mysqli ) && $wpdb->use_mysqli ) {
759
+ $client_version = $wpdb->dbh->client_info;
760
+ } else {
761
+ // phpcs:ignore WordPress.DB.RestrictedFunctions.mysql_mysql_get_client_info,PHPCompatibility.Extensions.RemovedExtensions.mysql_DeprecatedRemoved
762
+ if ( preg_match( '|[0-9]{1,2}\.[0-9]{1,2}\.[0-9]{1,2}|', mysql_get_client_info(), $matches ) ) {
763
+ $client_version = $matches[0];
764
+ } else {
765
+ $client_version = null;
766
+ }
767
+ }
768
+
769
+ $info['wp-database']['fields']['extension'] = array(
770
+ 'label' => __( 'Extension' ),
771
+ 'value' => $extension,
772
+ );
773
+
774
+ $info['wp-database']['fields']['server_version'] = array(
775
+ 'label' => __( 'Server version' ),
776
+ 'value' => $server,
777
+ );
778
+
779
+ $info['wp-database']['fields']['client_version'] = array(
780
+ 'label' => __( 'Client version' ),
781
+ 'value' => $client_version,
782
+ );
783
+
784
+ $info['wp-database']['fields']['database_user'] = array(
785
+ 'label' => __( 'Database username' ),
786
+ 'value' => $wpdb->dbuser,
787
+ 'private' => true,
788
+ );
789
+
790
+ $info['wp-database']['fields']['database_host'] = array(
791
+ 'label' => __( 'Database host' ),
792
+ 'value' => $wpdb->dbhost,
793
+ 'private' => true,
794
+ );
795
+
796
+ $info['wp-database']['fields']['database_name'] = array(
797
+ 'label' => __( 'Database name' ),
798
+ 'value' => $wpdb->dbname,
799
+ 'private' => true,
800
+ );
801
+
802
+ $info['wp-database']['fields']['database_prefix'] = array(
803
+ 'label' => __( 'Table prefix' ),
804
+ 'value' => $wpdb->prefix,
805
+ 'private' => true,
806
+ );
807
+
808
+ $info['wp-database']['fields']['database_charset'] = array(
809
+ 'label' => __( 'Database charset' ),
810
+ 'value' => $wpdb->charset,
811
+ 'private' => true,
812
+ );
813
+
814
+ $info['wp-database']['fields']['database_collate'] = array(
815
+ 'label' => __( 'Database collation' ),
816
+ 'value' => $wpdb->collate,
817
+ 'private' => true,
818
+ );
819
+
820
+ // List must use plugins if there are any.
821
+ $mu_plugins = get_mu_plugins();
822
+
823
+ foreach ( $mu_plugins as $plugin_path => $plugin ) {
824
+ $plugin_version = $plugin['Version'];
825
+ $plugin_author = $plugin['Author'];
826
+
827
+ $plugin_version_string = __( 'No version or author information is available.' );
828
+ $plugin_version_string_debug = 'author: (undefined), version: (undefined)';
829
+
830
+ if ( ! empty( $plugin_version ) && ! empty( $plugin_author ) ) {
831
+ /* translators: 1: Plugin version number. 2: Plugin author name. */
832
+ $plugin_version_string = sprintf( __( 'Version %1$s by %2$s' ), $plugin_version, $plugin_author );
833
+ $plugin_version_string_debug = sprintf( 'version: %s, author: %s', $plugin_version, $plugin_author );
834
+ } else {
835
+ if ( ! empty( $plugin_author ) ) {
836
+ /* translators: %s: Plugin author name. */
837
+ $plugin_version_string = sprintf( __( 'By %s' ), $plugin_author );
838
+ $plugin_version_string_debug = sprintf( 'author: %s, version: (undefined)', $plugin_author );
839
+ }
840
+
841
+ if ( ! empty( $plugin_version ) ) {
842
+ /* translators: %s: Plugin version number. */
843
+ $plugin_version_string = sprintf( __( 'Version %s' ), $plugin_version );
844
+ $plugin_version_string_debug = sprintf( 'author: (undefined), version: %s', $plugin_version );
845
+ }
846
+ }
847
+
848
+ $info['wp-mu-plugins']['fields'][ sanitize_text_field( $plugin['Name'] ) ] = array(
849
+ 'label' => $plugin['Name'],
850
+ 'value' => $plugin_version_string,
851
+ 'debug' => $plugin_version_string_debug,
852
+ );
853
+ }
854
+
855
+ // List all available plugins.
856
+ $plugins = get_plugins();
857
+ $plugin_updates = get_plugin_updates();
858
+ $transient = get_site_transient( 'update_plugins' );
859
+
860
+ foreach ( $plugins as $plugin_path => $plugin ) {
861
+ $plugin_part = ( is_plugin_active( $plugin_path ) ) ? 'wp-plugins-active' : 'wp-plugins-inactive';
862
+
863
+ $plugin_version = $plugin['Version'];
864
+ $plugin_author = $plugin['Author'];
865
+
866
+ $plugin_version_string = __( 'No version or author information is available.' );
867
+ $plugin_version_string_debug = 'author: (undefined), version: (undefined)';
868
+
869
+ if ( ! empty( $plugin_version ) && ! empty( $plugin_author ) ) {
870
+ /* translators: 1: Plugin version number. 2: Plugin author name. */
871
+ $plugin_version_string = sprintf( __( 'Version %1$s by %2$s' ), $plugin_version, $plugin_author );
872
+ $plugin_version_string_debug = sprintf( 'version: %s, author: %s', $plugin_version, $plugin_author );
873
+ } else {
874
+ if ( ! empty( $plugin_author ) ) {
875
+ /* translators: %s: Plugin author name. */
876
+ $plugin_version_string = sprintf( __( 'By %s' ), $plugin_author );
877
+ $plugin_version_string_debug = sprintf( 'author: %s, version: (undefined)', $plugin_author );
878
+ }
879
+
880
+ if ( ! empty( $plugin_version ) ) {
881
+ /* translators: %s: Plugin version number. */
882
+ $plugin_version_string = sprintf( __( 'Version %s' ), $plugin_version );
883
+ $plugin_version_string_debug = sprintf( 'author: (undefined), version: %s', $plugin_version );
884
+ }
885
+ }
886
+
887
+ if ( array_key_exists( $plugin_path, $plugin_updates ) ) {
888
+ /* translators: %s: Latest plugin version number. */
889
+ $plugin_version_string .= ' ' . sprintf( __( '(Latest version: %s)' ), $plugin_updates[ $plugin_path ]->update->new_version );
890
+ $plugin_version_string_debug .= sprintf( ' (latest version: %s)', $plugin_updates[ $plugin_path ]->update->new_version );
891
+ }
892
+
893
+ $info[ $plugin_part ]['fields'][ sanitize_text_field( $plugin['Name'] ) ] = array(
894
+ 'label' => $plugin['Name'],
895
+ 'value' => $plugin_version_string,
896
+ 'debug' => $plugin_version_string_debug,
897
+ );
898
+ }
899
+
900
+ // Populate the section for the currently active theme.
901
+ global $_wp_theme_features;
902
+ $theme_features = array();
903
+
904
+ if ( ! empty( $_wp_theme_features ) ) {
905
+ foreach ( $_wp_theme_features as $feature => $options ) {
906
+ $theme_features[] = $feature;
907
+ }
908
+ }
909
+
910
+ $active_theme = wp_get_theme();
911
+ $theme_updates = get_theme_updates();
912
+ $transient = get_site_transient( 'update_themes' );
913
+
914
+ $active_theme_version = $active_theme->version;
915
+ $active_theme_version_debug = $active_theme_version;
916
+
917
+ if ( array_key_exists( $active_theme->stylesheet, $theme_updates ) ) {
918
+ $theme_update_new_version = $theme_updates[ $active_theme->stylesheet ]->update['new_version'];
919
+
920
+ /* translators: %s: Latest theme version number. */
921
+ $active_theme_version .= ' ' . sprintf( __( '(Latest version: %s)' ), $theme_update_new_version );
922
+ $active_theme_version_debug .= sprintf( ' (latest version: %s)', $theme_update_new_version );
923
+ }
924
+
925
+ $active_theme_author_uri = $active_theme->display( 'AuthorURI' );
926
+
927
+ if ( $active_theme->parent_theme ) {
928
+ $active_theme_parent_theme = sprintf(
929
+ /* translators: 1: Theme name. 2: Theme slug. */
930
+ __( '%1$s (%2$s)' ),
931
+ $active_theme->parent_theme,
932
+ $active_theme->template
933
+ );
934
+ $active_theme_parent_theme_debug = sprintf(
935
+ '%s (%s)',
936
+ $active_theme->parent_theme,
937
+ $active_theme->template
938
+ );
939
+ } else {
940
+ $active_theme_parent_theme = __( 'None' );
941
+ $active_theme_parent_theme_debug = 'none';
942
+ }
943
+
944
+ $info['wp-active-theme']['fields'] = array(
945
+ 'name' => array(
946
+ 'label' => __( 'Name' ),
947
+ 'value' => sprintf(
948
+ /* translators: 1: Theme name. 2: Theme slug. */
949
+ __( '%1$s (%2$s)' ),
950
+ $active_theme->name,
951
+ $active_theme->stylesheet
952
+ ),
953
+ ),
954
+ 'version' => array(
955
+ 'label' => __( 'Version' ),
956
+ 'value' => $active_theme_version,
957
+ 'debug' => $active_theme_version_debug,
958
+ ),
959
+ 'author' => array(
960
+ 'label' => __( 'Author' ),
961
+ 'value' => wp_kses( $active_theme->author, array() ),
962
+ ),
963
+ 'author_website' => array(
964
+ 'label' => __( 'Author website' ),
965
+ 'value' => ( $active_theme_author_uri ? $active_theme_author_uri : __( 'Undefined' ) ),
966
+ 'debug' => ( $active_theme_author_uri ? $active_theme_author_uri : '(undefined)' ),
967
+ ),
968
+ 'parent_theme' => array(
969
+ 'label' => __( 'Parent theme' ),
970
+ 'value' => $active_theme_parent_theme,
971
+ 'debug' => $active_theme_parent_theme_debug,
972
+ ),
973
+ 'theme_features' => array(
974
+ 'label' => __( 'Theme features' ),
975
+ 'value' => implode( ', ', $theme_features ),
976
+ ),
977
+ 'theme_path' => array(
978
+ 'label' => __( 'Theme directory location' ),
979
+ 'value' => get_stylesheet_directory(),
980
+ ),
981
+ );
982
+
983
+ $parent_theme = $active_theme->parent();
984
+
985
+ if ( $parent_theme ) {
986
+ $parent_theme_version = $parent_theme->version;
987
+ $parent_theme_version_debug = $parent_theme_version;
988
+
989
+ if ( array_key_exists( $parent_theme->stylesheet, $theme_updates ) ) {
990
+ $parent_theme_update_new_version = $theme_updates[ $parent_theme->stylesheet ]->update['new_version'];
991
+
992
+ /* translators: %s: Latest theme version number. */
993
+ $parent_theme_version .= ' ' . sprintf( __( '(Latest version: %s)' ), $parent_theme_update_new_version );
994
+ $parent_theme_version_debug .= sprintf( ' (latest version: %s)', $parent_theme_update_new_version );
995
+ }
996
+
997
+ $parent_theme_author_uri = $parent_theme->display( 'AuthorURI' );
998
+
999
+ $info['wp-parent-theme']['fields'] = array(
1000
+ 'name' => array(
1001
+ 'label' => __( 'Name' ),
1002
+ 'value' => sprintf(
1003
+ /* translators: 1: Theme name. 2: Theme slug. */
1004
+ __( '%1$s (%2$s)' ),
1005
+ $parent_theme->name,
1006
+ $parent_theme->stylesheet
1007
+ ),
1008
+ ),
1009
+ 'version' => array(
1010
+ 'label' => __( 'Version' ),
1011
+ 'value' => $parent_theme_version,
1012
+ 'debug' => $parent_theme_version_debug,
1013
+ ),
1014
+ 'author' => array(
1015
+ 'label' => __( 'Author' ),
1016
+ 'value' => wp_kses( $parent_theme->author, array() ),
1017
+ ),
1018
+ 'author_website' => array(
1019
+ 'label' => __( 'Author website' ),
1020
+ 'value' => ( $parent_theme_author_uri ? $parent_theme_author_uri : __( 'Undefined' ) ),
1021
+ 'debug' => ( $parent_theme_author_uri ? $parent_theme_author_uri : '(undefined)' ),
1022
+ ),
1023
+ 'theme_path' => array(
1024
+ 'label' => __( 'Theme directory location' ),
1025
+ 'value' => get_template_directory(),
1026
+ ),
1027
+ );
1028
+ }
1029
+
1030
+ // Populate a list of all themes available in the install.
1031
+ $all_themes = wp_get_themes();
1032
+
1033
+ foreach ( $all_themes as $theme_slug => $theme ) {
1034
+ // Exclude the currently active theme from the list of all themes.
1035
+ if ( $active_theme->stylesheet === $theme_slug ) {
1036
+ continue;
1037
+ }
1038
+
1039
+ // Exclude the currently active parent theme from the list of all themes.
1040
+ if ( ! empty( $parent_theme ) && $parent_theme->stylesheet === $theme_slug ) {
1041
+ continue;
1042
+ }
1043
+
1044
+ $theme_version = $theme->version;
1045
+ $theme_author = $theme->author;
1046
+
1047
+ // Sanitize.
1048
+ $theme_author = wp_kses( $theme_author, array() );
1049
+
1050
+ $theme_version_string = __( 'No version or author information is available.' );
1051
+ $theme_version_string_debug = 'undefined';
1052
+
1053
+ if ( ! empty( $theme_version ) && ! empty( $theme_author ) ) {
1054
+ /* translators: 1: Theme version number. 2: Theme author name. */
1055
+ $theme_version_string = sprintf( __( 'Version %1$s by %2$s' ), $theme_version, $theme_author );
1056
+ $theme_version_string_debug = sprintf( 'version: %s, author: %s', $theme_version, $theme_author );
1057
+ } else {
1058
+ if ( ! empty( $theme_author ) ) {
1059
+ /* translators: %s: Theme author name. */
1060
+ $theme_version_string = sprintf( __( 'By %s' ), $theme_author );
1061
+ $theme_version_string_debug = sprintf( 'author: %s, version: (undefined)', $theme_author );
1062
+ }
1063
+
1064
+ if ( ! empty( $theme_version ) ) {
1065
+ /* translators: %s: Theme version number. */
1066
+ $theme_version_string = sprintf( __( 'Version %s' ), $theme_version );
1067
+ $theme_version_string_debug = sprintf( 'author: (undefined), version: %s', $theme_version );
1068
+ }
1069
+ }
1070
+
1071
+ if ( array_key_exists( $theme_slug, $theme_updates ) ) {
1072
+ /* translators: %s: Latest theme version number. */
1073
+ $theme_version_string .= ' ' . sprintf( __( '(Latest version: %s)' ), $theme_updates[ $theme_slug ]->update['new_version'] );
1074
+ $theme_version_string_debug .= sprintf( ' (latest version: %s)', $theme_updates[ $theme_slug ]->update['new_version'] );
1075
+ }
1076
+
1077
+ $info['wp-themes-inactive']['fields'][ sanitize_text_field( $theme->name ) ] = array(
1078
+ 'label' => sprintf(
1079
+ /* translators: 1: Theme name. 2: Theme slug. */
1080
+ __( '%1$s (%2$s)' ),
1081
+ $theme->name,
1082
+ $theme_slug
1083
+ ),
1084
+ 'value' => $theme_version_string,
1085
+ 'debug' => $theme_version_string_debug,
1086
+ );
1087
+ }
1088
+
1089
+ // Add more filesystem checks.
1090
+ if ( defined( 'WPMU_PLUGIN_DIR' ) && is_dir( WPMU_PLUGIN_DIR ) ) {
1091
+ $is_writable_wpmu_plugin_dir = wp_is_writable( WPMU_PLUGIN_DIR );
1092
+
1093
+ $info['wp-filesystem']['fields']['mu-plugins'] = array(
1094
+ 'label' => __( 'The must use plugins directory' ),
1095
+ 'value' => ( $is_writable_wpmu_plugin_dir ? __( 'Writable' ) : __( 'Not writable' ) ),
1096
+ 'debug' => ( $is_writable_wpmu_plugin_dir ? 'writable' : 'not writable' ),
1097
+ );
1098
+ }
1099
+
1100
+ /**
1101
+ * Add or modify the debug information.
1102
+ *
1103
+ * Plugin or themes may wish to introduce their own debug information without creating additional admin pages
1104
+ * they can utilize this filter to introduce their own sections or add more data to existing sections.
1105
+ *
1106
+ * Array keys for sections added by core are all prefixed with `wp-`, plugins and themes should use their own slug as
1107
+ * a prefix, both for consistency as well as avoiding key collisions. Note that the array keys are used as labels
1108
+ * for the copied data.
1109
+ *
1110
+ * All strings are expected to be plain text except $description that can contain inline HTML tags (see below).
1111
+ *
1112
+ * @param array $args {
1113
+ * The debug information to be added to the core information page.
1114
+ *
1115
+ * This is an associative multi-dimensional array, up to three levels deep. The topmost array holds the sections.
1116
+ * Each section has a `$fields` associative array (see below), and each `$value` in `$fields` can be
1117
+ * another associative array of name/value pairs when there is more structured data to display.
1118
+ *
1119
+ * @type string $label The title for this section of the debug output.
1120
+ * @type string $description Optional. A description for your information section which may contain basic HTML
1121
+ * markup, inline tags only as it is outputted in a paragraph.
1122
+ * @type boolean $show_count Optional. If set to `true` the amount of fields will be included in the title for
1123
+ * this section.
1124
+ * @type boolean $private Optional. If set to `true` the section and all associated fields will be excluded
1125
+ * from the copied data.
1126
+ * @type array $fields {
1127
+ * An associative array containing the data to be displayed.
1128
+ *
1129
+ * @type string $label The label for this piece of information.
1130
+ * @type string $value The output that is displayed for this field. Text should be translated. Can be
1131
+ * an associative array that is displayed as name/value pairs.
1132
+ * @type string $debug Optional. The output that is used for this field when the user copies the data.
1133
+ * It should be more concise and not translated. If not set, the content of `$value` is used.
1134
+ * Note that the array keys are used as labels for the copied data.
1135
+ * @type boolean $private Optional. If set to `true` the field will not be included in the copied data
1136
+ * allowing you to show, for example, API keys here.
1137
+ * }
1138
+ * }
1139
+ * @since 5.2.0
1140
+ *
1141
+ */
1142
+ $info = apply_filters( 'debug_information', $info );
1143
+
1144
+ return $info;
1145
+ }
1146
+
1147
+ /**
1148
+ * Format the information gathered for debugging, in a manner suitable for copying to a forum or support ticket.
1149
+ *
1150
+ * @param array $info_array Information gathered from the `WP_Debug_Data::debug_data` function.
1151
+ * @param string $type The data type to return, either 'info' or 'debug'.
1152
+ *
1153
+ * @return string The formatted data.
1154
+ * @since 5.2.0
1155
+ *
1156
+ */
1157
+ public static function format( $info_array, $type ) {
1158
+ $return = "`\n";
1159
+
1160
+ foreach ( $info_array as $section => $details ) {
1161
+ // Skip this section if there are no fields, or the section has been declared as private.
1162
+ if ( empty( $details['fields'] ) || ( isset( $details['private'] ) && $details['private'] ) ) {
1163
+ continue;
1164
+ }
1165
+
1166
+ $section_label = 'debug' === $type ? $section : $details['label'];
1167
+
1168
+ $return .= sprintf(
1169
+ "### %s%s ###\n\n",
1170
+ $section_label,
1171
+ ( isset( $details['show_count'] ) && $details['show_count'] ? sprintf( ' (%d)', count( $details['fields'] ) ) : '' )
1172
+ );
1173
+
1174
+ foreach ( $details['fields'] as $field_name => $field ) {
1175
+ if ( isset( $field['private'] ) && true === $field['private'] ) {
1176
+ continue;
1177
+ }
1178
+
1179
+ if ( 'debug' === $type && isset( $field['debug'] ) ) {
1180
+ $debug_data = $field['debug'];
1181
+ } else {
1182
+ $debug_data = $field['value'];
1183
+ }
1184
+
1185
+ // Can be array, one level deep only.
1186
+ if ( is_array( $debug_data ) ) {
1187
+ $value = '';
1188
+
1189
+ foreach ( $debug_data as $sub_field_name => $sub_field_value ) {
1190
+ $value .= sprintf( "\n\t%s: %s", $sub_field_name, $sub_field_value );
1191
+ }
1192
+ } elseif ( is_bool( $debug_data ) ) {
1193
+ $value = $debug_data ? 'true' : 'false';
1194
+ } elseif ( empty( $debug_data ) && '0' !== $debug_data ) {
1195
+ $value = 'undefined';
1196
+ } else {
1197
+ $value = $debug_data;
1198
+ }
1199
+
1200
+ if ( 'debug' === $type ) {
1201
+ $label = $field_name;
1202
+ } else {
1203
+ $label = $field['label'];
1204
+ }
1205
+
1206
+ $return .= sprintf( "%s: %s\n", $label, $value );
1207
+ }
1208
+
1209
+ $return .= "\n";
1210
+ }
1211
+
1212
+ $return .= '`';
1213
+
1214
+ return $return;
1215
+ }
1216
+
1217
+ /**
1218
+ * Fetch the total size of all the database tables for the active database user.
1219
+ *
1220
+ * @return int The size of the database, in bytes.
1221
+ * @since 5.2.0
1222
+ *
1223
+ */
1224
+ public static function get_database_size() {
1225
+ global $wpdb;
1226
+ $size = 0;
1227
+ $rows = $wpdb->get_results( 'SHOW TABLE STATUS', ARRAY_A );
1228
+
1229
+ if ( $wpdb->num_rows > 0 ) {
1230
+ foreach ( $rows as $row ) {
1231
+ $size += $row['Data_length'] + $row['Index_length'];
1232
+ }
1233
+ }
1234
+
1235
+ return (int) $size;
1236
+ }
1237
+ }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
HealthCheck/BackCompat/class-wp-site-health.php ADDED
@@ -0,0 +1,149 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Primary class for the Site Health component.
4
+ *
5
+ * @package WordPress
6
+ * @subpackage Site_Health
7
+ * @since 5.2.0
8
+ */
9
+
10
+ class WP_Site_Health {
11
+
12
+ public function __construct() {
13
+ $this->init();
14
+ }
15
+
16
+ public function init() {
17
+ add_filter( 'cron_schedules', array( $this, 'cron_schedules' ) );
18
+
19
+ add_action( 'admin_menu', array( $this, 'action_admin_menu' ) );
20
+
21
+ add_action( 'admin_enqueue_scripts', array( $this, 'enqueues' ) );
22
+
23
+ add_action( 'site_health_tab_content', array( $this, 'site_health_tab' ) );
24
+ }
25
+
26
+ public function cron_schedules( $schedules ) {
27
+ if ( ! isset( $schedules['weekly'] ) ) {
28
+ $schedules['weekly'] = array(
29
+ 'interval' => 7 * DAY_IN_SECONDS,
30
+ 'display' => __( 'Once weekly', 'health-check' ),
31
+ );
32
+ }
33
+
34
+ return $schedules;
35
+ }
36
+
37
+ /**
38
+ * Enqueue assets.
39
+ *
40
+ * Conditionally enqueue our CSS and JavaScript when viewing plugin related pages in wp-admin.
41
+ *
42
+ * @uses wp_enqueue_style()
43
+ * @uses plugins_url()
44
+ * @uses wp_enqueue_script()
45
+ * @uses wp_localize_script()
46
+ * @uses esc_html__()
47
+ *
48
+ * @return void
49
+ */
50
+ public function enqueues() {
51
+ $screen = get_current_screen();
52
+
53
+ // Don't enqueue anything unless we're on the health check page.
54
+ if ( 'tools_page_site-health' !== $screen->id ) {
55
+ return;
56
+ }
57
+
58
+ wp_enqueue_style( 'health-check', trailingslashit( HEALTH_CHECK_PLUGIN_URL ) . 'build/health-check.css', array(), HEALTH_CHECK_PLUGIN_VERSION );
59
+
60
+ wp_enqueue_script( 'health-check', trailingslashit( HEALTH_CHECK_PLUGIN_URL ) . 'build/health-check.js', array( 'jquery' ), HEALTH_CHECK_PLUGIN_VERSION );
61
+
62
+ wp_localize_script(
63
+ 'health-check',
64
+ 'HealthCheck',
65
+ array(
66
+ 'nonce' => array(
67
+ 'rest_api' => wp_create_nonce( 'wp_rest' ),
68
+ ),
69
+ )
70
+ );
71
+ }
72
+
73
+ /**
74
+ * Add item to the admin menu.
75
+ *
76
+ * @uses add_dashboard_page()
77
+ * @uses __()
78
+ *
79
+ * @return void
80
+ */
81
+ public function action_admin_menu() {
82
+ $critical_issues = 0;
83
+ $issue_counts = get_transient( 'health-check-site-status-result' );
84
+
85
+ if ( false !== $issue_counts ) {
86
+ $issue_counts = json_decode( $issue_counts );
87
+
88
+ $critical_issues = absint( $issue_counts->critical );
89
+ }
90
+
91
+ $critical_count = sprintf(
92
+ '<span class="update-plugins count-%d"><span class="update-count">%s</span></span>',
93
+ esc_attr( $critical_issues ),
94
+ sprintf(
95
+ '%d<span class="screen-reader-text"> %s</span>',
96
+ esc_html( $critical_issues ),
97
+ esc_html_x( 'Critical issues', 'Issue counter label for the admin menu', 'health-check' )
98
+ )
99
+ );
100
+
101
+ $menu_title =
102
+ sprintf(
103
+ // translators: %s: Critical issue counter, if any.
104
+ _x( 'Site Health %s', 'Menu Title', 'health-check' ),
105
+ ( ! $issue_counts || $critical_issues < 1 ? '' : $critical_count )
106
+ );
107
+
108
+ add_submenu_page(
109
+ 'tools.php',
110
+ _x( 'Site Health', 'Page title', 'health-check' ),
111
+ $menu_title,
112
+ 'view_site_health_checks',
113
+ 'site-health',
114
+ array( $this, 'render_menu_page' )
115
+ );
116
+ }
117
+
118
+ public function render_menu_page() {
119
+ require_once HEALTH_CHECK_PLUGIN_DIRECTORY . '/pages/site-health-header.php';
120
+
121
+ $tab = ( isset( $_GET['tab'] ) && ! empty( $_GET['tab'] ) ? $_GET['tab'] : '' );
122
+
123
+ do_action( 'site_health_tab_content', $tab );
124
+ }
125
+
126
+ public function site_health_tab( $tab ) {
127
+ include_once( HEALTH_CHECK_PLUGIN_DIRECTORY . '/pages/site-health-header.php' );
128
+
129
+ switch ( Health_Check::current_tab() ) {
130
+ case 'debug':
131
+ include_once( HEALTH_CHECK_PLUGIN_DIRECTORY . '/pages/debug-data.php' );
132
+ break;
133
+ case 'troubleshoot':
134
+ include_once( HEALTH_CHECK_PLUGIN_DIRECTORY . '/pages/troubleshoot.php' );
135
+ break;
136
+ case 'tools':
137
+ include_once( HEALTH_CHECK_PLUGIN_DIRECTORY . '/pages/tools.php' );
138
+ break;
139
+ case 'site-status':
140
+ default:
141
+ include_once( HEALTH_CHECK_PLUGIN_DIRECTORY . '/pages/site-status.php' );
142
+ }
143
+
144
+ // Close out the div tag opened as a wrapper in the header.
145
+ echo '</div>';
146
+ }
147
+ }
148
+
149
+ new WP_Site_Health();
{includes/tools → HealthCheck/Tools}/class-health-check-files-integrity.php RENAMED
File without changes
{includes/tools → HealthCheck/Tools}/class-health-check-mail-check.php RENAMED
@@ -48,8 +48,8 @@ class Health_Check_Mail_Check extends Health_Check_Tool {
48
  $email_message = sanitize_text_field( $_POST['email_message'] );
49
  $wp_address = get_bloginfo( 'url' );
50
  $wp_name = get_bloginfo( 'name' );
51
- $date = date_i18n( get_option( 'date_format' ), current_time( 'timestamp' ) );
52
- $time = date_i18n( get_option( 'time_format' ), current_time( 'timestamp' ) );
53
 
54
  // translators: %s: website url.
55
  $email_subject = sprintf( esc_html__( 'Health Check – Test Message from %s', 'health-check' ), $wp_address );
48
  $email_message = sanitize_text_field( $_POST['email_message'] );
49
  $wp_address = get_bloginfo( 'url' );
50
  $wp_name = get_bloginfo( 'name' );
51
+ $date = date_i18n( get_option( 'date_format' ), current_time( 'timestamp' ) ); // phpcs:ignore WordPress.DateTime.CurrentTimeTimestamp.Requested
52
+ $time = date_i18n( get_option( 'time_format' ), current_time( 'timestamp' ) ); // phpcs:ignore WordPress.DateTime.CurrentTimeTimestamp.Requested
53
 
54
  // translators: %s: website url.
55
  $email_subject = sprintf( esc_html__( 'Health Check – Test Message from %s', 'health-check' ), $wp_address );
HealthCheck/Tools/class-health-check-phpinfo.php ADDED
@@ -0,0 +1,87 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Provide a means to access extended phpinfo details.
4
+ *
5
+ * @package Health Check
6
+ */
7
+
8
+ // Make sure the file is not directly accessible.
9
+ if ( ! defined( 'ABSPATH' ) ) {
10
+ die( 'We\'re sorry, but you can not directly access this file.' );
11
+ }
12
+
13
+ /**
14
+ * Class PhpInfo
15
+ */
16
+ class Health_Check_Phpinfo extends Health_Check_Tool {
17
+
18
+ public function __construct() {
19
+ $this->label = __( 'PHP Info', 'health-check' );
20
+
21
+ if ( ! function_exists( 'phpinfo' ) ) {
22
+ $this->description = __( 'The phpinfo() function has been disabled by your host. Please contact the host if you need more information about your setup.', 'health-check' );
23
+ } else {
24
+ $this->description = __( 'Some scenarios require you to look up more detailed server configurations than what is normally required. The PHP Info page allows you to view all available configuration options for your PHP setup. Please be advised that WordPress does not guarantee that any information shown on that page may not be considered sensitive.', 'health-check' );
25
+ }
26
+
27
+ add_action( 'site_health_tab_content', array( $this, 'add_site_health_tab_content' ) );
28
+
29
+ parent::__construct();
30
+ }
31
+
32
+ /**
33
+ * Render the PHP Info tab content.
34
+ *
35
+ * @param string $tab The slug of the tab being requested.
36
+ * @return void
37
+ */
38
+ public function add_site_health_tab_content( $tab ) {
39
+ // If the host has disabled `phpinfo()`, do not try to load the page..
40
+ if ( ! function_exists( 'phpinfo' ) ) {
41
+ return;
42
+ }
43
+
44
+ if ( 'phpinfo' === $tab ) {
45
+ include_once( HEALTH_CHECK_PLUGIN_DIRECTORY . '/pages/phpinfo.php' );
46
+ }
47
+ }
48
+
49
+ /**
50
+ * Render the PHP Info tab content.
51
+ *
52
+ * @return void
53
+ */
54
+ public function tab_content() {
55
+ // If the host has disabled `phpinfo()`, do not offer a button alternative.
56
+ if ( ! function_exists( 'phpinfo' ) ) {
57
+ return;
58
+ }
59
+
60
+ $phpinfo_url = add_query_arg( array( 'tab' => 'phpinfo' ), admin_url( 'site-health.php' ) );
61
+ if ( defined( 'HEALTH_CHECK_BACKCOMPAT_LOADED' ) && HEALTH_CHECK_BACKCOMPAT_LOADED ) {
62
+ $phpinfo_url = add_query_arg(
63
+ array(
64
+ 'page' => 'site-health',
65
+ 'tab' => 'phpinfo',
66
+ ),
67
+ admin_url( 'tools.php' )
68
+ );
69
+ }
70
+
71
+ ?>
72
+
73
+ <div class="site-health-view-more">
74
+ <?php
75
+ printf(
76
+ '<a href="%s" class="button button-primary">%s</a>',
77
+ esc_url( $phpinfo_url ),
78
+ __( 'View extended PHP information', 'health-check' )
79
+ );
80
+ ?>
81
+ </div>
82
+
83
+ <?php
84
+ }
85
+ }
86
+
87
+ new Health_Check_Phpinfo();
{includes/tools → HealthCheck/Tools}/class-health-check-plugin-compatibility.php RENAMED
@@ -1,131 +1,155 @@
1
- <?php
2
-
3
- class Health_Check_Plugin_Compatibility extends Health_Check_Tool {
4
-
5
- public function __construct() {
6
- $this->label = __( 'Plugin compatibility', 'health-check' );
7
- $this->description = sprintf(
8
- '%s<br>%s',
9
- __( 'Attempt to identify the compatibility of your plugins before upgrading PHP, note that a compatibility check may not always be accurate, and you may want to contact the plugin author to confirm that things will continue working.', 'health-check' ),
10
- __( 'The compatibility check will need to send requests to the <a href="https://wptide.org">WPTide</a> project to fetch the test results for each of your plugins.', 'health-check' )
11
- );
12
-
13
- add_action( 'wp_ajax_health-check-tools-plugin-compat', array( $this, 'check_plugin_version' ) );
14
-
15
- parent::__construct();
16
- }
17
-
18
- public function tab_content() {
19
- ?>
20
- <table class="wp-list-table widefat fixed striped" id="health-check-tool-plugin-compat-list">
21
- <thead>
22
- <tr>
23
- <th><?php _e( 'Plugin', 'health-check' ); ?></th>
24
- <th><?php _e( 'Version', 'health-check' ); ?></th>
25
- <th><?php _e( 'Minimum PHP', 'health-check' ); ?></th>
26
- <th><?php _e( 'Highest supported PHP', 'health-check' ); ?></th>
27
- </tr>
28
- </thead>
29
-
30
- <tbody>
31
- <?php
32
- $plugins = get_plugins();
33
-
34
- foreach ( $plugins as $slug => $plugin ) {
35
- printf(
36
- '<tr data-plugin-slug="%s" data-plugin-version="%s" data-plugin-checked="false"><td>%s</td><td>%s</td><td>%s</td><td class="supported-version">%s</td></tr>',
37
- esc_attr( $slug ),
38
- esc_attr( $plugin['Version'] ),
39
- $plugin['Name'],
40
- $plugin['Version'],
41
- ( isset( $plugin['RequiresPHP'] ) && ! empty( $plugin['RequiresPHP'] ) ? $plugin['RequiresPHP'] : '&mdash;' ),
42
- '<span class="spinner"></span>'
43
- );
44
- }
45
- ?>
46
- </tbody>
47
- </table>
48
-
49
- <p>
50
- <button type="button" class="button button-primary" id="health-check-tool-plugin-compat">
51
- <?php _e( 'Check plugins', 'health-check' ); ?>
52
- </button>
53
- </p>
54
- <?php
55
- }
56
-
57
- function check_plugin_version() {
58
- check_ajax_referer( 'health-check-tools-plugin-compat' );
59
-
60
- if ( ! current_user_can( 'view_site_health_checks' ) ) {
61
- wp_send_json_error();
62
- }
63
-
64
- $response = array(
65
- 'version' => $this->get_highest_supported_php( $_POST['slug'], $_POST['version'] ),
66
- );
67
-
68
- wp_send_json_success( $response );
69
-
70
- wp_die();
71
- }
72
-
73
- function get_highest_supported_php( $slug, $version ) {
74
- $versions = $this->get_supported_php( $slug, $version );
75
-
76
- if ( empty( $versions ) ) {
77
- return __( 'Could not be determined', 'health-check' );
78
- }
79
-
80
- $highest = 0;
81
-
82
- foreach ( $versions as $version ) {
83
- if ( $highest < $version ) {
84
- $highest = $version;
85
- }
86
- }
87
-
88
- return $highest;
89
- }
90
-
91
- function get_supported_php( $slug, $version ) {
92
- // Clean up the slug, in case it's got more details
93
- if ( stristr( $slug, '/' ) ) {
94
- $parts = explode( '/', $slug );
95
- $slug = $parts[0];
96
- }
97
-
98
- $transient_name = sprintf(
99
- 'health-check-tide-%s-%s',
100
- $slug,
101
- $version
102
- );
103
-
104
- $tide_versions = get_transient( $transient_name );
105
-
106
- if ( false === $tide_versions ) {
107
- $tide_api_respone = wp_remote_get(
108
- sprintf(
109
- 'https://wptide.org/api/tide/v1/audit/wporg/plugin/%s',
110
- $slug
111
- )
112
- );
113
-
114
- $tide_response = wp_remote_retrieve_body( $tide_api_respone );
115
-
116
- $json = json_decode( $tide_response );
117
-
118
- if ( empty( $json ) ) {
119
- $tide_versions = array();
120
- } else {
121
- $tide_versions = $json[0]->reports->phpcs_phpcompatibility->compatible_versions;
122
- }
123
-
124
- set_transient( $transient_name, $tide_versions, 1 * WEEK_IN_SECONDS );
125
- }
126
-
127
- return $tide_versions;
128
- }
129
- }
130
-
131
- new Health_Check_Plugin_Compatibility();
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Health_Check_Plugin_Compatibility extends Health_Check_Tool {
4
+
5
+ public function __construct() {
6
+ $this->label = __( 'Plugin compatibility', 'health-check' );
7
+ $this->description = sprintf(
8
+ '%s<br>%s',
9
+ __( 'Attempt to identify the compatibility of your plugins before upgrading PHP, note that a compatibility check may not always be accurate, and you may want to contact the plugin author to confirm that things will continue working.', 'health-check' ),
10
+ __( 'The compatibility check will need to send requests to the <a href="https://wptide.org">WPTide</a> project to fetch the test results for each of your plugins.', 'health-check' )
11
+ );
12
+
13
+ add_action( 'rest_api_init', array( $this, 'register_plugin_compat_rest_route' ) );
14
+
15
+ parent::__construct();
16
+ }
17
+
18
+ public function register_plugin_compat_rest_route() {
19
+ register_rest_route(
20
+ 'health-check/v1',
21
+ 'plugin-compat',
22
+ array(
23
+ 'methods' => 'POST',
24
+ 'callback' => array( $this, 'check_plugin_version' ),
25
+ 'permission_callback' => function() {
26
+ return current_user_can( 'view_site_health_checks' );
27
+ },
28
+ )
29
+ );
30
+ }
31
+
32
+ public function tab_content() {
33
+ ?>
34
+ <table class="wp-list-table widefat fixed striped" id="health-check-tool-plugin-compat-list">
35
+ <thead>
36
+ <tr>
37
+ <th><?php _e( 'Plugin', 'health-check' ); ?></th>
38
+ <th><?php _e( 'Version', 'health-check' ); ?></th>
39
+ <th><?php _e( 'Minimum PHP', 'health-check' ); ?></th>
40
+ <th><?php _e( 'Highest supported PHP', 'health-check' ); ?></th>
41
+ </tr>
42
+ </thead>
43
+
44
+ <tbody>
45
+ <?php
46
+ $plugins = get_plugins();
47
+
48
+ foreach ( $plugins as $slug => $plugin ) {
49
+ printf(
50
+ '<tr data-plugin-slug="%s" data-plugin-version="%s" data-plugin-checked="false"><td>%s</td><td>%s</td><td>%s</td><td class="supported-version">%s</td></tr>',
51
+ esc_attr( $slug ),
52
+ esc_attr( $plugin['Version'] ),
53
+ $plugin['Name'],
54
+ $plugin['Version'],
55
+ ( isset( $plugin['RequiresPHP'] ) && ! empty( $plugin['RequiresPHP'] ) ? $plugin['RequiresPHP'] : '&mdash;' ),
56
+ '<span class="spinner"></span>'
57
+ );
58
+ }
59
+ ?>
60
+ </tbody>
61
+ </table>
62
+
63
+ <p>
64
+ <button type="button" class="button button-primary" id="health-check-tool-plugin-compat">
65
+ <?php _e( 'Check plugins', 'health-check' ); ?>
66
+ </button>
67
+ </p>
68
+ <?php
69
+ }
70
+
71
+ function check_plugin_version( $request ) {
72
+ if ( ! $request->has_param( 'slug' ) || ! $request->has_param( 'version' ) ) {
73
+ return new WP_Error( 'missing_arg', __( 'The slug, or version, is missing from the request.', 'health-check' ) );
74
+ }
75
+
76
+ $slug = $request->get_param( 'slug' );
77
+ $version = $request->get_param( 'version' );
78
+
79
+ /*
80
+ * Override for the Health Check plugin, which has back-compat code we are aware
81
+ * of and can account for early on. It should not become a habit to add exceptions for
82
+ * plugins in this field, this is rather to avoid confusion and concern in users of this plugin specifically.
83
+ */
84
+ if ( 'health-check/health-check.php' === $slug ) {
85
+ $response = array(
86
+ 'version' => '7.4',
87
+ );
88
+ } else {
89
+ $response = array(
90
+ 'version' => $this->get_highest_supported_php( $slug, $version ),
91
+ );
92
+ }
93
+
94
+ return new WP_REST_Response( $response, 200 );
95
+ }
96
+
97
+ function get_highest_supported_php( $slug, $version ) {
98
+ $versions = $this->get_supported_php( $slug, $version );
99
+
100
+ if ( empty( $versions ) ) {
101
+ return __( 'Could not be determined', 'health-check' );
102
+ }
103
+
104
+ $highest = 0;
105
+
106
+ foreach ( $versions as $version ) {
107
+ if ( $highest < $version ) {
108
+ $highest = $version;
109
+ }
110
+ }
111
+
112
+ return $highest;
113
+ }
114
+
115
+ function get_supported_php( $slug, $version ) {
116
+ // Clean up the slug, in case it's got more details
117
+ if ( stristr( $slug, '/' ) ) {
118
+ $parts = explode( '/', $slug );
119
+ $slug = $parts[0];
120
+ }
121
+
122
+ $transient_name = sprintf(
123
+ 'health-check-tide-%s-%s',
124
+ $slug,
125
+ $version
126
+ );
127
+
128
+ $tide_versions = get_transient( $transient_name );
129
+
130
+ if ( false === $tide_versions ) {
131
+ $tide_api_respone = wp_remote_get(
132
+ sprintf(
133
+ 'https://wptide.org/api/tide/v1/audit/wporg/plugin/%s',
134
+ $slug
135
+ )
136
+ );
137
+
138
+ $tide_response = wp_remote_retrieve_body( $tide_api_respone );
139
+
140
+ $json = json_decode( $tide_response );
141
+
142
+ if ( empty( $json ) ) {
143
+ $tide_versions = array();
144
+ } else {
145
+ $tide_versions = $json[0]->reports->phpcs_phpcompatibility->compatible_versions;
146
+ }
147
+
148
+ set_transient( $transient_name, $tide_versions, 1 * WEEK_IN_SECONDS );
149
+ }
150
+
151
+ return $tide_versions;
152
+ }
153
+ }
154
+
155
+ new Health_Check_Plugin_Compatibility();
{includes/tools → HealthCheck/Tools}/class-health-check-tool.php RENAMED
File without changes
includes/class-health-check-wp-cli.php → HealthCheck/WP_CLI/class-status.php RENAMED
@@ -1,42 +1,16 @@
1
  <?php
2
- /**
3
- * WP-CLI Commands for the Health Check plugin
4
- *
5
- * @package Health Check
6
- */
7
 
8
- use WP_CLI\Utils;
9
 
10
- // Make sure the file is not directly accessible.
11
- if ( ! defined( 'ABSPATH' ) ) {
12
- die( 'We\'re sorry, but you can not directly access this file.' );
13
- }
 
 
 
14
 
15
- /**
16
- * Class Health_Check_WP_CLI
17
- */
18
- class Health_Check_WP_CLI {
19
- /**
20
- * See the sites status based on best practices and WordPress recommendations.
21
- *
22
- * ## EXAMPLES
23
- *
24
- * wp health-check status
25
- *
26
- * ## OPTIONS
27
- *
28
- * [--format=<format>]
29
- * : Render the output in a particular format.
30
- * ---
31
- * default: table
32
- * options:
33
- * - table
34
- * - csv
35
- * - json
36
- * - yaml
37
- * ---
38
- */
39
- public function status( $args, $assoc_args ) {
40
  global $health_check_site_status;
41
 
42
  $all_tests = $health_check_site_status::get_tests();
@@ -62,16 +36,15 @@ class Health_Check_WP_CLI {
62
  );
63
  }
64
 
65
- if ( WP_CLI\Utils\get_flag_value( $assoc_args, 'format' ) === 'json' ) {
66
  WP_CLI\Utils\format_items( 'json', $test_result, array( 'test', 'type', 'result' ) );
67
- } elseif ( WP_CLI\Utils\get_flag_value( $assoc_args, 'format' ) === 'csv' ) {
68
  WP_CLI\Utils\format_items( 'csv', $test_result, array( 'test', 'type', 'result' ) );
69
- } elseif ( WP_CLI\Utils\get_flag_value( $assoc_args, 'format' ) === 'yaml' ) {
70
  WP_CLI\Utils\format_items( 'yaml', $test_result, array( 'test', 'type', 'result' ) );
71
  } else {
72
  WP_CLI\Utils\format_items( 'table', $test_result, array( 'test', 'type', 'result' ) );
73
  }
74
  }
75
- }
76
 
77
- WP_CLI::add_command( 'health-check', 'Health_Check_WP_CLI' );
1
  <?php
 
 
 
 
 
2
 
3
+ namespace HealthCheck\WP_CLI;
4
 
5
+ class Status {
6
+
7
+ private $format;
8
+
9
+ public function __construct( $format ) {
10
+ $this->format = $format;
11
+ }
12
 
13
+ public function run() {
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
14
  global $health_check_site_status;
15
 
16
  $all_tests = $health_check_site_status::get_tests();
36
  );
37
  }
38
 
39
+ if ( 'json' === $this->format ) {
40
  WP_CLI\Utils\format_items( 'json', $test_result, array( 'test', 'type', 'result' ) );
41
+ } elseif ( 'csv' === $this->format ) {
42
  WP_CLI\Utils\format_items( 'csv', $test_result, array( 'test', 'type', 'result' ) );
43
+ } elseif ( 'yaml' === $this->format ) {
44
  WP_CLI\Utils\format_items( 'yaml', $test_result, array( 'test', 'type', 'result' ) );
45
  } else {
46
  WP_CLI\Utils\format_items( 'table', $test_result, array( 'test', 'type', 'result' ) );
47
  }
48
  }
 
49
 
50
+ }
HealthCheck/class-cli.php ADDED
@@ -0,0 +1,50 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * WP-CLI Commands for the Health Check plugin
4
+ *
5
+ * @package Health Check
6
+ */
7
+
8
+ namespace HealthCheck;
9
+
10
+ use HealthCheck\WP_CLI\Status;
11
+ use WP_CLI;
12
+ use WP_CLI\Utils;
13
+
14
+ // Make sure the file is not directly accessible.
15
+ if ( ! defined( 'ABSPATH' ) ) {
16
+ die( 'We\'re sorry, but you can not directly access this file.' );
17
+ }
18
+
19
+ /**
20
+ * Class Health_Check_CLI
21
+ */
22
+ class CLI {
23
+ /**
24
+ * See the sites status based on best practices and WordPress recommendations.
25
+ *
26
+ * ## EXAMPLES
27
+ *
28
+ * wp health-check status
29
+ *
30
+ * ## OPTIONS
31
+ *
32
+ * [--format=<format>]
33
+ * : Render the output in a particular format.
34
+ * ---
35
+ * default: table
36
+ * options:
37
+ * - table
38
+ * - csv
39
+ * - json
40
+ * - yaml
41
+ * ---
42
+ */
43
+ public function status( $args, $assoc_args ) {
44
+ $runner = new Status( WP_CLI\Utils\get_flag_value( $assoc_args, 'format' ) );
45
+
46
+ $runner->run();
47
+ }
48
+ }
49
+
50
+ WP_CLI::add_command( 'health-check', __NAMESPACE__ . '\\CLI' );
{includes → HealthCheck}/class-health-check-loopback.php RENAMED
File without changes
{includes → HealthCheck}/class-health-check-troubleshoot.php RENAMED
@@ -101,7 +101,7 @@ class Health_Check_Troubleshoot {
101
  }
102
 
103
  // Copy the must-use plugin to the local directory.
104
- if ( ! $wp_filesystem->copy( trailingslashit( HEALTH_CHECK_PLUGIN_DIRECTORY ) . 'assets/mu-plugin/health-check-troubleshooting-mode.php', trailingslashit( WPMU_PLUGIN_DIR ) . 'health-check-troubleshooting-mode.php' ) ) {
105
  Health_Check::display_notice( esc_html__( 'We were unable to copy the plugin file required to enable the Troubleshooting Mode.', 'health-check' ), 'error' );
106
  return false;
107
  }
@@ -136,7 +136,7 @@ class Health_Check_Troubleshoot {
136
  return false;
137
  }
138
 
139
- $current = get_plugin_data( trailingslashit( HEALTH_CHECK_PLUGIN_DIRECTORY ) . 'assets/mu-plugin/health-check-troubleshooting-mode.php' );
140
  $active = get_plugin_data( trailingslashit( WPMU_PLUGIN_DIR ) . 'health-check-troubleshooting-mode.php' );
141
 
142
  $current_version = ( isset( $current['Version'] ) ? $current['Version'] : '0.0' );
@@ -145,7 +145,7 @@ class Health_Check_Troubleshoot {
145
  if ( version_compare( $current_version, $active_version, '>' ) ) {
146
  global $wp_filesystem;
147
 
148
- if ( ! $wp_filesystem->copy( trailingslashit( HEALTH_CHECK_PLUGIN_DIRECTORY ) . 'assets/mu-plugin/health-check-troubleshooting-mode.php', trailingslashit( WPMU_PLUGIN_DIR ) . 'health-check-troubleshooting-mode.php', true ) ) {
149
  Health_Check::display_notice( esc_html__( 'We were unable to replace the plugin file required to enable the Troubleshooting Mode.', 'health-check' ), 'error' );
150
  return false;
151
  }
101
  }
102
 
103
  // Copy the must-use plugin to the local directory.
104
+ if ( ! $wp_filesystem->copy( trailingslashit( HEALTH_CHECK_PLUGIN_DIRECTORY ) . 'mu-plugin/health-check-troubleshooting-mode.php', trailingslashit( WPMU_PLUGIN_DIR ) . 'health-check-troubleshooting-mode.php' ) ) {
105
  Health_Check::display_notice( esc_html__( 'We were unable to copy the plugin file required to enable the Troubleshooting Mode.', 'health-check' ), 'error' );
106
  return false;
107
  }
136
  return false;
137
  }
138
 
139
+ $current = get_plugin_data( trailingslashit( HEALTH_CHECK_PLUGIN_DIRECTORY ) . 'mu-plugin/health-check-troubleshooting-mode.php' );
140
  $active = get_plugin_data( trailingslashit( WPMU_PLUGIN_DIR ) . 'health-check-troubleshooting-mode.php' );
141
 
142
  $current_version = ( isset( $current['Version'] ) ? $current['Version'] : '0.0' );
145
  if ( version_compare( $current_version, $active_version, '>' ) ) {
146
  global $wp_filesystem;
147
 
148
+ if ( ! $wp_filesystem->copy( trailingslashit( HEALTH_CHECK_PLUGIN_DIRECTORY ) . 'mu-plugin/health-check-troubleshooting-mode.php', trailingslashit( WPMU_PLUGIN_DIR ) . 'health-check-troubleshooting-mode.php', true ) ) {
149
  Health_Check::display_notice( esc_html__( 'We were unable to replace the plugin file required to enable the Troubleshooting Mode.', 'health-check' ), 'error' );
150
  return false;
151
  }
{includes → HealthCheck}/class-health-check.php RENAMED
@@ -48,8 +48,6 @@ class Health_Check {
48
  public function init() {
49
  add_action( 'plugins_loaded', array( $this, 'load_i18n' ) );
50
 
51
- add_action( 'admin_menu', array( $this, 'action_admin_menu' ) );
52
-
53
  add_filter( 'plugin_action_links', array( $this, 'troubleshoot_plugin_action' ), 20, 4 );
54
  add_filter( 'plugin_action_links_' . plugin_basename( HEALTH_CHECK_PLUGIN_FILE ), array( $this, 'page_plugin_action' ) );
55
 
@@ -63,11 +61,24 @@ class Health_Check {
63
  add_action( 'wp_ajax_health-check-loopback-no-plugins', array( 'Health_Check_Loopback', 'loopback_no_plugins' ) );
64
  add_action( 'wp_ajax_health-check-loopback-individual-plugins', array( 'Health_Check_Loopback', 'loopback_test_individual_plugins' ) );
65
  add_action( 'wp_ajax_health-check-loopback-default-theme', array( 'Health_Check_Loopback', 'loopback_test_default_theme' ) );
66
- add_action( 'wp_ajax_health-check-get-sizes', array( 'Health_Check_Debug_Data', 'ajax_get_sizes' ) );
67
-
68
- add_filter( 'cron_schedules', array( $this, 'cron_schedules' ) );
69
 
70
  add_filter( 'user_has_cap', array( $this, 'maybe_grant_site_health_caps' ), 1, 4 );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
71
  }
72
 
73
  /**
@@ -217,177 +228,43 @@ class Health_Check {
217
  $screen = get_current_screen();
218
 
219
  // Don't enqueue anything unless we're on the health check page.
220
- if ( ( ! isset( $_GET['page'] ) || 'health-check' !== $_GET['page'] ) && 'dashboard' !== $screen->base ) {
221
  return;
222
  }
223
 
224
- $health_check_js_variables = array(
225
- 'string' => array(
226
- 'please_wait' => esc_html__( 'Please wait...', 'health-check' ),
227
- 'copied' => esc_html__( 'Copied', 'health-check' ),
228
- 'running_tests' => esc_html__( 'Currently being tested...', 'health-check' ),
229
- 'site_health_complete' => esc_html__( 'All site health tests have finished running.', 'health-check' ),
230
- 'site_health_complete_pass_sr' => esc_html__( 'All site health tests have finished running. Your site is looking good, and the results are now available on the page.', 'health-check' ),
231
- 'site_health_complete_fail_sr' => esc_html__( 'All site health tests have finished running. There are items that should be addressed, and the results are now available on the page.', 'health-check' ),
232
- 'site_health_complete_pass' => esc_html__( 'Good', 'health-check' ),
233
- 'site_health_complete_fail' => esc_html__( 'Should be improved', 'health-check' ),
234
- 'site_info_copied' => esc_html__( 'Site information has been added to your clipboard.', 'health-check' ),
235
- // translators: %s: Amount of critical issues.
236
- 'site_info_heading_critical_single' => esc_html__( '%s Critical issue', 'health-check' ),
237
- // translators: %s: Amount of critical issues.
238
- 'site_info_heading_critical_plural' => esc_html__( '%s Critical issues', 'health-check' ),
239
- // translators: %s: Amount of recommended issues.
240
- 'site_info_heading_recommended_single' => esc_html__( '%s Recommended improvement', 'health-check' ),
241
- // translators: %s: Amount of recommended issues.
242
- 'site_info_heading_recommended_plural' => esc_html__( '%s Recommended improvements', 'health-check' ),
243
- // translators: %s: Amount of passed tests.
244
- 'site_info_heading_good_single' => esc_html__( '%s Item with no issues detected', 'health-check' ),
245
- // translators: %s: Amount of passed tests.
246
- 'site_info_heading_good_plural' => esc_html__( '%s Items with no issues detected', 'health-check' ),
247
- ),
248
- 'nonce' => array(
249
- 'loopback_no_plugins' => wp_create_nonce( 'health-check-loopback-no-plugins' ),
250
- 'loopback_individual_plugins' => wp_create_nonce( 'health-check-loopback-individual-plugins' ),
251
- 'loopback_default_theme' => wp_create_nonce( 'health-check-loopback-default-theme' ),
252
- 'files_integrity_check' => wp_create_nonce( 'health-check-files-integrity-check' ),
253
- 'view_file_diff' => wp_create_nonce( 'health-check-view-file-diff' ),
254
- 'mail_check' => wp_create_nonce( 'health-check-mail-check' ),
255
- 'site_status' => wp_create_nonce( 'health-check-site-status' ),
256
- 'site_status_result' => wp_create_nonce( 'health-check-site-status-result' ),
257
- 'tools_plugin_compat' => wp_create_nonce( 'health-check-tools-plugin-compat' ),
258
- ),
259
- 'site_status' => array(
260
- 'direct' => array(),
261
- 'async' => array(),
262
- 'issues' => array(
263
- 'good' => 0,
264
- 'recommended' => 0,
265
- 'critical' => 0,
266
- ),
267
- ),
268
- );
269
-
270
- $issue_counts = get_transient( 'health-check-site-status-result' );
271
-
272
- if ( false !== $issue_counts ) {
273
- $issue_counts = json_decode( $issue_counts );
274
-
275
- $health_check_js_variables['site_status']['issues'] = $issue_counts;
276
- }
277
-
278
- if ( 'dashboard' !== $screen->base && ( ! isset( $_GET['tab'] ) || ( isset( $_GET['tab'] ) && 'site-status' === $_GET['tab'] ) ) ) {
279
- $tests = Health_Check_Site_Status::get_tests();
280
 
281
- // Don't run https test on localhost
282
- if ( 'localhost' === preg_replace( '|https?://|', '', get_site_url() ) ) {
283
- unset( $tests['direct']['https_status'] );
284
- }
285
-
286
- foreach ( $tests['direct'] as $test ) {
287
- if ( is_string( $test['test'] ) ) {
288
- $test_function = sprintf(
289
- 'get_test_%s',
290
- $test['test']
291
- );
292
-
293
- if ( method_exists( $this, $test_function ) && is_callable( array( $this, $test_function ) ) ) {
294
- /**
295
- * Filter the output of a finished Site Health test.
296
- *
297
- * @since 5.3.0
298
- *
299
- * @param array $test_result {
300
- * An associated array of test result data.
301
- *
302
- * @param string $label A label describing the test, and is used as a header in the output.
303
- * @param string $status The status of the test, which can be a value of `good`, `recommended` or `critical`.
304
- * @param array $badge {
305
- * Tests are put into categories which have an associated badge shown, these can be modified and assigned here.
306
- *
307
- * @param string $label The test label, for example `Performance`.
308
- * @param string $color Default `blue`. A string representing a color to use for the label.
309
- * }
310
- * @param string $description A more descriptive explanation of what the test looks for, and why it is important for the end user.
311
- * @param string $actions An action to direct the user to where they can resolve the issue, if one exists.
312
- * @param string $test The name of the test being ran, used as a reference point.
313
- * }
314
- */
315
- $health_check_js_variables['site_status']['direct'][] = apply_filters( 'site_status_test_result', call_user_func( array( $this, $test_function ) ) );
316
- continue;
317
- }
318
- }
319
-
320
- if ( is_callable( $test['test'] ) ) {
321
- $health_check_js_variables['site_status']['direct'][] = apply_filters( 'site_status_test_result', call_user_func( $test['test'] ) );
322
- }
323
- }
324
 
325
- foreach ( $tests['async'] as $test ) {
326
- if ( is_string( $test['test'] ) ) {
327
- $health_check_js_variables['site_status']['async'][] = array(
328
- 'test' => $test['test'],
329
- 'completed' => false,
330
- );
331
- }
332
  }
333
  }
334
 
335
- if ( ! wp_script_is( 'clipboard', 'registered' ) ) {
336
- wp_register_script( 'clipboard', trailingslashit( HEALTH_CHECK_PLUGIN_URL ) . 'assets/javascript/clipboard.min.js', array(), '2.0.4' );
337
- }
338
-
339
- wp_enqueue_style( 'health-check', trailingslashit( HEALTH_CHECK_PLUGIN_URL ) . 'assets/css/health-check.css', array(), HEALTH_CHECK_PLUGIN_VERSION );
340
-
341
- wp_enqueue_script( 'health-check', trailingslashit( HEALTH_CHECK_PLUGIN_URL ) . 'assets/javascript/health-check.js', array( 'jquery', 'wp-a11y', 'clipboard', 'wp-util' ), HEALTH_CHECK_PLUGIN_VERSION, true );
342
-
343
- wp_localize_script( 'health-check', 'SiteHealth', $health_check_js_variables );
344
- }
345
 
346
- /**
347
- * Add item to the admin menu.
348
- *
349
- * @uses add_dashboard_page()
350
- * @uses __()
351
- *
352
- * @return void
353
- */
354
- public function action_admin_menu() {
355
- $critical_issues = 0;
356
- $issue_counts = get_transient( 'health-check-site-status-result' );
357
-
358
- if ( false !== $issue_counts ) {
359
- $issue_counts = json_decode( $issue_counts );
360
-
361
- $critical_issues = absint( $issue_counts->critical );
362
- }
363
-
364
- $critical_count = sprintf(
365
- '<span class="update-plugins count-%d"><span class="update-count">%s</span></span>',
366
- esc_attr( $critical_issues ),
367
- sprintf(
368
- '%d<span class="screen-reader-text"> %s</span>',
369
- esc_html( $critical_issues ),
370
- esc_html_x( 'Critical issues', 'Issue counter label for the admin menu', 'health-check' )
371
  )
372
  );
373
-
374
- $menu_title =
375
- sprintf(
376
- // translators: %s: Critical issue counter, if any.
377
- _x( 'Site Health %s', 'Menu Title', 'health-check' ),
378
- ( ! $issue_counts || $critical_issues < 1 ? '' : $critical_count )
379
- );
380
-
381
- remove_submenu_page( 'tools.php', 'site-health.php' );
382
-
383
- add_submenu_page(
384
- 'tools.php',
385
- _x( 'Site Health', 'Page Title', 'health-check' ),
386
- $menu_title,
387
- 'view_site_health_checks',
388
- 'health-check',
389
- array( $this, 'dashboard_page' )
390
- );
391
  }
392
 
393
  /**
@@ -454,50 +331,34 @@ class Health_Check {
454
  return $actions;
455
  }
456
 
457
- /**
458
- * Render our admin page.
459
- *
460
- * @uses _e()
461
- * @uses esc_html__()
462
- * @uses printf()
463
- * @uses sprintf()
464
- * @uses menu_page_url()
465
- * @uses dirname()
466
- *
467
- * @return void
468
- */
469
- public function dashboard_page() {
470
- include_once( HEALTH_CHECK_PLUGIN_DIRECTORY . '/pages/site-health-header.php' );
471
 
472
- switch ( Health_Check::current_tab() ) {
473
- case 'debug':
474
- include_once( HEALTH_CHECK_PLUGIN_DIRECTORY . '/pages/debug-data.php' );
475
- break;
476
- case 'phpinfo':
477
- include_once( HEALTH_CHECK_PLUGIN_DIRECTORY . '/pages/phpinfo.php' );
478
- break;
 
 
 
 
 
479
  case 'troubleshoot':
480
  include_once( HEALTH_CHECK_PLUGIN_DIRECTORY . '/pages/troubleshoot.php' );
481
  break;
482
  case 'tools':
483
  include_once( HEALTH_CHECK_PLUGIN_DIRECTORY . '/pages/tools.php' );
484
  break;
485
- case 'site-status':
486
- default:
487
- include_once( HEALTH_CHECK_PLUGIN_DIRECTORY . '/pages/site-status.php' );
488
  }
489
-
490
- // Close out the div tag opened as a wrapper in the header.
491
- echo '</div>';
492
- }
493
-
494
- static function tabs() {
495
- return array(
496
- 'site-status' => esc_html__( 'Status', 'health-check' ),
497
- 'debug' => esc_html__( 'Info', 'health-check' ),
498
- 'troubleshoot' => esc_html__( 'Troubleshooting', 'health-check' ),
499
- 'tools' => esc_html__( 'Tools', 'health-check' ),
500
- );
501
  }
502
 
503
  static function current_tab() {
@@ -537,18 +398,6 @@ class Health_Check {
537
  }
538
  }
539
 
540
- public function cron_schedules( $schedules ) {
541
- if ( ! isset( $schedules['weekly'] ) ) {
542
- $schedules['weekly'] = array(
543
- 'interval' => 7 * DAY_IN_SECONDS,
544
- 'display' => __( 'Once weekly', 'health-check' ),
545
- );
546
- }
547
-
548
- return $schedules;
549
- }
550
-
551
-
552
  /**
553
  * Conditionally show a form for providing filesystem credentials when introducing our troubleshooting mode plugin.
554
  *
@@ -584,14 +433,4 @@ class Health_Check {
584
 
585
  return true;
586
  }
587
-
588
- public static function plugin_activation() {
589
- if ( ! wp_next_scheduled( 'health-check-scheduled-site-status-check' ) ) {
590
- wp_schedule_event( time(), 'weekly', 'health-check-scheduled-site-status-check' );
591
- }
592
- }
593
-
594
- public static function plugin_deactivation() {
595
- wp_clear_scheduled_hook( 'health-check-scheduled-site-status-check' );
596
- }
597
  }
48
  public function init() {
49
  add_action( 'plugins_loaded', array( $this, 'load_i18n' ) );
50
 
 
 
51
  add_filter( 'plugin_action_links', array( $this, 'troubleshoot_plugin_action' ), 20, 4 );
52
  add_filter( 'plugin_action_links_' . plugin_basename( HEALTH_CHECK_PLUGIN_FILE ), array( $this, 'page_plugin_action' ) );
53
 
61
  add_action( 'wp_ajax_health-check-loopback-no-plugins', array( 'Health_Check_Loopback', 'loopback_no_plugins' ) );
62
  add_action( 'wp_ajax_health-check-loopback-individual-plugins', array( 'Health_Check_Loopback', 'loopback_test_individual_plugins' ) );
63
  add_action( 'wp_ajax_health-check-loopback-default-theme', array( 'Health_Check_Loopback', 'loopback_test_default_theme' ) );
 
 
 
64
 
65
  add_filter( 'user_has_cap', array( $this, 'maybe_grant_site_health_caps' ), 1, 4 );
66
+
67
+ add_filter( 'site_health_navigation_tabs', array( $this, 'add_site_health_navigation_tabs' ) );
68
+ add_action( 'site_health_tab_content', array( $this, 'add_site_health_tab_content' ) );
69
+
70
+ add_action( 'init', array( $this, 'maybe_remove_old_scheduled_events' ) );
71
+ }
72
+
73
+ /**
74
+ * Disable scheduled events previously used by the plugin, but now part of WordPress core.
75
+ *
76
+ * @return void
77
+ */
78
+ public function maybe_remove_old_scheduled_events() {
79
+ if ( wp_next_scheduled( 'health-check-scheduled-site-status-check' ) ) {
80
+ wp_clear_scheduled_hook( 'health-check-scheduled-site-status-check' );
81
+ }
82
  }
83
 
84
  /**
228
  $screen = get_current_screen();
229
 
230
  // Don't enqueue anything unless we're on the health check page.
231
+ if ( 'tools_page_site-health' !== $screen->id && 'site-health' !== $screen->id ) {
232
  return;
233
  }
234
 
235
+ wp_enqueue_style( 'health-check', trailingslashit( HEALTH_CHECK_PLUGIN_URL ) . 'build/health-check.css', array(), HEALTH_CHECK_PLUGIN_VERSION );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
236
 
237
+ // If the WordPress 5.2+ version of Site Health is used, do some extra checks to not mess with core scripts and styles.
238
+ if ( 'site-health' === $screen->id ) {
239
+ $plugin_tabs = array(
240
+ 'tools',
241
+ 'troubleshoot',
242
+ );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
243
 
244
+ if ( ! isset( $_GET['tab'] ) || ! in_array( $_GET['tab'], $plugin_tabs, true ) ) {
245
+ return;
 
 
 
 
 
246
  }
247
  }
248
 
249
+ wp_enqueue_script( 'health-check-tools', trailingslashit( HEALTH_CHECK_PLUGIN_URL ) . 'build/health-check-tools.js', array( 'jquery' ), HEALTH_CHECK_PLUGIN_VERSION );
 
 
 
 
 
 
 
 
 
250
 
251
+ wp_localize_script(
252
+ 'health-check-tools',
253
+ 'HealthCheck',
254
+ array(
255
+ 'rest_api' => array(
256
+ 'tools' => array(
257
+ 'plugin_compat' => rest_url( 'health-check/v1/plugin-compat' ),
258
+ ),
259
+ ),
260
+ 'nonce' => array(
261
+ 'rest_api' => wp_create_nonce( 'wp_rest' ),
262
+ 'files_integrity_check' => wp_create_nonce( 'health-check-files-integrity-check' ),
263
+ 'view_file_diff' => wp_create_nonce( 'health-check-view-file-diff' ),
264
+ 'mail_check' => wp_create_nonce( 'health-check-mail-check' ),
265
+ ),
 
 
 
 
 
 
 
 
 
 
266
  )
267
  );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
268
  }
269
 
270
  /**
331
  return $actions;
332
  }
333
 
334
+ static function tabs() {
335
+ return array(
336
+ '' => esc_html__( 'Status', 'health-check' ), // The status tab is the front page, and therefore has no tab key relation.
337
+ 'debug' => esc_html__( 'Info', 'health-check' ),
338
+ 'troubleshoot' => esc_html__( 'Troubleshooting', 'health-check' ),
339
+ 'tools' => esc_html__( 'Tools', 'health-check' ),
340
+ );
341
+ }
 
 
 
 
 
 
342
 
343
+ public function add_site_health_navigation_tabs( $tabs ) {
344
+ return array_merge(
345
+ $tabs,
346
+ array(
347
+ 'troubleshoot' => esc_html__( 'Troubleshooting', 'health-check' ),
348
+ 'tools' => esc_html__( 'Tools', 'health-check' ),
349
+ )
350
+ );
351
+ }
352
+
353
+ public function add_site_health_tab_content( $tab ) {
354
+ switch ( $tab ) {
355
  case 'troubleshoot':
356
  include_once( HEALTH_CHECK_PLUGIN_DIRECTORY . '/pages/troubleshoot.php' );
357
  break;
358
  case 'tools':
359
  include_once( HEALTH_CHECK_PLUGIN_DIRECTORY . '/pages/tools.php' );
360
  break;
 
 
 
361
  }
 
 
 
 
 
 
 
 
 
 
 
 
362
  }
363
 
364
  static function current_tab() {
398
  }
399
  }
400
 
 
 
 
 
 
 
 
 
 
 
 
 
401
  /**
402
  * Conditionally show a form for providing filesystem credentials when introducing our troubleshooting mode plugin.
403
  *
433
 
434
  return true;
435
  }
 
 
 
 
 
 
 
 
 
 
436
  }
LICENSE ADDED
@@ -0,0 +1,339 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ GNU GENERAL PUBLIC LICENSE
2
+ Version 2, June 1991
3
+
4
+ Copyright (C) 1989, 1991 Free Software Foundation, Inc.,
5
+ 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
6
+ Everyone is permitted to copy and distribute verbatim copies
7
+ of this license document, but changing it is not allowed.
8
+
9
+ Preamble
10
+
11
+ The licenses for most software are designed to take away your
12
+ freedom to share and change it. By contrast, the GNU General Public
13
+ License is intended to guarantee your freedom to share and change free
14
+ software--to make sure the software is free for all its users. This
15
+ General Public License applies to most of the Free Software
16
+ Foundation's software and to any other program whose authors commit to
17
+ using it. (Some other Free Software Foundation software is covered by
18
+ the GNU Lesser General Public License instead.) You can apply it to
19
+ your programs, too.
20
+
21
+ When we speak of free software, we are referring to freedom, not
22
+ price. Our General Public Licenses are designed to make sure that you
23
+ have the freedom to distribute copies of free software (and charge for
24
+ this service if you wish), that you receive source code or can get it
25
+ if you want it, that you can change the software or use pieces of it
26
+ in new free programs; and that you know you can do these things.
27
+
28
+ To protect your rights, we need to make restrictions that forbid
29
+ anyone to deny you these rights or to ask you to surrender the rights.
30
+ These restrictions translate to certain responsibilities for you if you
31
+ distribute copies of the software, or if you modify it.
32
+
33
+ For example, if you distribute copies of such a program, whether
34
+ gratis or for a fee, you must give the recipients all the rights that
35
+ you have. You must make sure that they, too, receive or can get the
36
+ source code. And you must show them these terms so they know their
37
+ rights.
38
+
39
+ We protect your rights with two steps: (1) copyright the software, and
40
+ (2) offer you this license which gives you legal permission to copy,
41
+ distribute and/or modify the software.
42
+
43
+ Also, for each author's protection and ours, we want to make certain
44
+ that everyone understands that there is no warranty for this free
45
+ software. If the software is modified by someone else and passed on, we
46
+ want its recipients to know that what they have is not the original, so
47
+ that any problems introduced by others will not reflect on the original
48
+ authors' reputations.
49
+
50
+ Finally, any free program is threatened constantly by software
51
+ patents. We wish to avoid the danger that redistributors of a free
52
+ program will individually obtain patent licenses, in effect making the
53
+ program proprietary. To prevent this, we have made it clear that any
54
+ patent must be licensed for everyone's free use or not licensed at all.
55
+
56
+ The precise terms and conditions for copying, distribution and
57
+ modification follow.
58
+
59
+ GNU GENERAL PUBLIC LICENSE
60
+ TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
61
+
62
+ 0. This License applies to any program or other work which contains
63
+ a notice placed by the copyright holder saying it may be distributed
64
+ under the terms of this General Public License. The "Program", below,
65
+ refers to any such program or work, and a "work based on the Program"
66
+ means either the Program or any derivative work under copyright law:
67
+ that is to say, a work containing the Program or a portion of it,
68
+ either verbatim or with modifications and/or translated into another
69
+ language. (Hereinafter, translation is included without limitation in
70
+ the term "modification".) Each licensee is addressed as "you".
71
+
72
+ Activities other than copying, distribution and modification are not
73
+ covered by this License; they are outside its scope. The act of
74
+ running the Program is not restricted, and the output from the Program
75
+ is covered only if its contents constitute a work based on the
76
+ Program (independent of having been made by running the Program).
77
+ Whether that is true depends on what the Program does.
78
+
79
+ 1. You may copy and distribute verbatim copies of the Program's
80
+ source code as you receive it, in any medium, provided that you
81
+ conspicuously and appropriately publish on each copy an appropriate
82
+ copyright notice and disclaimer of warranty; keep intact all the
83
+ notices that refer to this License and to the absence of any warranty;
84
+ and give any other recipients of the Program a copy of this License
85
+ along with the Program.
86
+
87
+ You may charge a fee for the physical act of transferring a copy, and
88
+ you may at your option offer warranty protection in exchange for a fee.
89
+
90
+ 2. You may modify your copy or copies of the Program or any portion
91
+ of it, thus forming a work based on the Program, and copy and
92
+ distribute such modifications or work under the terms of Section 1
93
+ above, provided that you also meet all of these conditions:
94
+
95
+ a) You must cause the modified files to carry prominent notices
96
+ stating that you changed the files and the date of any change.
97
+
98
+ b) You must cause any work that you distribute or publish, that in
99
+ whole or in part contains or is derived from the Program or any
100
+ part thereof, to be licensed as a whole at no charge to all third
101
+ parties under the terms of this License.
102
+
103
+ c) If the modified program normally reads commands interactively
104
+ when run, you must cause it, when started running for such
105
+ interactive use in the most ordinary way, to print or display an
106
+ announcement including an appropriate copyright notice and a
107
+ notice that there is no warranty (or else, saying that you provide
108
+ a warranty) and that users may redistribute the program under
109
+ these conditions, and telling the user how to view a copy of this
110
+ License. (Exception: if the Program itself is interactive but
111
+ does not normally print such an announcement, your work based on
112
+ the Program is not required to print an announcement.)
113
+
114
+ These requirements apply to the modified work as a whole. If
115
+ identifiable sections of that work are not derived from the Program,
116
+ and can be reasonably considered independent and separate works in
117
+ themselves, then this License, and its terms, do not apply to those
118
+ sections when you distribute them as separate works. But when you
119
+ distribute the same sections as part of a whole which is a work based
120
+ on the Program, the distribution of the whole must be on the terms of
121
+ this License, whose permissions for other licensees extend to the
122
+ entire whole, and thus to each and every part regardless of who wrote it.
123
+
124
+ Thus, it is not the intent of this section to claim rights or contest
125
+ your rights to work written entirely by you; rather, the intent is to
126
+ exercise the right to control the distribution of derivative or
127
+ collective works based on the Program.
128
+
129
+ In addition, mere aggregation of another work not based on the Program
130
+ with the Program (or with a work based on the Program) on a volume of
131
+ a storage or distribution medium does not bring the other work under
132
+ the scope of this License.
133
+
134
+ 3. You may copy and distribute the Program (or a work based on it,
135
+ under Section 2) in object code or executable form under the terms of
136
+ Sections 1 and 2 above provided that you also do one of the following:
137
+
138
+ a) Accompany it with the complete corresponding machine-readable
139
+ source code, which must be distributed under the terms of Sections
140
+ 1 and 2 above on a medium customarily used for software interchange; or,
141
+
142
+ b) Accompany it with a written offer, valid for at least three
143
+ years, to give any third party, for a charge no more than your
144
+ cost of physically performing source distribution, a complete
145
+ machine-readable copy of the corresponding source code, to be
146
+ distributed under the terms of Sections 1 and 2 above on a medium
147
+ customarily used for software interchange; or,
148
+
149
+ c) Accompany it with the information you received as to the offer
150
+ to distribute corresponding source code. (This alternative is
151
+ allowed only for noncommercial distribution and only if you
152
+ received the program in object code or executable form with such
153
+ an offer, in accord with Subsection b above.)
154
+
155
+ The source code for a work means the preferred form of the work for
156
+ making modifications to it. For an executable work, complete source
157
+ code means all the source code for all modules it contains, plus any
158
+ associated interface definition files, plus the scripts used to
159
+ control compilation and installation of the executable. However, as a
160
+ special exception, the source code distributed need not include
161
+ anything that is normally distributed (in either source or binary
162
+ form) with the major components (compiler, kernel, and so on) of the
163
+ operating system on which the executable runs, unless that component
164
+ itself accompanies the executable.
165
+
166
+ If distribution of executable or object code is made by offering
167
+ access to copy from a designated place, then offering equivalent
168
+ access to copy the source code from the same place counts as
169
+ distribution of the source code, even though third parties are not
170
+ compelled to copy the source along with the object code.
171
+
172
+ 4. You may not copy, modify, sublicense, or distribute the Program
173
+ except as expressly provided under this License. Any attempt
174
+ otherwise to copy, modify, sublicense or distribute the Program is
175
+ void, and will automatically terminate your rights under this License.
176
+ However, parties who have received copies, or rights, from you under
177
+ this License will not have their licenses terminated so long as such
178
+ parties remain in full compliance.
179
+
180
+ 5. You are not required to accept this License, since you have not
181
+ signed it. However, nothing else grants you permission to modify or
182
+ distribute the Program or its derivative works. These actions are
183
+ prohibited by law if you do not accept this License. Therefore, by
184
+ modifying or distributing the Program (or any work based on the
185
+ Program), you indicate your acceptance of this License to do so, and
186
+ all its terms and conditions for copying, distributing or modifying
187
+ the Program or works based on it.
188
+
189
+ 6. Each time you redistribute the Program (or any work based on the
190
+ Program), the recipient automatically receives a license from the
191
+ original licensor to copy, distribute or modify the Program subject to
192
+ these terms and conditions. You may not impose any further
193
+ restrictions on the recipients' exercise of the rights granted herein.
194
+ You are not responsible for enforcing compliance by third parties to
195
+ this License.
196
+
197
+ 7. If, as a consequence of a court judgment or allegation of patent
198
+ infringement or for any other reason (not limited to patent issues),
199
+ conditions are imposed on you (whether by court order, agreement or
200
+ otherwise) that contradict the conditions of this License, they do not
201
+ excuse you from the conditions of this License. If you cannot
202
+ distribute so as to satisfy simultaneously your obligations under this
203
+ License and any other pertinent obligations, then as a consequence you
204
+ may not distribute the Program at all. For example, if a patent
205
+ license would not permit royalty-free redistribution of the Program by
206
+ all those who receive copies directly or indirectly through you, then
207
+ the only way you could satisfy both it and this License would be to
208
+ refrain entirely from distribution of the Program.
209
+
210
+ If any portion of this section is held invalid or unenforceable under
211
+ any particular circumstance, the balance of the section is intended to
212
+ apply and the section as a whole is intended to apply in other
213
+ circumstances.
214
+
215
+ It is not the purpose of this section to induce you to infringe any
216
+ patents or other property right claims or to contest validity of any
217
+ such claims; this section has the sole purpose of protecting the
218
+ integrity of the free software distribution system, which is
219
+ implemented by public license practices. Many people have made
220
+ generous contributions to the wide range of software distributed
221
+ through that system in reliance on consistent application of that
222
+ system; it is up to the author/donor to decide if he or she is willing
223
+ to distribute software through any other system and a licensee cannot
224
+ impose that choice.
225
+
226
+ This section is intended to make thoroughly clear what is believed to
227
+ be a consequence of the rest of this License.
228
+
229
+ 8. If the distribution and/or use of the Program is restricted in
230
+ certain countries either by patents or by copyrighted interfaces, the
231
+ original copyright holder who places the Program under this License
232
+ may add an explicit geographical distribution limitation excluding
233
+ those countries, so that distribution is permitted only in or among
234
+ countries not thus excluded. In such case, this License incorporates
235
+ the limitation as if written in the body of this License.
236
+
237
+ 9. The Free Software Foundation may publish revised and/or new versions
238
+ of the General Public License from time to time. Such new versions will
239
+ be similar in spirit to the present version, but may differ in detail to
240
+ address new problems or concerns.
241
+
242
+ Each version is given a distinguishing version number. If the Program
243
+ specifies a version number of this License which applies to it and "any
244
+ later version", you have the option of following the terms and conditions
245
+ either of that version or of any later version published by the Free
246
+ Software Foundation. If the Program does not specify a version number of
247
+ this License, you may choose any version ever published by the Free Software
248
+ Foundation.
249
+
250
+ 10. If you wish to incorporate parts of the Program into other free
251
+ programs whose distribution conditions are different, write to the author
252
+ to ask for permission. For software which is copyrighted by the Free
253
+ Software Foundation, write to the Free Software Foundation; we sometimes
254
+ make exceptions for this. Our decision will be guided by the two goals
255
+ of preserving the free status of all derivatives of our free software and
256
+ of promoting the sharing and reuse of software generally.
257
+
258
+ NO WARRANTY
259
+
260
+ 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
261
+ FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN
262
+ OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
263
+ PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED
264
+ OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
265
+ MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS
266
+ TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE
267
+ PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,
268
+ REPAIR OR CORRECTION.
269
+
270
+ 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
271
+ WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
272
+ REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,
273
+ INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING
274
+ OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED
275
+ TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY
276
+ YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
277
+ PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
278
+ POSSIBILITY OF SUCH DAMAGES.
279
+
280
+ END OF TERMS AND CONDITIONS
281
+
282
+ How to Apply These Terms to Your New Programs
283
+
284
+ If you develop a new program, and you want it to be of the greatest
285
+ possible use to the public, the best way to achieve this is to make it
286
+ free software which everyone can redistribute and change under these terms.
287
+
288
+ To do so, attach the following notices to the program. It is safest
289
+ to attach them to the start of each source file to most effectively
290
+ convey the exclusion of warranty; and each file should have at least
291
+ the "copyright" line and a pointer to where the full notice is found.
292
+
293
+ <one line to give the program's name and a brief idea of what it does.>
294
+ Copyright (C) <year> <name of author>
295
+
296
+ This program is free software; you can redistribute it and/or modify
297
+ it under the terms of the GNU General Public License as published by
298
+ the Free Software Foundation; either version 2 of the License, or
299
+ (at your option) any later version.
300
+
301
+ This program is distributed in the hope that it will be useful,
302
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
303
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
304
+ GNU General Public License for more details.
305
+
306
+ You should have received a copy of the GNU General Public License along
307
+ with this program; if not, write to the Free Software Foundation, Inc.,
308
+ 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
309
+
310
+ Also add information on how to contact you by electronic and paper mail.
311
+
312
+ If the program is interactive, make it output a short notice like this
313
+ when it starts in an interactive mode:
314
+
315
+ Gnomovision version 69, Copyright (C) year name of author
316
+ Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
317
+ This is free software, and you are welcome to redistribute it
318
+ under certain conditions; type `show c' for details.
319
+
320
+ The hypothetical commands `show w' and `show c' should show the appropriate
321
+ parts of the General Public License. Of course, the commands you use may
322
+ be called something other than `show w' and `show c'; they could even be
323
+ mouse-clicks or menu items--whatever suits your program.
324
+
325
+ You should also get your employer (if you work as a programmer) or your
326
+ school, if any, to sign a "copyright disclaimer" for the program, if
327
+ necessary. Here is a sample; alter the names:
328
+
329
+ Yoyodyne, Inc., hereby disclaims all copyright interest in the program
330
+ `Gnomovision' (which makes passes at compilers) written by James Hacker.
331
+
332
+ <signature of Ty Coon>, 1 April 1989
333
+ Ty Coon, President of Vice
334
+
335
+ This General Public License does not permit incorporating your program into
336
+ proprietary programs. If your program is a subroutine library, you may
337
+ consider it more useful to permit linking proprietary applications with the
338
+ library. If this is what you want to do, use the GNU Lesser General
339
+ Public License instead of this License.
README.md ADDED
@@ -0,0 +1,28 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Health Check
2
+
3
+ ![Build Status](https://github.com/WordPress/health-check/workflows/Build%20Status/badge.svg)
4
+
5
+ Health Check is a WordPress plugin that will perform a number of checks on your WordPress install to detect common configuration errors and known issues.
6
+
7
+ 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.
8
+
9
+ The debug section, which allows you to gather information about your WordPress and server configuration that you may easily share with support representatives for themes, plugins or on the official WordPress.org support forums.
10
+
11
+ Troubleshooting allows you to have a vanilla WordPress session, where all plugins are disabled, and a default theme is used, but only for your user.
12
+
13
+ For a more extensive example of how to efficiently use the Health Check plugin, check out the [WordPress.org support team handbook page about this plugin](https://make.wordpress.org/support/handbook/appendix/troubleshooting-using-the-health-check/).
14
+
15
+ In the future we may introduce more checks, and welcome feedback both through the [WordPress.org forums](https://wordpress.org/support/plugin/health-check), and the [GitHub project page](https://github.com/WordPress/health-check).
16
+
17
+ ## Installation
18
+
19
+ 1. Upload to your plugins folder, usually `wp-content/plugins/`
20
+ 2. Activate the plugin on the plugin screen.
21
+ 3. Once activated the plugin will appear under your `Dashboard` menu.
22
+
23
+ ## Contributing
24
+
25
+ Contributions are more than welcome, both through issues, and pull requests. Ideas and thoughts may also be discussed in the [#core-site-health](https://wordpress.slack.com/messages/core-site-health/) channel
26
+ on the [Making WordPress Slack](https://make.wordpress.org/chat) team.
27
+
28
+ For further information about contributing, see our [guide on contributing](https://github.com/WordPress/health-check/blob/master/.github/CONTRIBUTING.md).
assets/css/health-check.css DELETED
@@ -1,2 +0,0 @@
1
- body.tools_page_health-check #wpcontent{padding-left:0}body.tools_page_health-check .notice{margin:5px 20px 15px 22px}body.tools_page_health-check .update-nag{margin-bottom:20px;margin-left:22px}body.tools_page_health-check h2{padding:1rem 0;line-height:1.4}body.tools_page_health-check .wrap{margin-right:0;margin-left:0}body.tools_page_health-check .wrap h2{padding:1rem 0.5rem;font-size:1.3rem;font-weight:600;font-family:inherit}@media all and (min-width: 960px){body.tools_page_health-check .wrap h2{padding:1rem 0}}body.tools_page_health-check ul li,body.tools_page_health-check ol li{font-size:13px;line-height:1.5}body.tools_page_health-check .wp-core-ui .button{font-size:13px}body.tools_page_health-check .health-check-header{text-align:center;margin:0 0 1rem;background:#fff;border-bottom:1px solid #e2e4e7}body.tools_page_health-check .health-check-header .health-check-tabs-wrapper{display:-ms-inline-grid;-ms-grid-columns:1fr 1fr 1fr 1fr;vertical-align:top;display:inline-grid;grid-template-columns:1fr 1fr 1fr 1fr}body.tools_page_health-check .health-check-header .health-check-tabs-wrapper .health-check-tab{display:block;text-decoration:none;color:inherit;padding:0.5rem 1rem 1rem;margin:0 1rem;transition:box-shadow 0.5s ease-in-out}body.tools_page_health-check .health-check-header .health-check-tabs-wrapper .health-check-tab:nth-child(1){-ms-grid-column:1}body.tools_page_health-check .health-check-header .health-check-tabs-wrapper .health-check-tab:nth-child(2){-ms-grid-column:2}body.tools_page_health-check .health-check-header .health-check-tabs-wrapper .health-check-tab:nth-child(3){-ms-grid-column:3}body.tools_page_health-check .health-check-header .health-check-tabs-wrapper .health-check-tab:nth-child(4){-ms-grid-column:4}body.tools_page_health-check .health-check-header .health-check-tabs-wrapper .health-check-tab.active{box-shadow:inset 0 -3px #007cba;font-weight:600}body.tools_page_health-check .health-check-header .health-check-tabs-wrapper .health-check-tab:focus{color:#191e23;outline:1px solid #6c7781;box-shadow:none}body.tools_page_health-check .health-check-body{max-width:800px;margin:0 auto}body.tools_page_health-check .health-check-table{table-layout:fixed}body.tools_page_health-check .health-check-table thead th,body.tools_page_health-check .health-check-table thead td{font-size:13px}body.tools_page_health-check .health-check-table thead th:first-child,body.tools_page_health-check .health-check-table thead td:first-child{width:30%}body.tools_page_health-check .health-check-table tbody td{width:100%;box-sizing:border-box;display:block;font-size:13px;word-wrap:break-word}body.tools_page_health-check .health-check-table tbody td:first-child{width:100%;padding-bottom:0;font-weight:600}body.tools_page_health-check .health-check-table tbody td ul,body.tools_page_health-check .health-check-table tbody td ol{margin:0}body.tools_page_health-check .pass::before,body.tools_page_health-check .good::before{content:"\f147";display:inline-block;color:#46b450;font-family:dashicons}body.tools_page_health-check .warning::before{content:"\f460";display:inline-block;color:#ffb900;font-family:dashicons}body.tools_page_health-check .info::before{content:"\f348";display:inline-block;color:#00a0d2;font-family:dashicons}body.tools_page_health-check .fail::before,body.tools_page_health-check .error::before{content:"\f335";display:inline-block;color:#dc3232;font-family:dashicons}body.tools_page_health-check .spinner{float:none}body.tools_page_health-check .site-health-copy-buttons{display:block;margin:1rem 0}body.tools_page_health-check .site-health-copy-buttons .copy-button-wrapper{margin:0.5rem 0 1rem}body.tools_page_health-check .site-health-copy-buttons .success{display:none;color:#40860a;height:28px;line-height:2.2;margin-left:0.5rem}body.tools_page_health-check .site-health-copy-buttons .success.visible{display:inline-block}body.tools_page_health-check #health-check-debug{margin-bottom:3rem}body.tools_page_health-check .health-check-wp-paths-sizes.spinner{position:absolute;visibility:visible;float:none;margin:0 4px}body.tools_page_health-check .file-integrity-table thead th:first-child,body.tools_page_health-check .file-integrity-table thead td:first-child,body.tools_page_health-check .file-integrity-table tbody th:first-child,body.tools_page_health-check .file-integrity-table tbody td:first-child,body.tools_page_health-check .file-integrity-table tfoot th:first-child,body.tools_page_health-check .file-integrity-table tfoot td:first-child{text-align:center;width:60px}body.tools_page_health-check .tools-email-table{border:0;box-shadow:none}body.tools_page_health-check .tools-email-table td:first-child{width:280px}@media (max-width: 768px){body.tools_page_health-check .tools-email-table td{display:block}}body.tools_page_health-check .tools-email-table input{width:100%}body.tools_page_health-check .tools-email-table label{display:block;clear:both}body.tools_page_health-check #health-check-mail-check,body.tools_page_health-check #health-check-file-integrity{margin-bottom:15px}body.tools_page_health-check #health-check-diff-modal{width:100vw;height:100%;position:fixed;top:0;left:0;background:rgba(0,0,0,0.7);display:none;z-index:99999}body.tools_page_health-check #health-check-diff-modal #health-check-diff-modal-content{background:#fff;height:calc(100% - 120px);width:calc(100% - 120px);margin-top:40px;margin-left:40px;padding:20px;display:block}body.tools_page_health-check #health-check-diff-modal #health-check-diff-modal-diff{width:100%;height:calc(100% - 80px);overflow-y:auto;display:block;position:relative}body.tools_page_health-check #health-check-diff-modal #health-check-diff-modal-diff table.diff td:nth-child(2){background:#f3f3f3}body.tools_page_health-check #health-check-diff-modal-close-ref{position:relative;display:block;float:right;color:#000;text-decoration:none}body.tools_page_health-check .site-health-issues-wrapper{margin-bottom:3rem;margin-top:2rem}body.tools_page_health-check .site-health-issues-wrapper:first-of-type{margin-top:3rem}body.tools_page_health-check .site-status-has-issues{display:block}body.tools_page_health-check .site-status-has-issues.hide{display:none}body.tools_page_health-check h3{padding:0;font-weight:400}body.tools_page_health-check .site-health-view-more{text-align:center}body.tools_page_health-check .issues-wrapper{margin-bottom:5rem}body.tools_page_health-check .site-status-all-clear{display:flex;flex-direction:column;align-items:center;justify-content:center;text-align:center;height:100%;width:100%;margin-top:0}@media all and (min-width: 784px){body.tools_page_health-check .site-status-all-clear{margin:5rem 0}}body.tools_page_health-check .site-status-all-clear.hide{display:none}body.tools_page_health-check .site-status-all-clear .dashicons{font-size:150px;height:130px;width:150px}body.tools_page_health-check .site-status-all-clear .encouragement{font-family:inherit;font-size:1.5rem;font-weight:600}body.tools_page_health-check .site-status-all-clear p{margin:0}body.tools_page_health-check .site-health-view-passed{position:relative;padding-right:40px;padding-left:20px}body.tools_page_health-check .site-health-view-passed .icon{border:solid #555d66;border-width:0 2px 2px 0;height:0.5rem;pointer-events:none;position:absolute;right:1.5em;top:50%;transform:translateY(-70%) rotate(45deg);width:0.5rem}body.tools_page_health-check .site-health-view-passed[aria-expanded="true"] .icon{transform:translateY(-30%) rotate(-135deg)}body .health-check-accordion{border:1px solid #e2e4e7}body .health-check-accordion .health-check-accordion-heading{margin:0;border-top:1px solid #e2e4e7;font-size:inherit;line-height:inherit;font-weight:600;color:inherit}body .health-check-accordion .health-check-accordion-heading:first-child{border-top:none}body .health-check-accordion .health-check-accordion-trigger{background:#fff;border:0;color:#32373c;cursor:pointer;display:block;font-weight:400;margin:0;padding:1em 3.5em 1em 1.5em;position:relative;text-align:left;width:100%}body .health-check-accordion .health-check-accordion-trigger:hover,body .health-check-accordion .health-check-accordion-trigger:active{background:#f8f9f9}body .health-check-accordion .health-check-accordion-trigger:focus{color:#191e23;border:none;box-shadow:none;outline-offset:-2px;outline:1px dotted #555d66}body .health-check-accordion .health-check-accordion-trigger .title{display:inline-block;pointer-events:none;font-weight:600}body .health-check-accordion .health-check-accordion-trigger .icon{border:solid #555d66;border-width:0 2px 2px 0;height:0.5rem;pointer-events:none;position:absolute;right:1.5em;top:50%;transform:translateY(-70%) rotate(45deg);width:0.5rem}body .health-check-accordion .health-check-accordion-trigger .badge{float:right;padding:0.1rem 0.5rem 0.15rem;color:#32373c;font-weight:600;margin-left:0.5rem}body .health-check-accordion .health-check-accordion-trigger .badge.blue{border:1px solid #bfe7f3}body .health-check-accordion .health-check-accordion-trigger .badge.orange{border:1px solid #ffb900}body .health-check-accordion .health-check-accordion-trigger .badge.red{border:1px solid #dc3232}body .health-check-accordion .health-check-accordion-trigger .badge.green{border:1px solid #46b450}body .health-check-accordion .health-check-accordion-trigger .badge.purple{border:1px solid #826eb4}body .health-check-accordion .health-check-accordion-trigger .badge.gray{border:1px solid #ccd0d4}body .health-check-accordion .health-check-accordion-trigger[aria-expanded="true"] .icon{transform:translateY(-30%) rotate(-135deg)}body .health-check-accordion .health-check-accordion-panel{margin:0;padding:1em 1.5em;background:#fff}body .health-check-accordion .health-check-accordion-panel>div{display:block}body .health-check-accordion .health-check-accordion-panel[hidden]{display:none}body .health-check-accordion .health-check-accordion-panel a .dashicons{text-decoration:none}body .health-check-accordion dl dd{margin:0 0 0.5em 2em}.health-check-modal{display:none;position:absolute;z-index:1000;padding-top:50px;left:0;top:0;width:100%;height:100%;overflow:auto;background-color:#000;background-color:rgba(0,0,0,0.4)}@media all and (min-width: 1024px){.health-check-modal{padding-top:100px}}.health-check-modal.show{display:block}.health-check-modal .modal-content{background-color:#fefefe;margin:auto;padding:20px;border:1px solid #888;width:90%}@media all and (min-width: 1024px){.health-check-modal .modal-content{width:30%}}.health-check-modal .modal-content .modal-close{color:#aaa;float:right;font-size:28px;font-weight:600;cursor:pointer}.health-check-modal .modal-content #dynamic-content{display:block;width:100%}.health-check-modal .modal-close:hover,.health-check-modal .modal-close:focus{color:#aaa;float:right;font-size:28px;font-weight:600}.health-check-title-section{display:flex;align-items:center;justify-content:center;clear:both}.health-check-title-section h1{display:inline-block;font-weight:600;font-size:23px;margin:0 0.8rem 1rem;padding:9px 0 4px;line-height:1.3;font-family:inherit}.health-check-title-section.site-health-progress-wrapper{margin-bottom:1rem}.health-check-title-section.site-health-progress-wrapper.loading .site-health-progress svg #bar{stroke-dashoffset:0;stroke:#adc5d2;animation:loadingPulse 3s infinite ease-in-out}@keyframes loadingPulse{0%{stroke:#adc5d2}50%{stroke:#00a0d2}100%{stroke:#adc5d2}}.health-check-title-section.site-health-progress-wrapper.green #bar{stroke:#46b450}.health-check-title-section.site-health-progress-wrapper.green .site-health-progress-label{color:#46b450}.health-check-title-section.site-health-progress-wrapper.orange #bar{stroke:#ffb900}.health-check-title-section.site-health-progress-wrapper.orange .site-health-progress-label{color:#ffb900}.health-check-title-section.site-health-progress-wrapper .site-health-progress{display:inline-block;height:20px;width:20px;margin:0;border-radius:100%;position:relative;font-weight:600;font-size:0.4rem}.health-check-title-section.site-health-progress-wrapper .site-health-progress svg circle{stroke-dashoffset:0;transition:stroke-dashoffset 1s linear;stroke:#ccc;stroke-width:3em}.health-check-title-section.site-health-progress-wrapper .site-health-progress svg #bar{stroke-dashoffset:565}.health-check-title-section.site-health-progress-wrapper .site-health-progress-label{font-weight:600;line-height:20px;margin-left:0.3rem}#health-check-dashboard-widget{display:grid;grid-gap:2%;grid-template-columns:100%;padding:13px;background:#fff}@media all and (min-width: 783px){#health-check-dashboard-widget{margin-top:3rem;grid-template-columns:49% 49%}}#health-check-dashboard-widget h2 .green{color:#40860a}#health-check-dashboard-widget .welcome-panel-content{max-width:initial}#health-check-dashboard-widget #health-check-accordion-block-notices .no-notices p{color:#72777c;font-size:1.2rem}#health-check-dashboard-widget #health-check-accordion-block-notices .notice{color:#72777c;margin-left:0}#health-check-dashboard-widget #health-check-accordion-block-notices .notice p{font-size:13px}#health-check-dashboard-widget #health-check-accordion-block-notices .dismiss-notices{display:block;width:100%;text-align:right;margin-right:1rem}#health-check-dashboard-widget .disable-troubleshooting-mode{margin-bottom:1rem}@media all and (min-width: 960px){#health-check-dashboard-widget .disable-troubleshooting-mode{position:absolute;bottom:1rem;right:1rem}}#health-check-dashboard-widget ul li{font-size:13px}@media all and (max-width: 870px){#health-check-dashboard-widget ul li{display:inline-block;width:100%}}#health-check-dashboard-widget .about-description{margin:1em 0;max-width:700px;display:inline-block}#health-check-dashboard-widget .about-description p{color:inherit;font-size:16px}
2
-
 
 
assets/javascript/clipboard.min.js DELETED
@@ -1,7 +0,0 @@
1
- /*!
2
- * clipboard.js v2.0.4
3
- * https://zenorocha.github.io/clipboard.js
4
- *
5
- * Licensed MIT © Zeno Rocha
6
- */
7
- !function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e():"function"==typeof define&&define.amd?define([],e):"object"==typeof exports?exports.ClipboardJS=e():t.ClipboardJS=e()}(this,function(){return function(n){var o={};function r(t){if(o[t])return o[t].exports;var e=o[t]={i:t,l:!1,exports:{}};return n[t].call(e.exports,e,e.exports,r),e.l=!0,e.exports}return r.m=n,r.c=o,r.d=function(t,e,n){r.o(t,e)||Object.defineProperty(t,e,{enumerable:!0,get:n})},r.r=function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},r.t=function(e,t){if(1&t&&(e=r(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var n=Object.create(null);if(r.r(n),Object.defineProperty(n,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var o in e)r.d(n,o,function(t){return e[t]}.bind(null,o));return n},r.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return r.d(e,"a",e),e},r.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},r.p="",r(r.s=0)}([function(t,e,n){"use strict";var r="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},i=function(){function o(t,e){for(var n=0;n<e.length;n++){var o=e[n];o.enumerable=o.enumerable||!1,o.configurable=!0,"value"in o&&(o.writable=!0),Object.defineProperty(t,o.key,o)}}return function(t,e,n){return e&&o(t.prototype,e),n&&o(t,n),t}}(),a=o(n(1)),c=o(n(3)),u=o(n(4));function o(t){return t&&t.__esModule?t:{default:t}}var l=function(t){function o(t,e){!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,o);var n=function(t,e){if(!t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!e||"object"!=typeof e&&"function"!=typeof e?t:e}(this,(o.__proto__||Object.getPrototypeOf(o)).call(this));return n.resolveOptions(e),n.listenClick(t),n}return function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function, not "+typeof e);t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,enumerable:!1,writable:!0,configurable:!0}}),e&&(Object.setPrototypeOf?Object.setPrototypeOf(t,e):t.__proto__=e)}(o,c.default),i(o,[{key:"resolveOptions",value:function(){var t=0<arguments.length&&void 0!==arguments[0]?arguments[0]:{};this.action="function"==typeof t.action?t.action:this.defaultAction,this.target="function"==typeof t.target?t.target:this.defaultTarget,this.text="function"==typeof t.text?t.text:this.defaultText,this.container="object"===r(t.container)?t.container:document.body}},{key:"listenClick",value:function(t){var e=this;this.listener=(0,u.default)(t,"click",function(t){return e.onClick(t)})}},{key:"onClick",value:function(t){var e=t.delegateTarget||t.currentTarget;this.clipboardAction&&(this.clipboardAction=null),this.clipboardAction=new a.default({action:this.action(e),target:this.target(e),text:this.text(e),container:this.container,trigger:e,emitter:this})}},{key:"defaultAction",value:function(t){return s("action",t)}},{key:"defaultTarget",value:function(t){var e=s("target",t);if(e)return document.querySelector(e)}},{key:"defaultText",value:function(t){return s("text",t)}},{key:"destroy",value:function(){this.listener.destroy(),this.clipboardAction&&(this.clipboardAction.destroy(),this.clipboardAction=null)}}],[{key:"isSupported",value:function(){var t=0<arguments.length&&void 0!==arguments[0]?arguments[0]:["copy","cut"],e="string"==typeof t?[t]:t,n=!!document.queryCommandSupported;return e.forEach(function(t){n=n&&!!document.queryCommandSupported(t)}),n}}]),o}();function s(t,e){var n="data-clipboard-"+t;if(e.hasAttribute(n))return e.getAttribute(n)}t.exports=l},function(t,e,n){"use strict";var o,r="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},i=function(){function o(t,e){for(var n=0;n<e.length;n++){var o=e[n];o.enumerable=o.enumerable||!1,o.configurable=!0,"value"in o&&(o.writable=!0),Object.defineProperty(t,o.key,o)}}return function(t,e,n){return e&&o(t.prototype,e),n&&o(t,n),t}}(),a=n(2),c=(o=a)&&o.__esModule?o:{default:o};var u=function(){function e(t){!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,e),this.resolveOptions(t),this.initSelection()}return i(e,[{key:"resolveOptions",value:function(){var t=0<arguments.length&&void 0!==arguments[0]?arguments[0]:{};this.action=t.action,this.container=t.container,this.emitter=t.emitter,this.target=t.target,this.text=t.text,this.trigger=t.trigger,this.selectedText=""}},{key:"initSelection",value:function(){this.text?this.selectFake():this.target&&this.selectTarget()}},{key:"selectFake",value:function(){var t=this,e="rtl"==document.documentElement.getAttribute("dir");this.removeFake(),this.fakeHandlerCallback=function(){return t.removeFake()},this.fakeHandler=this.container.addEventListener("click",this.fakeHandlerCallback)||!0,this.fakeElem=document.createElement("textarea"),this.fakeElem.style.fontSize="12pt",this.fakeElem.style.border="0",this.fakeElem.style.padding="0",this.fakeElem.style.margin="0",this.fakeElem.style.position="absolute",this.fakeElem.style[e?"right":"left"]="-9999px";var n=window.pageYOffset||document.documentElement.scrollTop;this.fakeElem.style.top=n+"px",this.fakeElem.setAttribute("readonly",""),this.fakeElem.value=this.text,this.container.appendChild(this.fakeElem),this.selectedText=(0,c.default)(this.fakeElem),this.copyText()}},{key:"removeFake",value:function(){this.fakeHandler&&(this.container.removeEventListener("click",this.fakeHandlerCallback),this.fakeHandler=null,this.fakeHandlerCallback=null),this.fakeElem&&(this.container.removeChild(this.fakeElem),this.fakeElem=null)}},{key:"selectTarget",value:function(){this.selectedText=(0,c.default)(this.target),this.copyText()}},{key:"copyText",value:function(){var e=void 0;try{e=document.execCommand(this.action)}catch(t){e=!1}this.handleResult(e)}},{key:"handleResult",value:function(t){this.emitter.emit(t?"success":"error",{action:this.action,text:this.selectedText,trigger:this.trigger,clearSelection:this.clearSelection.bind(this)})}},{key:"clearSelection",value:function(){this.trigger&&this.trigger.focus(),window.getSelection().removeAllRanges()}},{key:"destroy",value:function(){this.removeFake()}},{key:"action",set:function(){var t=0<arguments.length&&void 0!==arguments[0]?arguments[0]:"copy";if(this._action=t,"copy"!==this._action&&"cut"!==this._action)throw new Error('Invalid "action" value, use either "copy" or "cut"')},get:function(){return this._action}},{key:"target",set:function(t){if(void 0!==t){if(!t||"object"!==(void 0===t?"undefined":r(t))||1!==t.nodeType)throw new Error('Invalid "target" value, use a valid Element');if("copy"===this.action&&t.hasAttribute("disabled"))throw new Error('Invalid "target" attribute. Please use "readonly" instead of "disabled" attribute');if("cut"===this.action&&(t.hasAttribute("readonly")||t.hasAttribute("disabled")))throw new Error('Invalid "target" attribute. You can\'t cut text from elements with "readonly" or "disabled" attributes');this._target=t}},get:function(){return this._target}}]),e}();t.exports=u},function(t,e){t.exports=function(t){var e;if("SELECT"===t.nodeName)t.focus(),e=t.value;else if("INPUT"===t.nodeName||"TEXTAREA"===t.nodeName){var n=t.hasAttribute("readonly");n||t.setAttribute("readonly",""),t.select(),t.setSelectionRange(0,t.value.length),n||t.removeAttribute("readonly"),e=t.value}else{t.hasAttribute("contenteditable")&&t.focus();var o=window.getSelection(),r=document.createRange();r.selectNodeContents(t),o.removeAllRanges(),o.addRange(r),e=o.toString()}return e}},function(t,e){function n(){}n.prototype={on:function(t,e,n){var o=this.e||(this.e={});return(o[t]||(o[t]=[])).push({fn:e,ctx:n}),this},once:function(t,e,n){var o=this;function r(){o.off(t,r),e.apply(n,arguments)}return r._=e,this.on(t,r,n)},emit:function(t){for(var e=[].slice.call(arguments,1),n=((this.e||(this.e={}))[t]||[]).slice(),o=0,r=n.length;o<r;o++)n[o].fn.apply(n[o].ctx,e);return this},off:function(t,e){var n=this.e||(this.e={}),o=n[t],r=[];if(o&&e)for(var i=0,a=o.length;i<a;i++)o[i].fn!==e&&o[i].fn._!==e&&r.push(o[i]);return r.length?n[t]=r:delete n[t],this}},t.exports=n},function(t,e,n){var d=n(5),h=n(6);t.exports=function(t,e,n){if(!t&&!e&&!n)throw new Error("Missing required arguments");if(!d.string(e))throw new TypeError("Second argument must be a String");if(!d.fn(n))throw new TypeError("Third argument must be a Function");if(d.node(t))return s=e,f=n,(l=t).addEventListener(s,f),{destroy:function(){l.removeEventListener(s,f)}};if(d.nodeList(t))return a=t,c=e,u=n,Array.prototype.forEach.call(a,function(t){t.addEventListener(c,u)}),{destroy:function(){Array.prototype.forEach.call(a,function(t){t.removeEventListener(c,u)})}};if(d.string(t))return o=t,r=e,i=n,h(document.body,o,r,i);throw new TypeError("First argument must be a String, HTMLElement, HTMLCollection, or NodeList");var o,r,i,a,c,u,l,s,f}},function(t,n){n.node=function(t){return void 0!==t&&t instanceof HTMLElement&&1===t.nodeType},n.nodeList=function(t){var e=Object.prototype.toString.call(t);return void 0!==t&&("[object NodeList]"===e||"[object HTMLCollection]"===e)&&"length"in t&&(0===t.length||n.node(t[0]))},n.string=function(t){return"string"==typeof t||t instanceof String},n.fn=function(t){return"[object Function]"===Object.prototype.toString.call(t)}},function(t,e,n){var a=n(7);function i(t,e,n,o,r){var i=function(e,n,t,o){return function(t){t.delegateTarget=a(t.target,n),t.delegateTarget&&o.call(e,t)}}.apply(this,arguments);return t.addEventListener(n,i,r),{destroy:function(){t.removeEventListener(n,i,r)}}}t.exports=function(t,e,n,o,r){return"function"==typeof t.addEventListener?i.apply(null,arguments):"function"==typeof n?i.bind(null,document).apply(null,arguments):("string"==typeof t&&(t=document.querySelectorAll(t)),Array.prototype.map.call(t,function(t){return i(t,e,n,o,r)}))}},function(t,e){if("undefined"!=typeof Element&&!Element.prototype.matches){var n=Element.prototype;n.matches=n.matchesSelector||n.mozMatchesSelector||n.msMatchesSelector||n.oMatchesSelector||n.webkitMatchesSelector}t.exports=function(t,e){for(;t&&9!==t.nodeType;){if("function"==typeof t.matches&&t.matches(e))return t;t=t.parentNode}}}])});
 
 
 
 
 
 
 
assets/javascript/health-check.js DELETED
@@ -1,8 +0,0 @@
1
- !function(e){var t={};function n(i){if(t[i])return t[i].exports;var a=t[i]={i:i,l:!1,exports:{}};return e[i].call(a.exports,a,a.exports,n),a.l=!0,a.exports}n.m=e,n.c=t,n.d=function(e,t,i){n.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:i})},n.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},n.t=function(e,t){if(1&t&&(e=n(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var i=Object.create(null);if(n.r(i),Object.defineProperty(i,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var a in e)n.d(i,a,function(t){return e[t]}.bind(null,a));return i},n.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return n.d(t,"a",t),t},n.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},n.p="",n(n.s=13)}([function(e,t,n){},function(e,t,n){
2
- /*!
3
- * clipboard.js v2.0.6
4
- * https://clipboardjs.com/
5
- *
6
- * Licensed MIT © Zeno Rocha
7
- */
8
- var i;i=function(){return function(e){var t={};function n(i){if(t[i])return t[i].exports;var a=t[i]={i:i,l:!1,exports:{}};return e[i].call(a.exports,a,a.exports,n),a.l=!0,a.exports}return n.m=e,n.c=t,n.d=function(e,t,i){n.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:i})},n.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},n.t=function(e,t){if(1&t&&(e=n(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var i=Object.create(null);if(n.r(i),Object.defineProperty(i,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var a in e)n.d(i,a,function(t){return e[t]}.bind(null,a));return i},n.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return n.d(t,"a",t),t},n.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},n.p="",n(n.s=6)}([function(e,t){e.exports=function(e){var t;if("SELECT"===e.nodeName)e.focus(),t=e.value;else if("INPUT"===e.nodeName||"TEXTAREA"===e.nodeName){var n=e.hasAttribute("readonly");n||e.setAttribute("readonly",""),e.select(),e.setSelectionRange(0,e.value.length),n||e.removeAttribute("readonly"),t=e.value}else{e.hasAttribute("contenteditable")&&e.focus();var i=window.getSelection(),a=document.createRange();a.selectNodeContents(e),i.removeAllRanges(),i.addRange(a),t=i.toString()}return t}},function(e,t){function n(){}n.prototype={on:function(e,t,n){var i=this.e||(this.e={});return(i[e]||(i[e]=[])).push({fn:t,ctx:n}),this},once:function(e,t,n){var i=this;function a(){i.off(e,a),t.apply(n,arguments)}return a._=t,this.on(e,a,n)},emit:function(e){for(var t=[].slice.call(arguments,1),n=((this.e||(this.e={}))[e]||[]).slice(),i=0,a=n.length;i<a;i++)n[i].fn.apply(n[i].ctx,t);return this},off:function(e,t){var n=this.e||(this.e={}),i=n[e],a=[];if(i&&t)for(var o=0,s=i.length;o<s;o++)i[o].fn!==t&&i[o].fn._!==t&&a.push(i[o]);return a.length?n[e]=a:delete n[e],this}},e.exports=n,e.exports.TinyEmitter=n},function(e,t,n){var i=n(3),a=n(4);e.exports=function(e,t,n){if(!e&&!t&&!n)throw new Error("Missing required arguments");if(!i.string(t))throw new TypeError("Second argument must be a String");if(!i.fn(n))throw new TypeError("Third argument must be a Function");if(i.node(e))return function(e,t,n){return e.addEventListener(t,n),{destroy:function(){e.removeEventListener(t,n)}}}(e,t,n);if(i.nodeList(e))return function(e,t,n){return Array.prototype.forEach.call(e,(function(e){e.addEventListener(t,n)})),{destroy:function(){Array.prototype.forEach.call(e,(function(e){e.removeEventListener(t,n)}))}}}(e,t,n);if(i.string(e))return function(e,t,n){return a(document.body,e,t,n)}(e,t,n);throw new TypeError("First argument must be a String, HTMLElement, HTMLCollection, or NodeList")}},function(e,t){t.node=function(e){return void 0!==e&&e instanceof HTMLElement&&1===e.nodeType},t.nodeList=function(e){var n=Object.prototype.toString.call(e);return void 0!==e&&("[object NodeList]"===n||"[object HTMLCollection]"===n)&&"length"in e&&(0===e.length||t.node(e[0]))},t.string=function(e){return"string"==typeof e||e instanceof String},t.fn=function(e){return"[object Function]"===Object.prototype.toString.call(e)}},function(e,t,n){var i=n(5);function a(e,t,n,i,a){var s=o.apply(this,arguments);return e.addEventListener(n,s,a),{destroy:function(){e.removeEventListener(n,s,a)}}}function o(e,t,n,a){return function(n){n.delegateTarget=i(n.target,t),n.delegateTarget&&a.call(e,n)}}e.exports=function(e,t,n,i,o){return"function"==typeof e.addEventListener?a.apply(null,arguments):"function"==typeof n?a.bind(null,document).apply(null,arguments):("string"==typeof e&&(e=document.querySelectorAll(e)),Array.prototype.map.call(e,(function(e){return a(e,t,n,i,o)})))}},function(e,t){if("undefined"!=typeof Element&&!Element.prototype.matches){var n=Element.prototype;n.matches=n.matchesSelector||n.mozMatchesSelector||n.msMatchesSelector||n.oMatchesSelector||n.webkitMatchesSelector}e.exports=function(e,t){for(;e&&9!==e.nodeType;){if("function"==typeof e.matches&&e.matches(t))return e;e=e.parentNode}}},function(e,t,n){"use strict";n.r(t);var i=n(0),a=n.n(i),o="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},s=function(){function e(e,t){for(var n=0;n<t.length;n++){var i=t[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,i.key,i)}}return function(t,n,i){return n&&e(t.prototype,n),i&&e(t,i),t}}(),r=function(){function e(t){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),this.resolveOptions(t),this.initSelection()}return s(e,[{key:"resolveOptions",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};this.action=e.action,this.container=e.container,this.emitter=e.emitter,this.target=e.target,this.text=e.text,this.trigger=e.trigger,this.selectedText=""}},{key:"initSelection",value:function(){this.text?this.selectFake():this.target&&this.selectTarget()}},{key:"selectFake",value:function(){var e=this,t="rtl"==document.documentElement.getAttribute("dir");this.removeFake(),this.fakeHandlerCallback=function(){return e.removeFake()},this.fakeHandler=this.container.addEventListener("click",this.fakeHandlerCallback)||!0,this.fakeElem=document.createElement("textarea"),this.fakeElem.style.fontSize="12pt",this.fakeElem.style.border="0",this.fakeElem.style.padding="0",this.fakeElem.style.margin="0",this.fakeElem.style.position="absolute",this.fakeElem.style[t?"right":"left"]="-9999px";var n=window.pageYOffset||document.documentElement.scrollTop;this.fakeElem.style.top=n+"px",this.fakeElem.setAttribute("readonly",""),this.fakeElem.value=this.text,this.container.appendChild(this.fakeElem),this.selectedText=a()(this.fakeElem),this.copyText()}},{key:"removeFake",value:function(){this.fakeHandler&&(this.container.removeEventListener("click",this.fakeHandlerCallback),this.fakeHandler=null,this.fakeHandlerCallback=null),this.fakeElem&&(this.container.removeChild(this.fakeElem),this.fakeElem=null)}},{key:"selectTarget",value:function(){this.selectedText=a()(this.target),this.copyText()}},{key:"copyText",value:function(){var e=void 0;try{e=document.execCommand(this.action)}catch(t){e=!1}this.handleResult(e)}},{key:"handleResult",value:function(e){this.emitter.emit(e?"success":"error",{action:this.action,text:this.selectedText,trigger:this.trigger,clearSelection:this.clearSelection.bind(this)})}},{key:"clearSelection",value:function(){this.trigger&&this.trigger.focus(),document.activeElement.blur(),window.getSelection().removeAllRanges()}},{key:"destroy",value:function(){this.removeFake()}},{key:"action",set:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"copy";if(this._action=e,"copy"!==this._action&&"cut"!==this._action)throw new Error('Invalid "action" value, use either "copy" or "cut"')},get:function(){return this._action}},{key:"target",set:function(e){if(void 0!==e){if(!e||"object"!==(void 0===e?"undefined":o(e))||1!==e.nodeType)throw new Error('Invalid "target" value, use a valid Element');if("copy"===this.action&&e.hasAttribute("disabled"))throw new Error('Invalid "target" attribute. Please use "readonly" instead of "disabled" attribute');if("cut"===this.action&&(e.hasAttribute("readonly")||e.hasAttribute("disabled")))throw new Error('Invalid "target" attribute. You can\'t cut text from elements with "readonly" or "disabled" attributes');this._target=e}},get:function(){return this._target}}]),e}(),c=n(1),l=n.n(c),u=n(2),h=n.n(u),d="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},f=function(){function e(e,t){for(var n=0;n<t.length;n++){var i=t[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,i.key,i)}}return function(t,n,i){return n&&e(t.prototype,n),i&&e(t,i),t}}(),p=function(e){function t(e,n){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,t);var i=function(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t}(this,(t.__proto__||Object.getPrototypeOf(t)).call(this));return i.resolveOptions(n),i.listenClick(e),i}return function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}(t,e),f(t,[{key:"resolveOptions",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};this.action="function"==typeof e.action?e.action:this.defaultAction,this.target="function"==typeof e.target?e.target:this.defaultTarget,this.text="function"==typeof e.text?e.text:this.defaultText,this.container="object"===d(e.container)?e.container:document.body}},{key:"listenClick",value:function(e){var t=this;this.listener=h()(e,"click",(function(e){return t.onClick(e)}))}},{key:"onClick",value:function(e){var t=e.delegateTarget||e.currentTarget;this.clipboardAction&&(this.clipboardAction=null),this.clipboardAction=new r({action:this.action(t),target:this.target(t),text:this.text(t),container:this.container,trigger:t,emitter:this})}},{key:"defaultAction",value:function(e){return m("action",e)}},{key:"defaultTarget",value:function(e){var t=m("target",e);if(t)return document.querySelector(t)}},{key:"defaultText",value:function(e){return m("text",e)}},{key:"destroy",value:function(){this.listener.destroy(),this.clipboardAction&&(this.clipboardAction.destroy(),this.clipboardAction=null)}}],[{key:"isSupported",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:["copy","cut"],t="string"==typeof e?[e]:e,n=!!document.queryCommandSupported;return t.forEach((function(e){n=n&&!!document.queryCommandSupported(e)})),n}}]),t}(l.a);function m(e,t){var n="data-clipboard-"+e;if(t.hasAttribute(n))return t.getAttribute(n)}t.default=p}]).default},e.exports=i()},function(e,t){jQuery(document).ready((function(e){var t,n,i,a=e(".health-check-debug-tab.active").length,o=e("#health-check-accordion-block-wp-paths-sizes");a&&o.length&&(t={action:"health-check-get-sizes",_wpnonce:SiteHealth.nonce.site_status_result},n=(new Date).getTime(),i=window.setTimeout((function(){wp.a11y.speak(SiteHealth.string.please_wait)}),3e3),e.post({type:"POST",url:ajaxurl,data:t,dataType:"json"}).done((function(t){!function(t){var n=e("button.button.copy-button"),i=n.attr("data-clipboard-text");e.each(t,(function(e,t){var n=t.debug||t.size;void 0!==n&&(i=i.replace(e+": loading...",e+": "+n))})),n.attr("data-clipboard-text",i),o.find("td[class]").each((function(n,i){var a=e(i),o=a.attr("class");t.hasOwnProperty(o)&&t[o].size&&a.text(t[o].size)}))}(t.data||{})})).always((function(){var t=(new Date).getTime()-n;e(".health-check-wp-paths-sizes.spinner").css("visibility","hidden"),t>3e3?(t=t>6e3?0:6500-t,window.setTimeout((function(){wp.a11y.speak(SiteHealth.string.site_health_complete)}),t)):window.clearTimeout(i),e(document).trigger("site-health-info-dirsizes-done")})))}))},function(e,t){jQuery(document).ready((function(e){e(".health-check-accordion").on("click",".health-check-accordion-trigger",(function(){"true"===e(this).attr("aria-expanded")?(e(this).attr("aria-expanded","false"),e("#"+e(this).attr("aria-controls")).attr("hidden",!0)):(e(this).attr("aria-expanded","true"),e("#"+e(this).attr("aria-controls")).attr("hidden",!1))}))}))},function(e,t){jQuery(document).ready((function(e){function t(e){e.hide()}e(".modal-close").click((function(n){n.preventDefault(),t(e(this).closest(".health-check-modal"))})),e(".health-check-modal").on("submit","form",(function(n){var i=e(this).serializeArray(),a=e(this).closest(".health-check-modal");n.preventDefault(),e.post(ajaxurl,i,(function(t){var n,o,s;!0===t.success?e(a.data("parent-field")).append(t.data.message):(n=t.data.message,o=i.action,s=a.data("parent-field"),e("#dynamic-content").html(n),e(".health-check-modal").data("modal-action",o).data("parent-field",s).show())})),t(a)}))}))},function(e,t){jQuery(document).ready((function(e){function t(){var n=e(".not-tested","#loopback-individual-plugins-list");if(n.length<1)return function(){var t=e(".individual-loopback-test-status","#test-single-no-theme"),n={action:"health-check-loopback-default-theme",_wpnonce:SiteHealth.nonce.loopback_default_theme};e.post(ajaxurl,n,(function(e){!0===e.success?t.html(e.data.message):healthCheckFailureModal(e.data,n.action,t)}),"json")}(),null;var i=n.first(),a={action:"health-check-loopback-individual-plugins",plugin:i.data("test-plugin"),_wpnonce:SiteHealth.nonce.loopback_individual_plugins},o=e(".individual-loopback-test-status",i);o.html(SiteHealth.string.running_tests),e.post(ajaxurl,a,(function(e){!0===e.success?(i.removeClass("not-tested"),o.html(e.data.message),t()):healthCheckFailureModal(e.data,a.action,o)}),"json")}e(".dashboard_page_health-check").on("click","#loopback-no-plugins",(function(t){var n=e(this),i=e(this).closest("p"),a={action:"health-check-loopback-no-plugins",_wpnonce:SiteHealth.nonce.loopback_no_plugins};t.preventDefault(),e(this).html('<span class="spinner" style="visibility: visible;"></span> '+SiteHealth.string.please_wait),e.post(ajaxurl,a,(function(e){n.remove(),!0===e.success?i.append(e.data.message):healthCheckFailureModal(e.data,a.action,i)}),"json")})).on("click","#loopback-individual-plugins",(function(n){n.preventDefault(),e(this).remove(),t()}))}))},function(e,t){jQuery(document).ready((function(e){var t,n=e(".health-check-debug-tab.active").length;function i(t){if(void 0!==t&&void 0!==t.status){var n,i=wp.template("health-check-issue"),a=e("#health-check-issues-"+t.status);SiteHealth.site_status.issues[t.status]++;var o=SiteHealth.site_status.issues[t.status];"critical"===t.status?n=o<=1?SiteHealth.string.site_info_heading_critical_single.replace("%s",'<span class="issue-count">'+o+"</span>"):SiteHealth.string.site_info_heading_critical_plural.replace("%s",'<span class="issue-count">'+o+"</span>"):"recommended"===t.status?n=o<=1?SiteHealth.string.site_info_heading_recommended_single.replace("%s",'<span class="issue-count">'+o+"</span>"):SiteHealth.string.site_info_heading_recommended_plural.replace("%s",'<span class="issue-count">'+o+"</span>"):"good"===t.status&&(n=o<=1?SiteHealth.string.site_info_heading_good_single.replace("%s",'<span class="issue-count">'+o+"</span>"):SiteHealth.string.site_info_heading_good_plural.replace("%s",'<span class="issue-count">'+o+"</span>")),n&&e(".site-health-issue-count-title",a).html(n),e(".issues","#health-check-issues-"+t.status).append(i(t))}}function a(){var t=e(".site-health-progress"),i=t.closest(".site-health-progress-wrapper"),a=e(".site-health-progress-label",i),o=e(".site-health-progress svg #bar"),s=parseInt(SiteHealth.site_status.issues.good,0)+parseInt(SiteHealth.site_status.issues.recommended,0)+1.5*parseInt(SiteHealth.site_status.issues.critical,0),r=.5*parseInt(SiteHealth.site_status.issues.recommended,0)+1.5*parseInt(SiteHealth.site_status.issues.critical,0),c=100-Math.ceil(r/s*100);if(0!==s){i.removeClass("loading");var l=o.attr("r");0>c&&(c=0),100<c&&(c=100);var u=(100-c)/100*(Math.PI*(2*l));o.css({strokeDashoffset:u}),1>parseInt(SiteHealth.site_status.issues.critical,0)&&e("#health-check-issues-critical").addClass("hidden"),1>parseInt(SiteHealth.site_status.issues.recommended,0)&&e("#health-check-issues-recommended").addClass("hidden"),n||e.post(ajaxurl,{action:"health-check-site-status-result",_wpnonce:SiteHealth.nonce.site_status_result,counts:SiteHealth.site_status.issues}),80<=c&&0===parseInt(SiteHealth.site_status.issues.critical,0)?(i.addClass("green").removeClass("orange"),a.text(SiteHealth.string.site_health_complete_pass),wp.a11y.speak(SiteHealth.string.site_health_complete_pass_sr)):(i.addClass("orange").removeClass("green"),a.text(SiteHealth.string.site_health_complete_fail),wp.a11y.speak(SiteHealth.string.site_health_complete_fail_sr)),100===c&&(e(".site-status-all-clear").removeClass("hide"),e(".site-status-has-issues").addClass("hide"))}else t.addClass("hidden")}e(".site-health-view-passed").on("click",(function(){var t=e("#health-check-issues-good");t.toggleClass("hidden"),e(this).attr("aria-expanded",!t.hasClass("hidden"))})),"undefined"!=typeof SiteHealth&&(0===SiteHealth.site_status.direct.length&&0===SiteHealth.site_status.async.length?a():SiteHealth.site_status.issues={good:0,recommended:0,critical:0},0<SiteHealth.site_status.direct.length&&e.each(SiteHealth.site_status.direct,(function(){i(this)})),0<SiteHealth.site_status.async.length?(t={action:"health-check-site-status",feature:SiteHealth.site_status.async[0].test,_wpnonce:SiteHealth.nonce.site_status},SiteHealth.site_status.async[0].completed=!0,e.post(ajaxurl,t,(function(n){i(n.data),function n(){var o=!0;1<=SiteHealth.site_status.async.length&&e.each(SiteHealth.site_status.async,(function(){return t={action:"health-check-site-status",feature:this.test,_wpnonce:SiteHealth.nonce.site_status},!!this.completed||(o=!1,this.completed=!0,e.post(ajaxurl,t,(function(e){void 0!==wp.hooks?i(wp.hooks.applyFilters("site_status_test_result",e.data)):i(e.data),n()})),!1)})),o&&a()}()}))):a())}))},function(e,t){jQuery(document).ready((function(e){e("#health-check-file-integrity").submit((function(t){var n={action:"health-check-files-integrity-check",_wpnonce:SiteHealth.nonce.files_integrity_check};t.preventDefault(),e("#tools-file-integrity-response-holder").html('<span class="spinner"></span>'),e("#tools-file-integrity-response-holder .spinner").addClass("is-active"),e.post(ajaxurl,n,(function(t){e("#tools-file-integrity-response-holder .spinner").removeClass("is-active"),e("#tools-file-integrity-response-holder").parent().css("height","auto"),e("#tools-file-integrity-response-holder").html(t.data.message)}))})),e("#tools-file-integrity-response-holder").on("click",'a[href="#health-check-diff"]',(function(t){var n=e(this).data("file");t.preventDefault(),e("#health-check-diff-modal").toggle(),e("#health-check-diff-modal #health-check-diff-modal-content .spinner").addClass("is-active");var i={action:"health-check-view-file-diff",file:n,_wpnonce:SiteHealth.nonce.view_file_diff};e.post(ajaxurl,i,(function(t){e("#health-check-diff-modal #health-check-diff-modal-diff").html(t.data.message),e("#health-check-diff-modal #health-check-diff-modal-content h3").html(n),e("#health-check-diff-modal #health-check-diff-modal-content .spinner").removeClass("is-active")}))}))}))},function(e,t){jQuery(document).ready((function(e){e("#health-check-diff-modal").on("click",'a[href="#health-check-diff-modal-close"]',(function(t){t.preventDefault(),e("#health-check-diff-modal").toggle(),e("#health-check-diff-modal #health-check-diff-modal-diff").html(""),e("#health-check-diff-modal #health-check-diff-modal-content h3").html("")})),e(document).keyup((function(t){27===t.which&&(e("#health-check-diff-modal").css("display","none"),e("#health-check-diff-modal #health-check-diff-modal-diff").html(""),e("#health-check-diff-modal #health-check-diff-modal-content h3").html(""))}))}))},function(e,t){jQuery(document).ready((function(e){e("#health-check-mail-check").submit((function(t){var n=e("#health-check-mail-check #email").val(),i=e("#health-check-mail-check #email_message").val();t.preventDefault(),e("#tools-mail-check-response-holder").html('<span class="spinner"></span>'),e("#tools-mail-check-response-holder .spinner").addClass("is-active");var a={action:"health-check-mail-check",email:n,email_message:i,_wpnonce:SiteHealth.nonce.mail_check};e.post(ajaxurl,a,(function(t){e("#tools-mail-check-response-holder .spinner").removeClass("is-active"),e("#tools-mail-check-response-holder").parent().css("height","auto"),e("#tools-mail-check-response-holder").html(t.data.message)}))}))}))},function(e,t){jQuery(document).ready((function(e){e("#health-check-tool-plugin-compat").click((function(){e("tr","#health-check-tool-plugin-compat-list").data("plugin-checked",!1),e(".spinner","#health-check-tool-plugin-compat-list").addClass("is-active"),e(this).attr("disabled",!0),function t(){var n=e('[data-plugin-checked="false"]',"#health-check-tool-plugin-compat-list");if(n.length<=0)return;var i=e(n[0]);i.attr("data-plugin-checked","true");var a={action:"health-check-tools-plugin-compat",slug:i.data("plugin-slug"),version:i.data("plugin-version"),_wpnonce:SiteHealth.nonce.tools_plugin_compat};e.post(ajaxurl,a,(function(n){e(".spinner",i).removeClass("is-active"),e(".supported-version",i).append(n.data.version),t()}))}()}))}))},,,function(e,t,n){"use strict";n.r(t);n(0),n(1);jQuery(document).ready((function(e){"undefined"!=typeof ClipboardJS&&new ClipboardJS(".site-health-copy-buttons .copy-button").on("success",(function(t){var n=e(t.trigger).closest("div");e(".success",n).addClass("visible"),wp.a11y.speak(SiteHealth.string.site_info_copied)}))}));n(2),n(3),n(4),n(5),n(6),n(7),n(8),n(9),n(10)}]);
 
 
 
 
 
 
 
 
assets/javascript/troubleshooting-mode.js DELETED
@@ -1 +0,0 @@
1
- !function(e){var t={};function n(r){if(t[r])return t[r].exports;var o=t[r]={i:r,l:!1,exports:{}};return e[r].call(o.exports,o,o.exports,n),o.l=!0,o.exports}n.m=e,n.c=t,n.d=function(e,t,r){n.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:r})},n.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},n.t=function(e,t){if(1&t&&(e=n(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var r=Object.create(null);if(n.r(r),Object.defineProperty(r,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var o in e)n.d(r,o,function(t){return e[t]}.bind(null,o));return r},n.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return n.d(t,"a",t),t},n.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},n.p="",n(n.s=11)}({11:function(e,t,n){"use strict";n.r(t);n(12)},12:function(e,t){jQuery(document).ready((function(e){e(".show-remaining").click((function(){e(".hidden",e(this).closest("ul")).removeClass("hidden")}))}))}});
 
build/health-check-tools.asset.php ADDED
@@ -0,0 +1 @@
 
1
+ <?php return array('dependencies' => array(), 'version' => 'ecf8e9136e1f6b75ecdf');
build/health-check-tools.js ADDED
@@ -0,0 +1 @@
 
1
+ (()=>{var e={629:()=>{jQuery(document).ready((function(e){e("#health-check-file-integrity").on("submit",(function(t){const c={action:"health-check-files-integrity-check",_wpnonce:HealthCheck.nonce.files_integrity_check};t.preventDefault(),e("#tools-file-integrity-response-holder").html('<span class="spinner"></span>'),e("#tools-file-integrity-response-holder .spinner").addClass("is-active"),e.post(ajaxurl,c,(function(t){e("#tools-file-integrity-response-holder .spinner").removeClass("is-active"),e("#tools-file-integrity-response-holder").parent().css("height","auto"),e("#tools-file-integrity-response-holder").html(t.data.message)}))})),e("#tools-file-integrity-response-holder").on("click",'a[href="#health-check-diff"]',(function(t){const c=e(this).data("file");t.preventDefault(),e("#health-check-diff-modal").toggle(),e("#health-check-diff-modal #health-check-diff-modal-content .spinner").addClass("is-active");const l={action:"health-check-view-file-diff",file:c,_wpnonce:HealthCheck.nonce.view_file_diff};e.post(ajaxurl,l,(function(t){e("#health-check-diff-modal #health-check-diff-modal-diff").html(t.data.message),e("#health-check-diff-modal #health-check-diff-modal-content h3").html(c),e("#health-check-diff-modal #health-check-diff-modal-content .spinner").removeClass("is-active")}))}))}))},593:()=>{jQuery(document).ready((function(e){e("#health-check-diff-modal").on("click",'a[href="#health-check-diff-modal-close"]',(function(t){t.preventDefault(),e("#health-check-diff-modal").toggle(),e("#health-check-diff-modal #health-check-diff-modal-diff").html(""),e("#health-check-diff-modal #health-check-diff-modal-content h3").html("")})),e(document).on("keyup",(function(t){27===t.which&&(e("#health-check-diff-modal").css("display","none"),e("#health-check-diff-modal #health-check-diff-modal-diff").html(""),e("#health-check-diff-modal #health-check-diff-modal-content h3").html(""))}))}))},433:()=>{jQuery(document).ready((function(e){e("#health-check-mail-check").on("submit",(function(t){const c=e("#health-check-mail-check #email").val(),l=e("#health-check-mail-check #email_message").val();t.preventDefault(),e("#tools-mail-check-response-holder").html('<span class="spinner"></span>'),e("#tools-mail-check-response-holder .spinner").addClass("is-active");const a={action:"health-check-mail-check",email:c,email_message:l,_wpnonce:HealthCheck.nonce.mail_check};e.post(ajaxurl,a,(function(t){e("#tools-mail-check-response-holder .spinner").removeClass("is-active"),e("#tools-mail-check-response-holder").parent().css("height","auto"),e("#tools-mail-check-response-holder").html(t.data.message)}))}))}))},188:()=>{jQuery(document).ready((function(e){function t(){const c=e('[data-plugin-checked="false"]',"#health-check-tool-plugin-compat-list");if(c.length<=0)return;const l=e(c[0]);l.attr("data-plugin-checked","true");const a={slug:l.data("plugin-slug"),version:l.data("plugin-version"),_wpnonce:HealthCheck.nonce.rest_api};e.post(HealthCheck.rest_api.tools.plugin_compat,a,(function(c){e(".spinner",l).removeClass("is-active"),e(".supported-version",l).append(c.version),t()}))}e("#health-check-tool-plugin-compat").on("click",(function(){e("tr","#health-check-tool-plugin-compat-list").data("plugin-checked",!1),e(".spinner","#health-check-tool-plugin-compat-list").addClass("is-active"),e(this).attr("disabled",!0),t()}))}))}},t={};function c(l){var a=t[l];if(void 0!==a)return a.exports;var o=t[l]={exports:{}};return e[l](o,o.exports,c),o.exports}c.n=e=>{var t=e&&e.__esModule?()=>e.default:()=>e;return c.d(t,{a:t}),t},c.d=(e,t)=>{for(var l in t)c.o(t,l)&&!c.o(e,l)&&Object.defineProperty(e,l,{enumerable:!0,get:t[l]})},c.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),(()=>{"use strict";c(629),c(593),c(433),c(188)})()})();
build/health-check.asset.php ADDED
@@ -0,0 +1 @@
 
1
+ <?php return array('dependencies' => array(), 'version' => '1c4d8753a5d2f87f548e');
build/health-check.css ADDED
@@ -0,0 +1 @@
 
1
+ body.tools_page_site-health #wpcontent,body.wp-admin.site-health-php #wpcontent{padding-left:0}body.tools_page_site-health .notice,body.wp-admin.site-health-php .notice{margin:5px 20px 15px 22px}body.tools_page_site-health .update-nag,body.wp-admin.site-health-php .update-nag{margin-bottom:20px;margin-left:22px}body.tools_page_site-health h2,body.wp-admin.site-health-php h2{line-height:1.4;padding:1rem 0}body.tools_page_site-health .wrap,body.wp-admin.site-health-php .wrap{margin-left:0;margin-right:0}body.tools_page_site-health .wrap h2,body.wp-admin.site-health-php .wrap h2{font-family:inherit;font-size:1.3rem;font-weight:600;padding:1rem .5rem}@media (min-width:960px){body.tools_page_site-health .wrap h2,body.wp-admin.site-health-php .wrap h2{padding:1rem 0}}body.tools_page_site-health ol li,body.tools_page_site-health ul li,body.wp-admin.site-health-php ol li,body.wp-admin.site-health-php ul li{font-size:13px;line-height:1.5}body.tools_page_site-health .wp-core-ui .button,body.wp-admin.site-health-php .wp-core-ui .button{font-size:13px}body.tools_page_site-health .health-check-header,body.wp-admin.site-health-php .health-check-header{background:#fff;border-bottom:1px solid #e2e4e7;margin:0 0 1rem;text-align:center}body.tools_page_site-health .health-check-header .health-check-tabs-wrapper,body.wp-admin.site-health-php .health-check-header .health-check-tabs-wrapper{-ms-grid-columns:1fr 1fr 1fr 1fr;display:-ms-inline-grid;display:inline-grid;grid-template-columns:1fr 1fr 1fr 1fr;vertical-align:top}body.tools_page_site-health .health-check-header .health-check-tabs-wrapper .health-check-tab,body.wp-admin.site-health-php .health-check-header .health-check-tabs-wrapper .health-check-tab{color:inherit;display:block;margin:0 1rem;padding:.5rem 1rem 1rem;text-decoration:none;transition:box-shadow .5s ease-in-out}body.tools_page_site-health .health-check-header .health-check-tabs-wrapper .health-check-tab:first-child,body.wp-admin.site-health-php .health-check-header .health-check-tabs-wrapper .health-check-tab:first-child{-ms-grid-column:1}body.tools_page_site-health .health-check-header .health-check-tabs-wrapper .health-check-tab:nth-child(2),body.wp-admin.site-health-php .health-check-header .health-check-tabs-wrapper .health-check-tab:nth-child(2){-ms-grid-column:2}body.tools_page_site-health .health-check-header .health-check-tabs-wrapper .health-check-tab:nth-child(3),body.wp-admin.site-health-php .health-check-header .health-check-tabs-wrapper .health-check-tab:nth-child(3){-ms-grid-column:3}body.tools_page_site-health .health-check-header .health-check-tabs-wrapper .health-check-tab:nth-child(4),body.wp-admin.site-health-php .health-check-header .health-check-tabs-wrapper .health-check-tab:nth-child(4){-ms-grid-column:4}body.tools_page_site-health .health-check-header .health-check-tabs-wrapper .health-check-tab.active,body.wp-admin.site-health-php .health-check-header .health-check-tabs-wrapper .health-check-tab.active{box-shadow:inset 0 -3px #007cba;font-weight:600}body.tools_page_site-health .health-check-header .health-check-tabs-wrapper .health-check-tab:focus,body.wp-admin.site-health-php .health-check-header .health-check-tabs-wrapper .health-check-tab:focus{box-shadow:none;color:#191e23;outline:1px solid #6c7781}body.tools_page_site-health .health-check-body,body.wp-admin.site-health-php .health-check-body{margin:0 auto;max-width:800px}body.tools_page_site-health .health-check-table,body.wp-admin.site-health-php .health-check-table{table-layout:fixed}body.tools_page_site-health .health-check-table thead td,body.tools_page_site-health .health-check-table thead th,body.wp-admin.site-health-php .health-check-table thead td,body.wp-admin.site-health-php .health-check-table thead th{font-size:13px}body.tools_page_site-health .health-check-table thead td:first-child,body.tools_page_site-health .health-check-table thead th:first-child,body.wp-admin.site-health-php .health-check-table thead td:first-child,body.wp-admin.site-health-php .health-check-table thead th:first-child{width:30%}body.tools_page_site-health .health-check-table tbody td,body.wp-admin.site-health-php .health-check-table tbody td{word-wrap:break-word;box-sizing:border-box;display:block;font-size:13px;width:100%}body.tools_page_site-health .health-check-table tbody td:first-child,body.wp-admin.site-health-php .health-check-table tbody td:first-child{font-weight:600;padding-bottom:0;width:100%}body.tools_page_site-health .health-check-table tbody td ol,body.tools_page_site-health .health-check-table tbody td ul,body.wp-admin.site-health-php .health-check-table tbody td ol,body.wp-admin.site-health-php .health-check-table tbody td ul{margin:0}body.tools_page_site-health .good:before,body.tools_page_site-health .pass:before,body.wp-admin.site-health-php .good:before,body.wp-admin.site-health-php .pass:before{color:#46b450;content:"";display:inline-block;font-family:dashicons}body.tools_page_site-health .warning:before,body.wp-admin.site-health-php .warning:before{color:#ffb900;content:"";display:inline-block;font-family:dashicons}body.tools_page_site-health .info:before,body.wp-admin.site-health-php .info:before{color:#00a0d2;content:"";display:inline-block;font-family:dashicons}body.tools_page_site-health .error:before,body.tools_page_site-health .fail:before,body.wp-admin.site-health-php .error:before,body.wp-admin.site-health-php .fail:before{color:#dc3232;content:"";display:inline-block;font-family:dashicons}body.tools_page_site-health .spinner,body.wp-admin.site-health-php .spinner{float:none}body.tools_page_site-health .site-health-copy-buttons,body.wp-admin.site-health-php .site-health-copy-buttons{display:block;margin:1rem 0}body.tools_page_site-health .site-health-copy-buttons .copy-button-wrapper,body.wp-admin.site-health-php .site-health-copy-buttons .copy-button-wrapper{margin:.5rem 0 1rem}body.tools_page_site-health .site-health-copy-buttons .success,body.wp-admin.site-health-php .site-health-copy-buttons .success{color:#40860a;display:none;height:28px;line-height:2.2;margin-left:.5rem}body.tools_page_site-health .site-health-copy-buttons .success.visible,body.wp-admin.site-health-php .site-health-copy-buttons .success.visible{display:inline-block}body.tools_page_site-health #health-check-debug,body.wp-admin.site-health-php #health-check-debug{margin-bottom:3rem}body.tools_page_site-health .health-check-wp-paths-sizes.spinner,body.wp-admin.site-health-php .health-check-wp-paths-sizes.spinner{float:none;margin:0 4px;position:absolute;visibility:visible}body.tools_page_site-health .file-integrity-table tbody td:first-child,body.tools_page_site-health .file-integrity-table tbody th:first-child,body.tools_page_site-health .file-integrity-table tfoot td:first-child,body.tools_page_site-health .file-integrity-table tfoot th:first-child,body.tools_page_site-health .file-integrity-table thead td:first-child,body.tools_page_site-health .file-integrity-table thead th:first-child,body.wp-admin.site-health-php .file-integrity-table tbody td:first-child,body.wp-admin.site-health-php .file-integrity-table tbody th:first-child,body.wp-admin.site-health-php .file-integrity-table tfoot td:first-child,body.wp-admin.site-health-php .file-integrity-table tfoot th:first-child,body.wp-admin.site-health-php .file-integrity-table thead td:first-child,body.wp-admin.site-health-php .file-integrity-table thead th:first-child{text-align:center;width:60px}body.tools_page_site-health .tools-email-table,body.wp-admin.site-health-php .tools-email-table{border:0;box-shadow:none}body.tools_page_site-health .tools-email-table td:first-child,body.wp-admin.site-health-php .tools-email-table td:first-child{width:280px}@media(max-width:768px){body.tools_page_site-health .tools-email-table td,body.wp-admin.site-health-php .tools-email-table td{display:block}}body.tools_page_site-health .tools-email-table input,body.wp-admin.site-health-php .tools-email-table input{width:100%}body.tools_page_site-health .tools-email-table label,body.wp-admin.site-health-php .tools-email-table label{clear:both;display:block}body.tools_page_site-health #health-check-file-integrity,body.tools_page_site-health #health-check-mail-check,body.wp-admin.site-health-php #health-check-file-integrity,body.wp-admin.site-health-php #health-check-mail-check{margin-bottom:15px}body.tools_page_site-health #health-check-diff-modal,body.wp-admin.site-health-php #health-check-diff-modal{background:rgba(0,0,0,.7);display:none;height:100%;left:0;position:fixed;top:0;width:100vw;z-index:99999}body.tools_page_site-health #health-check-diff-modal #health-check-diff-modal-content,body.wp-admin.site-health-php #health-check-diff-modal #health-check-diff-modal-content{background:#fff;display:block;height:calc(100% - 120px);margin-left:40px;margin-top:40px;padding:20px;width:calc(100% - 120px)}body.tools_page_site-health #health-check-diff-modal #health-check-diff-modal-diff,body.wp-admin.site-health-php #health-check-diff-modal #health-check-diff-modal-diff{display:block;height:calc(100% - 80px);overflow-y:auto;position:relative;width:100%}body.tools_page_site-health #health-check-diff-modal #health-check-diff-modal-diff table.diff td:nth-child(2),body.wp-admin.site-health-php #health-check-diff-modal #health-check-diff-modal-diff table.diff td:nth-child(2){background:#f3f3f3}body.tools_page_site-health #health-check-diff-modal-close-ref,body.wp-admin.site-health-php #health-check-diff-modal-close-ref{color:#000;display:block;float:right;position:relative;text-decoration:none}body.tools_page_site-health .site-health-issues-wrapper,body.wp-admin.site-health-php .site-health-issues-wrapper{margin-bottom:3rem;margin-top:2rem}body.tools_page_site-health .site-health-issues-wrapper:first-of-type,body.wp-admin.site-health-php .site-health-issues-wrapper:first-of-type{margin-top:3rem}body.tools_page_site-health .site-status-has-issues,body.wp-admin.site-health-php .site-status-has-issues{display:block}body.tools_page_site-health .site-status-has-issues.hide,body.wp-admin.site-health-php .site-status-has-issues.hide{display:none}body.tools_page_site-health h3,body.wp-admin.site-health-php h3{font-weight:400;padding:0}body.tools_page_site-health .site-health-view-more,body.wp-admin.site-health-php .site-health-view-more{text-align:center}body.tools_page_site-health .issues-wrapper,body.wp-admin.site-health-php .issues-wrapper{margin-bottom:5rem}body.tools_page_site-health .site-status-all-clear,body.wp-admin.site-health-php .site-status-all-clear{align-items:center;display:flex;flex-direction:column;height:100%;justify-content:center;margin-top:0;text-align:center;width:100%}@media (min-width:784px){body.tools_page_site-health .site-status-all-clear,body.wp-admin.site-health-php .site-status-all-clear{margin:5rem 0}}body.tools_page_site-health .site-status-all-clear.hide,body.wp-admin.site-health-php .site-status-all-clear.hide{display:none}body.tools_page_site-health .site-status-all-clear .dashicons,body.wp-admin.site-health-php .site-status-all-clear .dashicons{font-size:150px;height:130px;width:150px}body.tools_page_site-health .site-status-all-clear .wp-logo,body.wp-admin.site-health-php .site-status-all-clear .wp-logo{height:150px;width:150px}body.tools_page_site-health .site-status-all-clear .encouragement,body.wp-admin.site-health-php .site-status-all-clear .encouragement{font-family:inherit;font-size:1.5rem;font-weight:600}body.tools_page_site-health .site-status-all-clear p,body.wp-admin.site-health-php .site-status-all-clear p{margin:0}body.tools_page_site-health .site-health-view-passed,body.wp-admin.site-health-php .site-health-view-passed{padding-left:20px;padding-right:40px;position:relative}body.tools_page_site-health .site-health-view-passed .icon,body.wp-admin.site-health-php .site-health-view-passed .icon{border:solid #555d66;border-width:0 2px 2px 0;height:.5rem;pointer-events:none;position:absolute;right:1.5em;top:50%;transform:translateY(-70%) rotate(45deg);width:.5rem}body.tools_page_site-health .site-health-view-passed[aria-expanded=true] .icon,body.wp-admin.site-health-php .site-health-view-passed[aria-expanded=true] .icon{transform:translateY(-30%) rotate(-135deg)}body .health-check-accordion{border:1px solid #e2e4e7}body .health-check-accordion .health-check-accordion-heading{border-top:1px solid #e2e4e7;color:inherit;font-size:inherit;font-weight:600;line-height:inherit;margin:0}body .health-check-accordion .health-check-accordion-heading:first-child{border-top:none}body .health-check-accordion .health-check-accordion-trigger{background:#fff;border:0;color:#32373c;cursor:pointer;display:block;font-weight:400;margin:0;padding:1em 3.5em 1em 1.5em;position:relative;text-align:left;width:100%}body .health-check-accordion .health-check-accordion-trigger:active,body .health-check-accordion .health-check-accordion-trigger:hover{background:#f8f9f9}body .health-check-accordion .health-check-accordion-trigger:focus{border:none;box-shadow:none;color:#191e23;outline:1px dotted #555d66;outline-offset:-2px}body .health-check-accordion .health-check-accordion-trigger .title{display:inline-block;font-weight:600;pointer-events:none}body .health-check-accordion .health-check-accordion-trigger .icon{border:solid #555d66;border-width:0 2px 2px 0;height:.5rem;pointer-events:none;position:absolute;right:1.5em;top:50%;transform:translateY(-70%) rotate(45deg);width:.5rem}body .health-check-accordion .health-check-accordion-trigger .badge{color:#32373c;float:right;font-weight:600;margin-left:.5rem;padding:.1rem .5rem .15rem}body .health-check-accordion .health-check-accordion-trigger .badge.blue{border:1px solid #bfe7f3}body .health-check-accordion .health-check-accordion-trigger .badge.orange{border:1px solid #ffb900}body .health-check-accordion .health-check-accordion-trigger .badge.red{border:1px solid #dc3232}body .health-check-accordion .health-check-accordion-trigger .badge.green{border:1px solid #46b450}body .health-check-accordion .health-check-accordion-trigger .badge.purple{border:1px solid #826eb4}body .health-check-accordion .health-check-accordion-trigger .badge.gray{border:1px solid #ccd0d4}body .health-check-accordion .health-check-accordion-trigger[aria-expanded=true] .icon{transform:translateY(-30%) rotate(-135deg)}body .health-check-accordion .health-check-accordion-panel{background:#fff;margin:0;padding:1em 1.5em}body .health-check-accordion .health-check-accordion-panel>div{display:block}body .health-check-accordion .health-check-accordion-panel[hidden]{display:none}body .health-check-accordion .health-check-accordion-panel a .dashicons{text-decoration:none}body .health-check-accordion dl dd{margin:0 0 .5em 2em}.health-check-modal{background-color:#000;background-color:rgba(0,0,0,.4);display:none;height:100%;left:0;overflow:auto;padding-top:50px;position:absolute;top:0;width:100%;z-index:1000}@media (min-width:1024px){.health-check-modal{padding-top:100px}}.health-check-modal.show{display:block}.health-check-modal .modal-content{background-color:#fefefe;border:1px solid #888;margin:auto;padding:20px;width:90%}@media (min-width:1024px){.health-check-modal .modal-content{width:30%}}.health-check-modal .modal-content .modal-close{color:#aaa;cursor:pointer;float:right;font-size:28px;font-weight:600}.health-check-modal .modal-content #dynamic-content{display:block;width:100%}.health-check-modal .modal-close:focus,.health-check-modal .modal-close:hover{color:#aaa;float:right;font-size:28px;font-weight:600}.health-check-title-section{align-items:center;clear:both;display:flex;justify-content:center}.health-check-title-section h1{display:inline-block;font-family:inherit;font-size:23px;font-weight:600;line-height:1.3;margin:0 .8rem 1rem;padding:9px 0 4px}.health-check-title-section.site-health-progress-wrapper{margin-bottom:1rem}.health-check-title-section.site-health-progress-wrapper.loading .site-health-progress svg #bar{stroke-dashoffset:0;stroke:#adc5d2;-webkit-animation:loadingPulse 3s ease-in-out infinite;animation:loadingPulse 3s ease-in-out infinite}@-webkit-keyframes loadingPulse{0%{stroke:#adc5d2}50%{stroke:#00a0d2}to{stroke:#adc5d2}}@keyframes loadingPulse{0%{stroke:#adc5d2}50%{stroke:#00a0d2}to{stroke:#adc5d2}}.health-check-title-section.site-health-progress-wrapper.green #bar{stroke:#46b450}.health-check-title-section.site-health-progress-wrapper.green .site-health-progress-label{color:#46b450}.health-check-title-section.site-health-progress-wrapper.orange #bar{stroke:#ffb900}.health-check-title-section.site-health-progress-wrapper.orange .site-health-progress-label{color:#ffb900}.health-check-title-section.site-health-progress-wrapper .site-health-progress{border-radius:100%;display:inline-block;font-size:.4rem;font-weight:600;height:20px;margin:0;position:relative;width:20px}.health-check-title-section.site-health-progress-wrapper .site-health-progress svg circle{stroke-dashoffset:0;stroke:#ccc;stroke-width:3em;transition:stroke-dashoffset 1s linear}.health-check-title-section.site-health-progress-wrapper .site-health-progress svg #bar{stroke-dashoffset:565}.health-check-title-section.site-health-progress-wrapper .site-health-progress-label{font-weight:600;line-height:20px;margin-left:.3rem}#health-check-dashboard-widget{grid-gap:2%;background:#fff;display:grid;grid-template-columns:100%;padding:13px}@media (min-width:783px){#health-check-dashboard-widget{grid-template-columns:49% 49%;margin-top:3rem}}#health-check-dashboard-widget h2 .green{color:#40860a}#health-check-dashboard-widget .welcome-panel-content{display:block;max-width:none}#health-check-dashboard-widget #health-check-accordion-block-notices .no-notices p{color:#72777c;font-size:1.2rem}#health-check-dashboard-widget #health-check-accordion-block-notices .notice{color:#72777c;margin-left:0}#health-check-dashboard-widget #health-check-accordion-block-notices .notice p{font-size:13px}#health-check-dashboard-widget #health-check-accordion-block-notices .dismiss-notices{display:block;margin-right:1rem;text-align:right;width:100%}#health-check-dashboard-widget .disable-troubleshooting-mode{margin-bottom:1rem}@media (min-width:960px){#health-check-dashboard-widget .disable-troubleshooting-mode{bottom:1rem;position:absolute;right:1rem}}#health-check-dashboard-widget ul li{font-size:13px}@media (max-width:870px){#health-check-dashboard-widget ul li{display:inline-block;width:100%}}#health-check-dashboard-widget .about-description{display:inline-block;margin:1em 0;max-width:700px}#health-check-dashboard-widget .about-description p{color:inherit;font-size:16px}
build/health-check.js ADDED
@@ -0,0 +1 @@
 
1
+ (()=>{var t={368:()=>{jQuery(document).ready((function(t){t(".health-check-accordion").on("click",".health-check-accordion-trigger",(function(){"true"===t(this).attr("aria-expanded")?(t(this).attr("aria-expanded","false"),t("#"+t(this).attr("aria-controls")).attr("hidden",!0)):(t(this).attr("aria-expanded","true"),t("#"+t(this).attr("aria-controls")).attr("hidden",!1))}))}))}},r={};function e(a){var o=r[a];if(void 0!==o)return o.exports;var n=r[a]={exports:{}};return t[a](n,n.exports,e),n.exports}e.n=t=>{var r=t&&t.__esModule?()=>t.default:()=>t;return e.d(r,{a:r}),r},e.d=(t,r)=>{for(var a in r)e.o(r,a)&&!e.o(t,a)&&Object.defineProperty(t,a,{enumerable:!0,get:r[a]})},e.o=(t,r)=>Object.prototype.hasOwnProperty.call(t,r),(()=>{"use strict";e(368)})()})();
build/troubleshooting-mode.asset.php ADDED
@@ -0,0 +1 @@
 
1
+ <?php return array('dependencies' => array(), 'version' => '9fb4d8aebf14252d8925');
build/troubleshooting-mode.js ADDED
@@ -0,0 +1 @@
 
1
+ (()=>{var e={407:()=>{jQuery(document).ready((function(e){e(".show-remaining").click((function(){e(".hidden",e(this).closest("ul")).removeClass("hidden")}))}))}},r={};function t(o){var n=r[o];if(void 0!==n)return n.exports;var i=r[o]={exports:{}};return e[o](i,i.exports,t),i.exports}t.n=e=>{var r=e&&e.__esModule?()=>e.default:()=>e;return t.d(r,{a:r}),r},t.d=(e,r)=>{for(var o in r)t.o(r,o)&&!t.o(e,o)&&Object.defineProperty(e,o,{enumerable:!0,get:r[o]})},t.o=(e,r)=>Object.prototype.hasOwnProperty.call(e,r),(()=>{"use strict";t(407)})()})();
includes/compat.php → compat.php RENAMED
@@ -3,6 +3,90 @@
3
  // Manually include the versions file as we can't always rely on `get_bloginfo()` to fetch versions.
4
  include ABSPATH . WPINC . '/version.php';
5
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
6
  if ( ! function_exists( 'wp_check_php_version' ) && version_compare( '5.1', $wp_version, '>' ) ) {
7
  /**
8
  * Fallback function replicating core behavior from WordPress 5.1.0 to check PHP versions.
3
  // Manually include the versions file as we can't always rely on `get_bloginfo()` to fetch versions.
4
  include ABSPATH . WPINC . '/version.php';
5
 
6
+ if ( ! function_exists( 'wp_timezone_string' ) ) {
7
+ /**
8
+ * Fallback function for replicating core behavior from WordPress 5.3.0 to get a timezone string
9
+ *
10
+ * @return string PHP timezone string or a ±HH:MM offset.
11
+ */
12
+ function wp_timezone_string() {
13
+ $timezone_string = get_option( 'timezone_string' );
14
+
15
+ if ( $timezone_string ) {
16
+ return $timezone_string;
17
+ }
18
+
19
+ $offset = (float) get_option( 'gmt_offset' );
20
+ $hours = (int) $offset;
21
+ $minutes = ( $offset - $hours );
22
+
23
+ $sign = ( $offset < 0 ) ? '-' : '+';
24
+ $abs_hour = abs( $hours );
25
+ $abs_mins = abs( $minutes * 60 );
26
+ $tz_offset = sprintf( '%s%02d:%02d', $sign, $abs_hour, $abs_mins );
27
+
28
+ return $tz_offset;
29
+ }
30
+ }
31
+
32
+ if ( ! function_exists( 'wp_get_environment_type' ) ) {
33
+ /**
34
+ * Fallback function replicating core behavior from WordPress 5.5.0 to get the current environment used.
35
+ *
36
+ * @return string The current environment type.
37
+ */
38
+ function wp_get_environment_type() {
39
+ static $current_env = '';
40
+
41
+ if ( $current_env ) {
42
+ return $current_env;
43
+ }
44
+
45
+ $wp_environments = array(
46
+ 'local',
47
+ 'development',
48
+ 'staging',
49
+ 'production',
50
+ );
51
+
52
+ // Add a note about the deprecated WP_ENVIRONMENT_TYPES constant.
53
+ if ( defined( 'WP_ENVIRONMENT_TYPES' ) && function_exists( '_deprecated_argument' ) ) {
54
+ if ( function_exists( '__' ) ) {
55
+ /* translators: %s: WP_ENVIRONMENT_TYPES */
56
+ $message = sprintf( __( 'The %s constant is no longer supported.' ), 'WP_ENVIRONMENT_TYPES' );
57
+ } else {
58
+ $message = sprintf( 'The %s constant is no longer supported.', 'WP_ENVIRONMENT_TYPES' );
59
+ }
60
+
61
+ _deprecated_argument(
62
+ 'define()',
63
+ '5.5.1',
64
+ $message
65
+ );
66
+ }
67
+
68
+ // Check if the environment variable has been set, if `getenv` is available on the system.
69
+ if ( function_exists( 'getenv' ) ) {
70
+ $has_env = getenv( 'WP_ENVIRONMENT_TYPE' );
71
+ if ( false !== $has_env ) {
72
+ $current_env = $has_env;
73
+ }
74
+ }
75
+
76
+ // Fetch the environment from a constant, this overrides the global system variable.
77
+ if ( defined( 'WP_ENVIRONMENT_TYPE' ) ) {
78
+ $current_env = WP_ENVIRONMENT_TYPE;
79
+ }
80
+
81
+ // Make sure the environment is an allowed one, and not accidentally set to an invalid value.
82
+ if ( ! in_array( $current_env, $wp_environments, true ) ) {
83
+ $current_env = 'production';
84
+ }
85
+
86
+ return $current_env;
87
+ }
88
+ }
89
+
90
  if ( ! function_exists( 'wp_check_php_version' ) && version_compare( '5.1', $wp_version, '>' ) ) {
91
  /**
92
  * Fallback function replicating core behavior from WordPress 5.1.0 to check PHP versions.
health-check.php CHANGED
@@ -9,33 +9,22 @@
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.4.5
13
  * Author URI: https://wordpress.org/plugins/health-check/
14
  * Text Domain: health-check
15
  */
16
 
 
 
17
  // Check that the file is not accessed directly.
 
 
18
  if ( ! defined( 'ABSPATH' ) ) {
19
  die( 'We\'re sorry, but you can not directly access this file.' );
20
  }
21
 
22
- // Set the minimum PHP version WordPress supports.
23
- define( 'HEALTH_CHECK_PHP_MIN_VERSION', '5.2.4' );
24
-
25
- // Set the lowest PHP version still receiving security updates.
26
- define( 'HEALTH_CHECK_PHP_SUPPORTED_VERSION', '5.6' );
27
-
28
- // Set the PHP version WordPress recommends.
29
- define( 'HEALTH_CHECK_PHP_REC_VERSION', '7.2' );
30
-
31
- // Set the minimum MySQL version WordPress supports.
32
- define( 'HEALTH_CHECK_MYSQL_MIN_VERSION', '5.0' );
33
-
34
- // Set the MySQL version WordPress recommends.
35
- define( 'HEALTH_CHECK_MYSQL_REC_VERSION', '5.6' );
36
-
37
  // Set the plugin version.
38
- define( 'HEALTH_CHECK_PLUGIN_VERSION', '1.4.5' );
39
 
40
  // Set the plugin file.
41
  define( 'HEALTH_CHECK_PLUGIN_FILE', __FILE__ );
@@ -46,42 +35,44 @@ define( 'HEALTH_CHECK_PLUGIN_DIRECTORY', plugin_dir_path( __FILE__ ) );
46
  // Set the plugin URL root.
47
  define( 'HEALTH_CHECK_PLUGIN_URL', plugins_url( '/', __FILE__ ) );
48
 
49
- // Set the current cURL version.
50
- define( 'HEALTH_CHECK_CURL_VERSION', '7.58' );
51
-
52
- // Set the minimum cURL version that we've tested that core works with.
53
- define( 'HEALTH_CHECK_CURL_MIN_VERSION', '7.38' );
54
-
55
  // Always include our compatibility file first.
56
- require_once( dirname( __FILE__ ) . '/includes/compat.php' );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
57
 
58
  // Include class-files used by our plugin.
59
- require_once( dirname( __FILE__ ) . '/includes/class-health-check.php' );
60
- require_once( dirname( __FILE__ ) . '/includes/class-health-check-auto-updates.php' );
61
- require_once( dirname( __FILE__ ) . '/includes/class-health-check-wp-cron.php' );
62
- require_once( dirname( __FILE__ ) . '/includes/class-health-check-debug-data.php' );
63
- require_once( dirname( __FILE__ ) . '/includes/class-health-check-loopback.php' );
64
- require_once( dirname( __FILE__ ) . '/includes/class-health-check-troubleshoot.php' );
65
- require_once( dirname( __FILE__ ) . '/includes/class-health-check-site-status.php' );
66
- require_once( dirname( __FILE__ ) . '/includes/class-health-check-updates.php' );
67
- require_once( dirname( __FILE__ ) . '/includes/class-health-check-dashboard-widget.php' );
68
 
69
  // Tools section.
70
- require_once( dirname( __FILE__ ) . '/includes/tools/class-health-check-tool.php' );
71
- require_once( dirname( __FILE__ ) . '/includes/tools/class-health-check-files-integrity.php' );
72
- require_once( dirname( __FILE__ ) . '/includes/tools/class-health-check-mail-check.php' );
73
- require_once( dirname( __FILE__ ) . '/includes/tools/class-health-check-plugin-compatibility.php' );
 
74
 
75
  // Initialize our plugin.
76
  new Health_Check();
77
 
78
- // Initialize the dashboard widget.
79
- new Health_Check_Dashboard_Widget();
80
-
81
- // Setup up scheduled events.
82
- register_activation_hook( __FILE__, array( 'Health_Check', 'plugin_activation' ) );
83
- register_deactivation_hook( __FILE__, array( 'Health_Check', 'plugin_deactivation' ) );
84
-
85
  if ( defined( 'WP_CLI' ) && WP_CLI ) {
86
- require_once( dirname( __FILE__ ) . '/includes/class-health-check-wp-cli.php' );
87
  }
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.5.0
13
  * Author URI: https://wordpress.org/plugins/health-check/
14
  * Text Domain: health-check
15
  */
16
 
17
+ namespace HealthCheck;
18
+
19
  // Check that the file is not accessed directly.
20
+ use Health_Check;
21
+
22
  if ( ! defined( 'ABSPATH' ) ) {
23
  die( 'We\'re sorry, but you can not directly access this file.' );
24
  }
25
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
26
  // Set the plugin version.
27
+ define( 'HEALTH_CHECK_PLUGIN_VERSION', '1.5.0' );
28
 
29
  // Set the plugin file.
30
  define( 'HEALTH_CHECK_PLUGIN_FILE', __FILE__ );
35
  // Set the plugin URL root.
36
  define( 'HEALTH_CHECK_PLUGIN_URL', plugins_url( '/', __FILE__ ) );
37
 
 
 
 
 
 
 
38
  // Always include our compatibility file first.
39
+ require_once( dirname( __FILE__ ) . '/compat.php' );
40
+
41
+ // Backwards compatible pull in of extra resources
42
+ if ( ! class_exists( 'WP_Debug_Data' ) ) {
43
+ $original_paths = array(
44
+ 'class-wp-site-health.php' => ABSPATH . '/wp-admin/includes/class-wp-site-health.php',
45
+ 'class-wp-debug-data.php' => ABSPATH . '/wp-admin/includes/class-wp-debug-data.php',
46
+ );
47
+
48
+ foreach ( $original_paths as $filename => $original_path ) {
49
+ if ( file_exists( $original_path ) ) {
50
+ require_once $original_path;
51
+ } else {
52
+ require_once __DIR__ . '/HealthCheck/BackCompat/' . $filename;
53
+
54
+ if ( ! defined( 'HEALTH_CHECK_BACKCOMPAT_LOADED' ) ) {
55
+ define( 'HEALTH_CHECK_BACKCOMPAT_LOADED', true );
56
+ }
57
+ }
58
+ }
59
+ }
60
 
61
  // Include class-files used by our plugin.
62
+ require_once( dirname( __FILE__ ) . '/HealthCheck/class-health-check.php' );
63
+ require_once( dirname( __FILE__ ) . '/HealthCheck/class-health-check-loopback.php' );
64
+ require_once( dirname( __FILE__ ) . '/HealthCheck/class-health-check-troubleshoot.php' );
 
 
 
 
 
 
65
 
66
  // Tools section.
67
+ require_once( dirname( __FILE__ ) . '/HealthCheck/Tools/class-health-check-tool.php' );
68
+ require_once( dirname( __FILE__ ) . '/HealthCheck/Tools/class-health-check-files-integrity.php' );
69
+ require_once( dirname( __FILE__ ) . '/HealthCheck/Tools/class-health-check-mail-check.php' );
70
+ require_once( dirname( __FILE__ ) . '/HealthCheck/Tools/class-health-check-plugin-compatibility.php' );
71
+ require_once( dirname( __FILE__ ) . '/HealthCheck/Tools/class-health-check-phpinfo.php' );
72
 
73
  // Initialize our plugin.
74
  new Health_Check();
75
 
 
 
 
 
 
 
 
76
  if ( defined( 'WP_CLI' ) && WP_CLI ) {
77
+ require_once( dirname( __FILE__ ) . '/HealthCheck/class-cli.php' );
78
  }
includes/class-health-check-auto-updates.php DELETED
@@ -1,453 +0,0 @@
1
- <?php
2
- /**
3
- * Class for testing automatic updates in the WordPress code.
4
- *
5
- * @package Health Check
6
- */
7
-
8
- // Make sure the file is not directly accessible.
9
- if ( ! defined( 'ABSPATH' ) ) {
10
- die( 'We\'re sorry, but you can not directly access this file.' );
11
- }
12
-
13
- /**
14
- * Class Health_Check_Auto_Updates
15
- */
16
- class Health_Check_Auto_Updates {
17
- /**
18
- * WP_Site_Health_Auto_Updates constructor.
19
- * @since 5.2.0
20
- */
21
- public function __construct() {
22
- include_once ABSPATH . 'wp-admin/includes/class-wp-upgrader.php';
23
- }
24
-
25
- public function run_tests() {
26
- $tests = array();
27
-
28
- foreach ( get_class_methods( $this ) as $method ) {
29
- if ( 'test_' !== substr( $method, 0, 5 ) ) {
30
- continue;
31
- }
32
-
33
- $result = call_user_func( array( $this, $method ) );
34
-
35
- if ( false === $result || null === $result ) {
36
- continue;
37
- }
38
-
39
- $result = (object) $result;
40
-
41
- if ( empty( $result->severity ) ) {
42
- $result->severity = 'warning';
43
- }
44
-
45
- $tests[ $method ] = $result;
46
- }
47
-
48
- return $tests;
49
- }
50
-
51
- public function test_contant_DISALLOW_FILE_MODS() {
52
- return $this->check_constants( 'DISALLOW_FILE_MODS', false );
53
- }
54
-
55
- public function test_contant_AUTOMATIC_UPDATER_DISABLED() {
56
- return $this->check_constants( 'AUTOMATIC_UPDATER_DISABLED', false );
57
- }
58
-
59
- public function test_contant_WP_AUTO_UPDATE_CORE() {
60
- return $this->check_constants( 'WP_AUTO_UPDATE_CORE', true );
61
- }
62
-
63
- /**
64
- * Test if auto-updates related constants are set correctly.
65
- *
66
- * @since 5.2.0
67
- *
68
- * @param string $constant The name of the constant to check.
69
- * @param bool $value The value that the constant should be, if set.
70
- * @return array The test results.
71
- */
72
- public function check_constants( $constant, $value ) {
73
- if ( defined( $constant ) && constant( $constant ) != $value ) {
74
- return array(
75
- 'description' => sprintf(
76
- /* translators: %s: Name of the constant used. */
77
- __( 'The %s constant is defined and enabled.', 'health-check' ),
78
- "<code>$constant</code>"
79
- ),
80
- 'severity' => 'fail',
81
- );
82
- }
83
- }
84
-
85
- /**
86
- * Check if updates are intercepted by a filter.
87
- *
88
- * @since 5.2.0
89
- *
90
- * @return array The test results.
91
- */
92
- public function test_wp_version_check_attached() {
93
- if ( ! is_main_site() ) {
94
- return;
95
- }
96
-
97
- $cookies = wp_unslash( $_COOKIE );
98
- $timeout = 10;
99
- $headers = array(
100
- 'Cache-Control' => 'no-cache',
101
- );
102
-
103
- // Include Basic auth in loopback requests.
104
- if ( isset( $_SERVER['PHP_AUTH_USER'] ) && isset( $_SERVER['PHP_AUTH_PW'] ) ) {
105
- $headers['Authorization'] = 'Basic ' . base64_encode( wp_unslash( $_SERVER['PHP_AUTH_USER'] ) . ':' . wp_unslash( $_SERVER['PHP_AUTH_PW'] ) );
106
- }
107
-
108
- $url = add_query_arg(
109
- array(
110
- 'health-check-test-wp_version_check' => true,
111
- ),
112
- admin_url( '' )
113
- );
114
-
115
- $test = wp_remote_get( $url, compact( 'cookies', 'headers', 'timeout' ) );
116
-
117
- if ( is_wp_error( $test ) ) {
118
- return array(
119
- 'description' => sprintf(
120
- /* translators: %s: Name of the filter used. */
121
- __( 'Could not confirm that the %s filter is available.', 'health-check' ),
122
- '<code>wp_version_check()</code>'
123
- ),
124
- 'severity' => 'warning',
125
- );
126
- }
127
-
128
- $response = wp_remote_retrieve_body( $test );
129
-
130
- if ( 'yes' !== $response ) {
131
- return array(
132
- 'description' => sprintf(
133
- /* translators: %s: Name of the filter used. */
134
- __( 'A plugin has prevented updates by disabling %s.', 'health-check' ),
135
- '<code>wp_version_check()</code>'
136
- ),
137
- 'severity' => 'fail',
138
- );
139
- }
140
- }
141
-
142
- /**
143
- * Check if automatic updates are disabled by a filter.
144
- *
145
- * @since 5.2.0
146
- *
147
- * @return array The test results.
148
- */
149
- public function test_filters_automatic_updater_disabled() {
150
- if ( apply_filters( 'automatic_updater_disabled', false ) ) {
151
- return array(
152
- 'description' => sprintf(
153
- /* translators: %s: Name of the filter used. */
154
- __( 'The %s filter is enabled.', 'health-check' ),
155
- '<code>automatic_updater_disabled</code>'
156
- ),
157
- 'severity' => 'fail',
158
- );
159
- }
160
- }
161
-
162
- /**
163
- * Check if automatic updates have tried to run, but failed, previously.
164
- *
165
- * @since 5.2.0
166
- *
167
- * @return array|bool The test results. false if the auto updates failed.
168
- */
169
- function test_if_failed_update() {
170
- $failed = get_site_option( 'auto_core_update_failed' );
171
-
172
- if ( ! $failed ) {
173
- return false;
174
- }
175
-
176
- if ( ! empty( $failed['critical'] ) ) {
177
- $description = __( 'A previous automatic background update ended with a critical failure, so updates are now disabled.', 'health-check' );
178
- $description .= ' ' . __( 'You would have received an email because of this.', 'health-check' );
179
- $description .= ' ' . __( "When you've been able to update using the \"Update Now\" button on Dashboard > Updates, we'll clear this error for future update attempts.", 'health-check' );
180
- $description .= ' ' . sprintf(
181
- /* translators: %s: Code of error shown. */
182
- __( 'The error code was %s.', 'health-check' ),
183
- '<code>' . $failed['error_code'] . '</code>'
184
- );
185
- return array(
186
- 'description' => $description,
187
- 'severity' => 'warning',
188
- );
189
- }
190
-
191
- $description = __( 'A previous automatic background update could not occur.', 'health-check' );
192
- if ( empty( $failed['retry'] ) ) {
193
- $description .= ' ' . __( 'You would have received an email because of this.', 'health-check' );
194
- }
195
-
196
- $description .= ' ' . __( "We'll try again with the next release.", 'health-check' );
197
- $description .= ' ' . sprintf(
198
- /* translators: %s: Code of error shown. */
199
- __( 'The error code was %s.', 'health-check' ),
200
- '<code>' . $failed['error_code'] . '</code>'
201
- );
202
- return array(
203
- 'description' => $description,
204
- 'severity' => 'warning',
205
- );
206
- }
207
-
208
- /**
209
- * Check if WordPress is controlled by a VCS (Git, Subversion etc).
210
- *
211
- * @since 5.2.0
212
- *
213
- * @return array The test results.
214
- */
215
- public function test_vcs_abspath() {
216
- $context_dirs = array( ABSPATH );
217
- $vcs_dirs = array( '.svn', '.git', '.hg', '.bzr' );
218
- $check_dirs = array();
219
-
220
- foreach ( $context_dirs as $context_dir ) {
221
- // Walk up from $context_dir to the root.
222
- do {
223
- $check_dirs[] = $context_dir;
224
-
225
- // Once we've hit '/' or 'C:\', we need to stop. dirname will keep returning the input here.
226
- if ( dirname( $context_dir ) == $context_dir ) {
227
- break;
228
- }
229
-
230
- // Continue one level at a time.
231
- } while ( $context_dir = dirname( $context_dir ) );
232
- }
233
-
234
- $check_dirs = array_unique( $check_dirs );
235
-
236
- // Search all directories we've found for evidence of version control.
237
- foreach ( $vcs_dirs as $vcs_dir ) {
238
- foreach ( $check_dirs as $check_dir ) {
239
- // phpcs:ignore
240
- if ( $checkout = @is_dir( rtrim( $check_dir, '\\/' ) . "/$vcs_dir" ) ) {
241
- break 2;
242
- }
243
- }
244
- }
245
-
246
- if ( $checkout && ! apply_filters( 'automatic_updates_is_vcs_checkout', true, ABSPATH ) ) {
247
- return array(
248
- 'description' => sprintf(
249
- // translators: 1: Folder name. 2: Version control directory. 3: Filter name.
250
- __( 'The folder %1$s was detected as being under version control (%2$s), but the %3$s filter is allowing updates.', 'health-check' ),
251
- '<code>' . $check_dir . '</code>',
252
- "<code>$vcs_dir</code>",
253
- '<code>automatic_updates_is_vcs_checkout</code>'
254
- ),
255
- 'severity' => 'info',
256
- );
257
- }
258
-
259
- if ( $checkout ) {
260
- return array(
261
- 'description' => sprintf(
262
- // translators: 1: Folder name. 2: Version control directory.
263
- __( 'The folder %1$s was detected as being under version control (%2$s).', 'health-check' ),
264
- '<code>' . $check_dir . '</code>',
265
- "<code>$vcs_dir</code>"
266
- ),
267
- 'severity' => 'fail',
268
- );
269
- }
270
-
271
- return array(
272
- 'description' => __( 'No version control systems were detected.', 'health-check' ),
273
- 'severity' => 'pass',
274
- );
275
- }
276
-
277
- /**
278
- * Check if we can access files without providing credentials.
279
- *
280
- * @since 5.2.0
281
- *
282
- * @return array The test results.
283
- */
284
- function test_check_wp_filesystem_method() {
285
- $skin = new Automatic_Upgrader_Skin;
286
- $success = $skin->request_filesystem_credentials( false, ABSPATH );
287
-
288
- if ( ! $success ) {
289
- $description = __( 'Your installation of WordPress prompts for FTP credentials to perform updates.', 'health-check' );
290
- $description .= ' ' . __( '(Your site is performing updates over FTP due to file ownership. Talk to your hosting company.)', 'health-check' );
291
-
292
- return array(
293
- 'description' => $description,
294
- 'severity' => 'fail',
295
- );
296
- }
297
-
298
- return array(
299
- 'description' => __( "Your installation of WordPress doesn't require FTP credentials to perform updates.", 'health-check' ),
300
- 'severity' => 'pass',
301
- );
302
- }
303
-
304
- /**
305
- * Check if core files are writable by the web user/group.
306
- *
307
- * @since 5.2.0
308
- *
309
- * @global WP_Filesystem_Base $wp_filesystem WordPress filesystem subclass.
310
- *
311
- * @return array|bool The test results. false if they're not writeable.
312
- */
313
- function test_all_files_writable() {
314
- global $wp_filesystem;
315
-
316
- include ABSPATH . WPINC . '/version.php'; // $wp_version; // x.y.z
317
-
318
- $skin = new Automatic_Upgrader_Skin;
319
- $success = $skin->request_filesystem_credentials( false, ABSPATH );
320
-
321
- if ( ! $success ) {
322
- return false;
323
- }
324
-
325
- WP_Filesystem();
326
-
327
- if ( 'direct' != $wp_filesystem->method ) {
328
- return false;
329
- }
330
-
331
- $checksums = get_core_checksums( $wp_version, 'en_US' );
332
- $dev = ( false !== strpos( $wp_version, '-' ) );
333
- // Get the last stable version's files and test against that
334
- if ( ! $checksums && $dev ) {
335
- $checksums = get_core_checksums( (float) $wp_version - 0.1, 'en_US' );
336
- }
337
-
338
- // There aren't always checksums for development releases, so just skip the test if we still can't find any
339
- if ( ! $checksums && $dev ) {
340
- return false;
341
- }
342
-
343
- if ( ! $checksums ) {
344
- $description = sprintf(
345
- // translators: %s: WordPress version
346
- __( "Couldn't retrieve a list of the checksums for WordPress %s.", 'health-check' ),
347
- $wp_version
348
- );
349
- $description .= ' ' . __( 'This could mean that connections are failing to WordPress.org.', 'health-check' );
350
- return array(
351
- 'description' => $description,
352
- 'severity' => 'warning',
353
- );
354
- }
355
-
356
- $unwritable_files = array();
357
- foreach ( array_keys( $checksums ) as $file ) {
358
- if ( 'wp-content' == substr( $file, 0, 10 ) ) {
359
- continue;
360
- }
361
- if ( ! file_exists( ABSPATH . $file ) ) {
362
- continue;
363
- }
364
- if ( ! is_writable( ABSPATH . $file ) ) {
365
- $unwritable_files[] = $file;
366
- }
367
- }
368
-
369
- if ( $unwritable_files ) {
370
- if ( count( $unwritable_files ) > 20 ) {
371
- $unwritable_files = array_slice( $unwritable_files, 0, 20 );
372
- $unwritable_files[] = '...';
373
- }
374
- return array(
375
- 'description' => __( 'Some files are not writable by WordPress:', 'health-check' ) . ' <ul><li>' . implode( '</li><li>', $unwritable_files ) . '</li></ul>',
376
- 'severity' => 'fail',
377
- );
378
- } else {
379
- return array(
380
- 'description' => __( 'All of your WordPress files are writable.', 'health-check' ),
381
- 'severity' => 'pass',
382
- );
383
- }
384
- }
385
-
386
- /**
387
- * Check if the install is using a development branch and can use nightly packages.
388
- *
389
- * @since 5.2.0
390
- *
391
- * @return array|bool The test results. false if it isn't a development version.
392
- */
393
- function test_accepts_dev_updates() {
394
- include ABSPATH . WPINC . '/version.php'; // $wp_version; // x.y.z
395
- // Only for dev versions
396
- if ( false === strpos( $wp_version, '-' ) ) {
397
- return false;
398
- }
399
-
400
- if ( defined( 'WP_AUTO_UPDATE_CORE' ) && ( 'minor' === WP_AUTO_UPDATE_CORE || false === WP_AUTO_UPDATE_CORE ) ) {
401
- return array(
402
- 'description' => sprintf(
403
- /* translators: %s: Name of the constant used. */
404
- __( 'WordPress development updates are blocked by the %s constant.', 'health-check' ),
405
- '<code>WP_AUTO_UPDATE_CORE</code>'
406
- ),
407
- 'severity' => 'fail',
408
- );
409
- }
410
-
411
- if ( ! apply_filters( 'allow_dev_auto_core_updates', $wp_version ) ) {
412
- return array(
413
- 'description' => sprintf(
414
- /* translators: %s: Name of the filter used. */
415
- __( 'WordPress development updates are blocked by the %s filter.', 'health-check' ),
416
- '<code>allow_dev_auto_core_updates</code>'
417
- ),
418
- 'severity' => 'fail',
419
- );
420
- }
421
- }
422
-
423
- /**
424
- * Check if the site supports automatic minor updates.
425
- *
426
- * @since 5.2.0
427
- *
428
- * @return array The test results.
429
- */
430
- function test_accepts_minor_updates() {
431
- if ( defined( 'WP_AUTO_UPDATE_CORE' ) && false === WP_AUTO_UPDATE_CORE ) {
432
- return array(
433
- 'description' => sprintf(
434
- /* translators: %s: Name of the constant used. */
435
- __( 'WordPress security and maintenance releases are blocked by %s.', 'health-check' ),
436
- "<code>define( 'WP_AUTO_UPDATE_CORE', false );</code>"
437
- ),
438
- 'severity' => 'fail',
439
- );
440
- }
441
-
442
- if ( ! apply_filters( 'allow_minor_auto_core_updates', true ) ) {
443
- return array(
444
- 'description' => sprintf(
445
- /* translators: %s: Name of the filter used. */
446
- __( 'WordPress security and maintenance releases are blocked by the %s filter.', 'health-check' ),
447
- '<code>allow_minor_auto_core_updates</code>'
448
- ),
449
- 'severity' => 'fail',
450
- );
451
- }
452
- }
453
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
includes/class-health-check-dashboard-widget.php DELETED
@@ -1,101 +0,0 @@
1
- <?php
2
-
3
- // Check that the file is not accessed directly.
4
- if ( ! defined( 'ABSPATH' ) ) {
5
- die( 'We\'re sorry, but you can not directly access this file.' );
6
- }
7
-
8
- class Health_Check_Dashboard_Widget {
9
-
10
- public function __construct() {
11
- add_action( 'wp_dashboard_setup', array( $this, 'dashboard_setup' ) );
12
- }
13
-
14
- function dashboard_setup() {
15
- global $wp_meta_boxes;
16
-
17
- if ( ! isset( $wp_meta_boxes['dashboard']['normal']['core']['dashboard_site_health'] ) ) {
18
- wp_add_dashboard_widget(
19
- 'dashboard_site_health',
20
- __( 'Site Health Status', 'health-check' ),
21
- array( $this, 'widget_render' )
22
- );
23
- } else {
24
- $wp_meta_boxes['dashboard']['normal']['core']['dashboard_site_health']['callback'] = array( $this, 'widget_render' );
25
- }
26
- }
27
-
28
- function widget_render() {
29
- $get_issues = get_transient( 'health-check-site-status-result' );
30
-
31
- if ( false !== $get_issues ) {
32
- $issue_counts = json_decode( $get_issues );
33
- } else {
34
- $issue_counts = (object) array(
35
- 'good' => 0,
36
- 'recommended' => 0,
37
- 'critical' => 0,
38
- );
39
- }
40
-
41
- $issues_total = $issue_counts->recommended + $issue_counts->critical;
42
- ?>
43
- <div class="health-check-title-section site-health-progress-wrapper loading hide-if-no-js">
44
- <div class="site-health-progress">
45
- <svg role="img" aria-hidden="true" focusable="false" width="100%" height="100%" viewBox="0 0 200 200" version="1.1" xmlns="http://www.w3.org/2000/svg">
46
- <circle r="90" cx="100" cy="100" fill="transparent" stroke-dasharray="565.48" stroke-dashoffset="0"></circle>
47
- <circle id="bar" r="90" cx="100" cy="100" fill="transparent" stroke-dasharray="565.48" stroke-dashoffset="0"></circle>
48
- </svg>
49
- </div>
50
- <div class="site-health-progress-label">
51
- <?php if ( false === $get_issues ) : ?>
52
- <?php _e( 'No information yet&hellip;', 'health-check' ); ?>
53
- <?php else : ?>
54
- <?php _e( 'Results are still loading&hellip;', 'health-check' ); ?>
55
- <?php endif; ?>
56
- </div>
57
- </div>
58
-
59
- <?php if ( false === $get_issues ) : ?>
60
- <p>
61
- <?php _e( 'No Site Health information has been gathered yet, you can do so by visiting the Site Health page, alternatively the checks will run automatically once every week.', 'health-check' ); ?>
62
- </p>
63
-
64
- <p>
65
- <?php
66
- printf(
67
- // translators: %s: URL for the Site Health page.
68
- __( '<a href="%s">Visit the Site Health page</a> to gather information on about your site..', 'health-check' ),
69
- esc_url( admin_url( 'tools.php?page=health-check' ) )
70
- );
71
- ?>
72
- </p>
73
-
74
- <?php else : ?>
75
- <p>
76
- <?php if ( $issue_counts->critical > 0 ) : ?>
77
- <?php _e( 'Your site has critical issues that should be addressed as soon as possible to improve the performance or security of your website.', 'health-check' ); ?>
78
- <?php elseif ( $issues_total <= 0 ) : ?>
79
- <?php _e( 'Great job! Your site currently passes all site health checks.', 'health-check' ); ?>
80
- <?php else : ?>
81
- <?php _e( 'Your site scores pretty well on the Health Check, but there are still some things you can do to improve the performance and security of your website.', 'health-check' ); ?>
82
- <?php endif; ?>
83
- </p>
84
- <?php endif; ?>
85
-
86
- <?php if ( $issues_total > 0 && false !== $get_issues ) : ?>
87
- <p>
88
- <?php
89
- printf(
90
- // translators: 1: Count of issues. 2: URL for the Site Health page.
91
- __( 'Take a look at the <strong>%1$d items</strong> on the <a href="%2$s">Site Health Check status page</a>.', 'health-check' ),
92
- $issues_total,
93
- esc_url( admin_url( 'tools.php?page=health-check' ) )
94
- );
95
- ?>
96
- </p>
97
- <?php endif; ?>
98
-
99
- <?php
100
- }
101
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
includes/class-health-check-site-status.php DELETED
@@ -1,2039 +0,0 @@
1
- <?php
2
-
3
- // Make sure the file is not directly accessible.
4
- if ( ! defined( 'ABSPATH' ) ) {
5
- die( 'We\'re sorry, but you can not directly access this file.' );
6
- }
7
-
8
- class Health_Check_Site_Status {
9
- private $mysql_min_version_check;
10
- private $mysql_rec_version_check;
11
-
12
- public $is_mariadb = false;
13
- private $mysql_server_version = '';
14
- private $health_check_mysql_required_version = '5.5';
15
- private $health_check_mysql_rec_version = '';
16
-
17
- public function __construct() {
18
- $this->init();
19
- }
20
-
21
- public function init() {
22
- $this->prepare_sql_data();
23
-
24
- add_action( 'wp_ajax_health-check-site-status', array( $this, 'site_status' ) );
25
-
26
- add_action( 'wp_ajax_health-check-site-status-result', array( $this, 'site_status_result' ) );
27
-
28
- add_action( 'admin_init', array( $this, 'check_wp_version_check_exists' ) );
29
-
30
- add_action( 'health-check-scheduled-site-status-check', array( $this, 'scheduled_check' ) );
31
- }
32
-
33
- /**
34
- * Run the SQL version checks.
35
- *
36
- * These values are used in later tests, but the part of preparing them is more easily managed early
37
- * in the class for ease of access and discovery.
38
- *
39
- * @since 5.2.0
40
- *
41
- * @global wpdb $wpdb WordPress database abstraction object.
42
- */
43
- private function prepare_sql_data() {
44
- global $wpdb;
45
-
46
- if ( method_exists( $wpdb, 'db_version' ) ) {
47
- if ( $wpdb->use_mysqli ) {
48
- // phpcs:ignore WordPress.DB.RestrictedFunctions.mysql_mysqli_get_server_info
49
- $mysql_server_type = mysqli_get_server_info( $wpdb->dbh );
50
- } else {
51
- // phpcs:ignore WordPress.DB.RestrictedFunctions.mysql_mysql_get_server_info
52
- $mysql_server_type = mysql_get_server_info( $wpdb->dbh );
53
- }
54
-
55
- $this->mysql_server_version = $wpdb->get_var( 'SELECT VERSION()' );
56
- }
57
-
58
- $this->health_check_mysql_rec_version = '5.6';
59
-
60
- if ( stristr( $mysql_server_type, 'mariadb' ) ) {
61
- $this->is_mariadb = true;
62
- $this->health_check_mysql_rec_version = '10.0';
63
- }
64
-
65
- $this->mysql_min_version_check = version_compare( '5.5', $this->mysql_server_version, '<=' );
66
- $this->mysql_rec_version_check = version_compare( $this->health_check_mysql_rec_version, $this->mysql_server_version, '<=' );
67
- }
68
-
69
- /**
70
- * Test if `wp_version_check` is blocked.
71
- *
72
- * It's possible to block updates with the `wp_version_check` filter, but this can't be checked during an
73
- * AJAX call, as the filter is never introduced then.
74
- *
75
- * This filter overrides a normal page request if it's made by an admin through the AJAX call with the
76
- * right query argument to check for this.
77
- *
78
- * @since 5.2.0
79
- */
80
- public function check_wp_version_check_exists() {
81
- if ( ! is_admin() || ! is_user_logged_in() || ! current_user_can( 'update_core' ) || ! isset( $_GET['health-check-test-wp_version_check'] ) ) {
82
- return;
83
- }
84
-
85
- echo ( has_filter( 'wp_version_check', 'wp_version_check' ) ? 'yes' : 'no' );
86
-
87
- die();
88
- }
89
-
90
- public function site_status_result() {
91
- check_ajax_referer( 'health-check-site-status-result' );
92
-
93
- if ( ! current_user_can( 'view_site_health_checks' ) ) {
94
- wp_send_json_error();
95
- }
96
-
97
- set_transient( 'health-check-site-status-result', wp_json_encode( $_POST['counts'] ) );
98
- }
99
-
100
- public function site_status() {
101
- check_ajax_referer( 'health-check-site-status' );
102
-
103
- if ( ! current_user_can( 'view_site_health_checks' ) ) {
104
- wp_send_json_error();
105
- }
106
-
107
- $function = sprintf(
108
- 'json_test_%s',
109
- $_POST['feature']
110
- );
111
-
112
- if ( ! method_exists( $this, $function ) || ! is_callable( array( $this, $function ) ) ) {
113
- return;
114
- }
115
-
116
- $call = call_user_func( array( $this, $function ) );
117
- }
118
-
119
- /**
120
- * Tests for WordPress version and outputs it.
121
- *
122
- * Gives various results depending on what kind of updates are available, if any, to encourage the
123
- * user to install security updates as a priority.
124
- *
125
- * @since 5.2.0
126
- *
127
- * @return array The test result.
128
- */
129
- public function get_test_wordpress_version() {
130
- $result = array(
131
- 'label' => '',
132
- 'status' => '',
133
- 'badge' => array(
134
- 'label' => __( 'Performance', 'health-check' ),
135
- 'color' => 'blue',
136
- ),
137
- 'description' => '',
138
- 'actions' => '',
139
- 'test' => 'wordpress_version',
140
- );
141
-
142
- $core_current_version = get_bloginfo( 'version' );
143
- $core_updates = get_core_updates();
144
-
145
- if ( ! is_array( $core_updates ) ) {
146
- $result['status'] = 'recommended';
147
-
148
- $result['label'] = sprintf(
149
- // translators: %s: Your current version of WordPress.
150
- __( 'WordPress version %s', 'health-check' ),
151
- $core_current_version
152
- );
153
-
154
- $result['description'] = sprintf(
155
- '<p>%s</p>',
156
- __( 'We were unable to check if any new versions of WordPress are available.', 'health-check' )
157
- );
158
-
159
- $result['actions'] = sprintf(
160
- '<a href="%s">%s</a>',
161
- esc_url( admin_url( 'update-core.php?force-check=1' ) ),
162
- __( 'Check for updates manually', 'health-check' )
163
- );
164
- } else {
165
- foreach ( $core_updates as $core => $update ) {
166
- if ( 'upgrade' === $update->response ) {
167
- $current_version = explode( '.', $core_current_version );
168
- $new_version = explode( '.', $update->version );
169
-
170
- $current_major = $current_version[0] . '.' . $current_version[1];
171
- $new_major = $new_version[0] . '.' . $new_version[1];
172
-
173
- $result['label'] = sprintf(
174
- // translators: %s: The latest version of WordPress available.
175
- __( 'WordPress update available (%s)', 'health-check' ),
176
- $update->version
177
- );
178
-
179
- $result['actions'] = sprintf(
180
- '<a href="%s">%s</a>',
181
- esc_url( admin_url( 'update-core.php' ) ),
182
- __( 'Install the latest version of WordPress', 'health-check' )
183
- );
184
-
185
- if ( $current_major !== $new_major ) {
186
- // This is a major version mismatch.
187
- $result['status'] = 'recommended';
188
- $result['description'] = sprintf(
189
- '<p>%s</p>',
190
- __( 'A new version of WordPress is available.', 'health-check' )
191
- );
192
- } else {
193
- // This is a minor version, sometimes considered more critical.
194
- $result['status'] = 'critical';
195
- $result['badge']['label'] = __( 'Security', 'health-check' );
196
- $result['description'] = sprintf(
197
- '<p>%s</p>',
198
- __( 'A new minor update is available for your site. Because minor updates often address security, it&#8217;s important to install them.', 'health-check' )
199
- );
200
- }
201
- } else {
202
- $result['status'] = 'good';
203
- $result['label'] = sprintf(
204
- // translators: %s: The current version of WordPress installed on this site.
205
- __( 'Your WordPress version is up to date (%s)', 'health-check' ),
206
- $core_current_version
207
- );
208
-
209
- $result['description'] = sprintf(
210
- '<p>%s</p>',
211
- __( 'You are currently running the latest version of WordPress available, keep it up!', 'health-check' )
212
- );
213
- }
214
- }
215
- }
216
-
217
- return $result;
218
- }
219
-
220
- public function test_wordpress_version() {
221
- $check = $this->get_test_wordpress_version();
222
-
223
- printf( '<span class="%s"></span> %s', esc_attr( $check['status'] ), esc_html( $check['label'] ) );
224
- }
225
-
226
- public function json_wordpress_version() {
227
- wp_send_json_success( $this->get_test_wordpress_version() );
228
- }
229
-
230
- /**
231
- * Check if the user is currently in Troubleshooting Mode or not.
232
- *
233
- * @return bool
234
- */
235
- public function is_troubleshooting() {
236
- // Check if a session cookie to disable plugins has been set.
237
- if ( isset( $_COOKIE['wp-health-check-disable-plugins'] ) ) {
238
- $_GET['health-check-disable-plugin-hash'] = $_COOKIE['wp-health-check-disable-plugins'];
239
- }
240
-
241
- // If the disable hash isn't set, no need to interact with things.
242
- if ( ! isset( $_GET['health-check-disable-plugin-hash'] ) ) {
243
- return false;
244
- }
245
-
246
- $disable_hash = get_option( 'health-check-disable-plugin-hash', null );
247
-
248
- if ( empty( $disable_hash ) ) {
249
- return false;
250
- }
251
-
252
- // If the plugin hash is not valid, we also break out
253
- if ( $disable_hash !== $_GET['health-check-disable-plugin-hash'] ) {
254
- return false;
255
- }
256
-
257
- return true;
258
- }
259
-
260
- /**
261
- * Test if plugins are outdated, or unnecessary.
262
- *
263
- * The tests checks if your plugins are up to date, and encourages you to remove any that are not in use.
264
- *
265
- * @since 5.2.0
266
- *
267
- * @return array The test result.
268
- */
269
- public function get_test_plugin_version() {
270
- $result = array(
271
- 'label' => __( 'Your plugins are up to date', 'health-check' ),
272
- 'status' => 'good',
273
- 'badge' => array(
274
- 'label' => __( 'Security', 'health-check' ),
275
- 'color' => 'blue',
276
- ),
277
- 'description' => sprintf(
278
- '<p>%s</p>',
279
- __( 'Plugins extend your site&#8217;s functionality with things like contact forms, ecommerce and much more. That means they have deep access to your site, so it&#8217;s vital to keep them up to date.', 'health-check' )
280
- ),
281
- 'actions' => sprintf(
282
- '<p><a href="%s">%s</a></p>',
283
- esc_url( admin_url( 'plugins.php' ) ),
284
- __( 'Manage your plugins', 'health-check' )
285
- ),
286
- 'test' => 'plugin_version',
287
- );
288
-
289
- $plugins = get_plugins();
290
- $plugin_updates = get_plugin_updates();
291
-
292
- $plugins_have_updates = false;
293
- $plugins_active = 0;
294
- $plugins_total = 0;
295
- $plugins_need_update = 0;
296
-
297
- // Loop over the available plugins and check their versions and active state.
298
- foreach ( $plugins as $plugin_path => $plugin ) {
299
- $plugins_total++;
300
-
301
- if ( is_plugin_active( $plugin_path ) ) {
302
- $plugins_active++;
303
- }
304
-
305
- $plugin_version = $plugin['Version'];
306
-
307
- if ( array_key_exists( $plugin_path, $plugin_updates ) ) {
308
- $plugins_need_update++;
309
- $plugins_have_updates = true;
310
- }
311
- }
312
-
313
- // Add a notice if there are outdated plugins.
314
- if ( $plugins_need_update > 0 ) {
315
- $result['status'] = 'critical';
316
-
317
- $result['label'] = __( 'You have plugins waiting to be updated', 'health-check' );
318
-
319
- $result['description'] .= sprintf(
320
- '<p>%s</p>',
321
- sprintf(
322
- /* translators: %d: The number of outdated plugins. */
323
- _n(
324
- 'Your site has %d plugin waiting to be updated.',
325
- 'Your site has %d plugins waiting to be updated.',
326
- $plugins_need_update,
327
- 'health-check'
328
- ),
329
- $plugins_need_update
330
- )
331
- );
332
-
333
- $result['actions'] .= sprintf(
334
- '<p><a href="%s">%s</a></p>',
335
- esc_url( admin_url( 'plugins.php?plugin_status=upgrade' ) ),
336
- __( 'Update your plugins', 'health-check' )
337
- );
338
- } else {
339
- if ( 1 === $plugins_active ) {
340
- $result['description'] .= sprintf(
341
- '<p>%s</p>',
342
- __( 'Your site has 1 active plugin, and it is up to date.', 'health-check' )
343
- );
344
- } else {
345
- $result['description'] .= sprintf(
346
- '<p>%s</p>',
347
- sprintf(
348
- /* translators: %d: The number of active plugins. */
349
- _n(
350
- 'Your site has %d active plugin, and they are all up to date.',
351
- 'Your site has %d active plugins, and they are all up to date.',
352
- $plugins_active,
353
- 'health-check'
354
- ),
355
- $plugins_active
356
- )
357
- );
358
- }
359
- }
360
-
361
- // Check if there are inactive plugins.
362
- if ( $plugins_total > $plugins_active && ! is_multisite() ) {
363
- $unused_plugins = $plugins_total - $plugins_active;
364
-
365
- $result['status'] = 'recommended';
366
-
367
- $result['label'] = __( 'You should remove inactive plugins', 'health-check' );
368
-
369
- $result['description'] .= sprintf(
370
- '<p>%s %s</p>',
371
- sprintf(
372
- /* translators: %d: The number of inactive plugins. */
373
- _n(
374
- 'Your site has %d inactive plugin.',
375
- 'Your site has %d inactive plugins.',
376
- $unused_plugins,
377
- 'health-check'
378
- ),
379
- $unused_plugins
380
- ),
381
- __( 'Inactive plugins are tempting targets for attackers. If you&#8217;re not going to use a plugin, we recommend you remove it.', 'health-check' )
382
- );
383
-
384
- $result['actions'] .= sprintf(
385
- '<p><a href="%s">%s</a></p>',
386
- esc_url( admin_url( 'plugins.php?plugin_status=inactive' ) ),
387
- __( 'Manage inactive plugins', 'health-check' )
388
- );
389
- }
390
-
391
- return $result;
392
- }
393
-
394
- /**
395
- * Test if themes are outdated, or unnecessary.
396
- *
397
- * The tests checks if your site has a default theme (to fall back on if there is a need), if your themes
398
- * are up to date and, finally, encourages you to remove any themes that are not needed.
399
- *
400
- * @since 5.2.0
401
- *
402
- * @return array The test results.
403
- */
404
- public function get_test_theme_version() {
405
- $result = array(
406
- 'label' => __( 'Your themes are up to date', 'health-check' ),
407
- 'status' => 'good',
408
- 'badge' => array(
409
- 'label' => __( 'Security', 'health-check' ),
410
- 'color' => 'blue',
411
- ),
412
- 'description' => sprintf(
413
- '<p>%s</p>',
414
- __( 'Themes add your site&#8217;s look and feel. It&#8217;s important to keep them up to date, to stay consistent with your brand and keep your site secure.', 'health-check' )
415
- ),
416
- 'actions' => sprintf(
417
- '<p><a href="%s">%s</a></p>',
418
- esc_url( admin_url( 'themes.php' ) ),
419
- __( 'Manage your themes', 'health-check' )
420
- ),
421
- 'test' => 'theme_version',
422
- );
423
-
424
- $theme_updates = get_theme_updates();
425
-
426
- $themes_total = 0;
427
- $themes_need_updates = 0;
428
- $themes_inactive = 0;
429
-
430
- // This value is changed during processing to determine how many themes are considered a reasonable amount.
431
- $allowed_theme_count = 1;
432
-
433
- $has_default_theme = false;
434
- $has_unused_themes = false;
435
- $show_unused_themes = true;
436
- $using_default_theme = false;
437
-
438
- // Populate a list of all themes available in the install.
439
- $all_themes = wp_get_themes();
440
- $active_theme = wp_get_theme();
441
-
442
- foreach ( $all_themes as $theme_slug => $theme ) {
443
- $themes_total++;
444
-
445
- if ( WP_DEFAULT_THEME === $theme_slug ) {
446
- $has_default_theme = true;
447
-
448
- if ( get_stylesheet() === $theme_slug ) {
449
- $using_default_theme = true;
450
- }
451
- }
452
-
453
- if ( array_key_exists( $theme_slug, $theme_updates ) ) {
454
- $themes_need_updates++;
455
- }
456
- }
457
-
458
- // If this is a child theme, increase the allowed theme count by one, to account for the parent.
459
- if ( $active_theme->parent() ) {
460
- $allowed_theme_count++;
461
-
462
- if ( $active_theme->get_template() === WP_DEFAULT_THEME ) {
463
- $using_default_theme = true;
464
- }
465
- }
466
-
467
- // If there's a default theme installed and not in use, we count that as allowed as well.
468
- if ( $has_default_theme && ! $using_default_theme ) {
469
- $allowed_theme_count++;
470
- }
471
-
472
- if ( $themes_total > $allowed_theme_count ) {
473
- $has_unused_themes = true;
474
- $themes_inactive = ( $themes_total - $allowed_theme_count );
475
- }
476
-
477
- // Check if any themes need to be updated.
478
- if ( $themes_need_updates > 0 ) {
479
- $result['status'] = 'critical';
480
-
481
- $result['label'] = __( 'You have themes waiting to be updated', 'health-check' );
482
-
483
- $result['description'] .= sprintf(
484
- '<p>%s</p>',
485
- sprintf(
486
- /* translators: %d: The number of outdated themes. */
487
- _n(
488
- 'Your site has %d theme waiting to be updated.',
489
- 'Your site has %d themes waiting to be updated.',
490
- $themes_need_updates,
491
- 'health-check'
492
- ),
493
- $themes_need_updates
494
- )
495
- );
496
- } else {
497
- // Give positive feedback about the site being good about keeping things up to date.
498
- if ( 1 === $themes_total ) {
499
- $result['description'] .= sprintf(
500
- '<p>%s</p>',
501
- __( 'Your site has 1 installed theme, and it is up to date.', 'health-check' )
502
- );
503
- } else {
504
- $result['description'] .= sprintf(
505
- '<p>%s</p>',
506
- sprintf(
507
- /* translators: %d: The number of themes. */
508
- _n(
509
- 'Your site has %d installed theme, and they are all up to date.',
510
- 'Your site has %d installed themes, and they are all up to date.',
511
- $themes_total,
512
- 'health-check'
513
- ),
514
- $themes_total
515
- )
516
- );
517
- }
518
- }
519
-
520
- if ( $has_unused_themes && $show_unused_themes && ! is_multisite() ) {
521
-
522
- // This is a child theme, so we want to be a bit more explicit in our messages.
523
- if ( $active_theme->parent() ) {
524
- // Recommend removing inactive themes, except a default theme, your current one, and the parent theme.
525
- $result['status'] = 'recommended';
526
-
527
- $result['label'] = __( 'You should remove inactive themes', 'health-check' );
528
-
529
- if ( $using_default_theme ) {
530
- $result['description'] .= sprintf(
531
- '<p>%s %s</p>',
532
- sprintf(
533
- /* translators: %d: The number of inactive themes. */
534
- _n(
535
- 'Your site has %d inactive theme.',
536
- 'Your site has %d inactive themes.',
537
- $themes_inactive,
538
- 'health-check'
539
- ),
540
- $themes_inactive
541
- ),
542
- sprintf(
543
- /* translators: 1: The currently active theme. 2: The active theme's parent theme. */
544
- __( 'To enhance your site&#8217;s security, we recommend you remove any themes you&#8217;re not using. You should keep your current theme, %1$s, and %2$s, its parent theme.', 'health-check' ),
545
- $active_theme->name,
546
- $active_theme->parent()->name
547
- )
548
- );
549
- } else {
550
- $result['description'] .= sprintf(
551
- '<p>%s %s</p>',
552
- sprintf(
553
- /* translators: %d: The number of inactive themes. */
554
- _n(
555
- 'Your site has %d inactive theme.',
556
- 'Your site has %d inactive themes.',
557
- $themes_inactive,
558
- 'health-check'
559
- ),
560
- $themes_inactive
561
- ),
562
- sprintf(
563
- /* translators: 1: The default theme for WordPress. 2: The currently active theme. 3: The active theme's parent theme. */
564
- __( 'To enhance your site&#8217;s security, we recommend you remove any themes you&#8217;re not using. You should keep %1$s, the default WordPress theme, %2$s, your current theme, and %3$s, its parent theme.', 'health-check' ),
565
- WP_DEFAULT_THEME,
566
- $active_theme->name,
567
- $active_theme->parent()->name
568
- )
569
- );
570
- }
571
- } else {
572
- // Recommend removing all inactive themes.
573
- $result['status'] = 'recommended';
574
-
575
- $result['label'] = __( 'You should remove inactive themes', 'health-check' );
576
-
577
- if ( $using_default_theme ) {
578
- $result['description'] .= sprintf(
579
- '<p>%s %s</p>',
580
- sprintf(
581
- /* translators: 1: The amount of inactive themes. 2: The currently active theme. */
582
- _n(
583
- 'Your site has %1$d inactive theme, other than %2$s, your active theme.',
584
- 'Your site has %1$d inactive themes, other than %2$s, your active theme.',
585
- $themes_inactive,
586
- 'health-check'
587
- ),
588
- $themes_inactive,
589
- $active_theme->name
590
- ),
591
- __( 'We recommend removing any unused themes to enhance your site&#8217;s security.', 'health-check' )
592
- );
593
- } else {
594
- $result['description'] .= sprintf(
595
- '<p>%s %s</p>',
596
- sprintf(
597
- /* translators: 1: The amount of inactive themes. 2: The default theme for WordPress. 3: The currently active theme. */
598
- _n(
599
- 'Your site has %1$d inactive theme, other than %2$s, the default WordPress theme, and %3$s, your active theme.',
600
- 'Your site has %1$d inactive themes, other than %2$s, the default WordPress theme, and %3$s, your active theme.',
601
- $themes_inactive,
602
- 'health-check'
603
- ),
604
- $themes_inactive,
605
- WP_DEFAULT_THEME,
606
- $active_theme->name
607
- ),
608
- __( 'We recommend removing any unused themes to enhance your site&#8217;s security.', 'health-check' )
609
- );
610
- }
611
- }
612
- }
613
-
614
- // If not default Twenty* theme exists.
615
- if ( ! $has_default_theme ) {
616
- $result['status'] = 'recommended';
617
-
618
- $result['label'] = __( 'Have a default theme available', 'health-check' );
619
-
620
- $result['description'] .= sprintf(
621
- '<p>%s</p>',
622
- __( 'Your site does not have any default theme. Default themes are used by WordPress automatically if anything is wrong with your normal theme.', 'health-check' )
623
- );
624
- }
625
-
626
- return $result;
627
- }
628
-
629
- /**
630
- * Test if the supplied PHP version is supported.
631
- *
632
- * @since 5.2.0
633
- *
634
- * @return array The test results.
635
- */
636
- public function get_test_php_version() {
637
- $response = wp_check_php_version();
638
-
639
- $result = array(
640
- 'label' => sprintf(
641
- // translators: %s: The current PHP version.
642
- __( 'PHP is up to date (%s)', 'health-check' ),
643
- PHP_VERSION
644
- ),
645
- 'status' => 'good',
646
- 'badge' => array(
647
- 'label' => __( 'Performance', 'health-check' ),
648
- 'color' => 'blue',
649
- ),
650
- 'description' => sprintf(
651
- '<p>%s</p>',
652
- __( 'PHP is the programming language we use to build and maintain WordPress. Newer versions of PHP are both faster and more secure, so updating will have a positive effect on your site&#8217;s performance.', 'health-check' )
653
- ),
654
- 'actions' => sprintf(
655
- '<p><a href="%s" target="_blank" rel="noopener noreferrer">%s <span class="screen-reader-text">%s</span><span aria-hidden="true" class="dashicons dashicons-external"></span></a></p>',
656
- esc_url( wp_get_update_php_url() ),
657
- __( 'Learn more about updating PHP', 'health-check' ),
658
- /* translators: accessibility text */
659
- __( '(opens in a new tab)', 'health-check' )
660
- ),
661
- 'test' => 'php_version',
662
- );
663
-
664
- // PHP is up to date.
665
- if ( ! $response || version_compare( PHP_VERSION, $response['recommended_version'], '>=' ) ) {
666
- return $result;
667
- }
668
-
669
- // The PHP version is older than the recommended version, but still acceptable.
670
- if ( $response['is_supported'] ) {
671
- $result['label'] = __( 'We recommend that you update PHP', 'health-check' );
672
- $result['status'] = 'recommended';
673
-
674
- return $result;
675
- }
676
-
677
- // The PHP version is only receiving security fixes.
678
- if ( $response['is_secure'] ) {
679
- $result['label'] = __( 'Your PHP version should be updated', 'health-check' );
680
- $result['status'] = 'recommended';
681
-
682
- return $result;
683
- }
684
-
685
- // Anything no longer secure must be updated.
686
- $result['label'] = __( 'Your PHP version requires an update', 'health-check' );
687
- $result['status'] = 'critical';
688
- $result['badge']['label'] = __( 'Security', 'health-check' );
689
-
690
- return $result;
691
- }
692
-
693
- /**
694
- * Check if the passed extension or function are available.
695
- *
696
- * Make the check for available PHP modules into a simple boolean operator for a cleaner test runner.
697
- *
698
- * @since 5.2.0
699
- *
700
- * @param string $extension Optional. The extension name to test. Default null.
701
- * @param string $function Optional. The function name to test. Default null.
702
- * @param string $constant Optional. The constant to text for. Default null.
703
- *
704
- * @return bool Whether or not the extension and function are available.
705
- */
706
- private function test_php_extension_availability( $extension = null, $function = null, $constant = null ) {
707
- // If no extension or function is passed, claim to fail testing, as we have nothing to test against.
708
- if ( ! $extension && ! $function && ! $constant ) {
709
- return false;
710
- }
711
-
712
- if ( $extension && ! extension_loaded( $extension ) ) {
713
- return false;
714
- }
715
- if ( $function && ! function_exists( $function ) ) {
716
- return false;
717
- }
718
- if ( $constant && ! defined( $constant ) ) {
719
- return false;
720
- }
721
-
722
- return true;
723
- }
724
-
725
- /**
726
- * Test if required PHP modules are installed on the host.
727
- *
728
- * This test builds on the recommendations made by the WordPress Hosting Team
729
- * as seen at https://make.wordpress.org/hosting/handbook/handbook/server-environment/#php-extensions
730
- *
731
- * @since 5.2.0
732
- *
733
- * @return array
734
- */
735
- public function get_test_php_extensions() {
736
- $result = array(
737
- 'label' => __( 'Required and recommended modules are installed', 'health-check' ),
738
- 'status' => 'good',
739
- 'badge' => array(
740
- 'label' => __( 'Performance', 'health-check' ),
741
- 'color' => 'blue',
742
- ),
743
- 'description' => sprintf(
744
- '<p>%s</p><p>%s</p>',
745
- __( 'PHP modules perform most of the tasks on the server that make your site run. Any changes to these must be made by your server administrator.', 'health-check' ),
746
- sprintf(
747
- /* translators: %s: Link to the hosting group page about recommended PHP modules. */
748
- __( 'The WordPress Hosting Team maintains a list of those modules, both recommended and required, in %s.', 'health-check' ),
749
- sprintf(
750
- '<a href="%1$s" target="_blank" rel="noopener noreferrer">%2$s <span class="screen-reader-text">%3$s</span><span aria-hidden="true" class="dashicons dashicons-external"></span></a>',
751
- /* translators: Localized team handbook, if one exists. */
752
- esc_url( __( 'https://make.wordpress.org/hosting/handbook/handbook/server-environment/#php-extensions', 'health-check' ) ),
753
- __( 'the team handbook', 'health-check' ),
754
- /* translators: accessibility text */
755
- __( '(opens in a new tab)', 'health-check' )
756
- )
757
- )
758
- ),
759
- 'actions' => '',
760
- 'test' => 'php_extensions',
761
- );
762
-
763
- $modules = array(
764
- 'bcmath' => array(
765
- 'function' => 'bcadd',
766
- 'required' => false,
767
- ),
768
- 'curl' => array(
769
- 'function' => 'curl_version',
770
- 'required' => false,
771
- ),
772
- 'exif' => array(
773
- 'function' => 'exif_read_data',
774
- 'required' => false,
775
- ),
776
- 'filter' => array(
777
- 'function' => 'filter_list',
778
- 'required' => false,
779
- ),
780
- 'fileinfo' => array(
781
- 'function' => 'finfo_file',
782
- 'required' => false,
783
- ),
784
- 'mod_xml' => array(
785
- 'extension' => 'libxml',
786
- 'required' => false,
787
- ),
788
- 'mysqli' => array(
789
- 'function' => 'mysqli_connect',
790
- 'required' => false,
791
- ),
792
- 'libsodium' => array(
793
- 'constant' => 'SODIUM_LIBRARY_VERSION',
794
- 'required' => false,
795
- 'php_bundled_version' => '7.2.0',
796
- ),
797
- 'openssl' => array(
798
- 'function' => 'openssl_encrypt',
799
- 'required' => false,
800
- ),
801
- 'pcre' => array(
802
- 'function' => 'preg_match',
803
- 'required' => false,
804
- ),
805
- 'imagick' => array(
806
- 'extension' => 'imagick',
807
- 'required' => false,
808
- ),
809
- 'gd' => array(
810
- 'extension' => 'gd',
811
- 'required' => false,
812
- 'fallback_for' => 'imagick',
813
- ),
814
- 'mcrypt' => array(
815
- 'extension' => 'mcrypt',
816
- 'required' => false,
817
- 'fallback_for' => 'libsodium',
818
- ),
819
- 'xmlreader' => array(
820
- 'extension' => 'xmlreader',
821
- 'required' => false,
822
- 'fallback_for' => 'xml',
823
- ),
824
- 'zlib' => array(
825
- 'extension' => 'zlib',
826
- 'required' => false,
827
- 'fallback_for' => 'zip',
828
- ),
829
- 'mbstring' => array(
830
- 'extension' => 'mbstring',
831
- 'required' => true,
832
- ),
833
- 'json' => array(
834
- 'extension' => 'json',
835
- 'required' => true,
836
- ),
837
- );
838
-
839
- /**
840
- * An array representing all the modules we wish to test for.
841
- *
842
- * @since 5.2.0
843
- *
844
- * @param array $modules {
845
- * An associated array of modules to test for.
846
- *
847
- * array $module {
848
- * An associated array of module properties used during testing.
849
- * One of either `$function` or `$extension` must be provided, or they will fail by default.
850
- *
851
- * string $function Optional. A function name to test for the existence of.
852
- * string $extension Optional. An extension to check if is loaded in PHP.
853
- * string $constant Optional. A constant to check for to verify an extension exists.
854
- * bool $required Is this a required feature or not.
855
- * string $fallback_for Optional. The module this module replaces as a fallback.
856
- * }
857
- * }
858
- */
859
- $modules = apply_filters( 'site_status_test_php_modules', $modules );
860
-
861
- $failures = array();
862
-
863
- foreach ( $modules as $library => $module ) {
864
- $extension = ( isset( $module['extension'] ) ? $module['extension'] : null );
865
- $function = ( isset( $module['function'] ) ? $module['function'] : null );
866
- $constant = ( isset( $module['constant'] ) ? $module['constant'] : null );
867
-
868
- // If this module is a fallback for another function, check if that other function passed.
869
- if ( isset( $module['fallback_for'] ) ) {
870
- /*
871
- * If that other function has a failure, mark this module as required for normal operations.
872
- * If that other function hasn't failed, skip this test as it's only a fallback.
873
- */
874
- if ( isset( $failures[ $module['fallback_for'] ] ) ) {
875
- $module['required'] = true;
876
- } else {
877
- continue;
878
- }
879
- }
880
-
881
- if ( ! $this->test_php_extension_availability( $extension, $function, $constant ) && ( ! isset( $module['php_bundled_version'] ) || version_compare( PHP_VERSION, $module['php_bundled_version'], '<' ) ) ) {
882
- if ( $module['required'] ) {
883
- $result['status'] = 'critical';
884
-
885
- $class = 'error';
886
- $screen_reader = __( 'Error', 'health-check' );
887
- $message = sprintf(
888
- /* translators: %s: The module name. */
889
- __( 'The required module, %s, is not installed, or has been disabled.', 'health-check' ),
890
- $library
891
- );
892
- } else {
893
- $class = 'warning';
894
- $screen_reader = __( 'Warning', 'health-check' );
895
- $message = sprintf(
896
- /* translators: %s: The module name. */
897
- __( 'The optional module, %s, is not installed, or has been disabled.', 'health-check' ),
898
- $library
899
- );
900
- }
901
-
902
- if ( ! $module['required'] && 'good' === $result['status'] ) {
903
- $result['status'] = 'recommended';
904
- }
905
-
906
- $failures[ $library ] = "<span class='$class'><span class='screen-reader-text'>$screen_reader</span></span> $message";
907
- }
908
- }
909
-
910
- if ( ! empty( $failures ) ) {
911
- $output = '<ul>';
912
-
913
- foreach ( $failures as $failure ) {
914
- $output .= sprintf(
915
- '<li>%s</li>',
916
- $failure
917
- );
918
- }
919
-
920
- $output .= '</ul>';
921
- }
922
-
923
- if ( 'good' !== $result['status'] ) {
924
- if ( 'recommended' === $result['status'] ) {
925
- $result['label'] = __( 'One or more recommended modules are missing', 'health-check' );
926
- }
927
- if ( 'critical' === $result['status'] ) {
928
- $result['label'] = __( 'One or more required modules are missing', 'health-check' );
929
- }
930
-
931
- $result['description'] .= sprintf(
932
- '<p>%s</p>',
933
- $output
934
- );
935
- }
936
-
937
- return $result;
938
- }
939
-
940
- /**
941
- * Test if the SQL server is up to date.
942
- *
943
- * @since 5.2.0
944
- *
945
- * @return array The test results.
946
- */
947
- public function get_test_sql_server() {
948
- $result = array(
949
- 'label' => __( 'SQL server is up to date', 'health-check' ),
950
- 'status' => 'good',
951
- 'badge' => array(
952
- 'label' => __( 'Performance', 'health-check' ),
953
- 'color' => 'blue',
954
- ),
955
- 'description' => sprintf(
956
- '<p>%s</p>',
957
- __( 'The SQL server is a required piece of software for the database WordPress uses to store all your site&#8217;s content and settings.', 'health-check' )
958
- ),
959
- 'actions' => sprintf(
960
- '<p><a href="%s" target="_blank" rel="noopener noreferrer">%s <span class="screen-reader-text">%s</span><span aria-hidden="true" class="dashicons dashicons-external"></span></a></p>',
961
- /* translators: Localized version of WordPress requirements if one exists. */
962
- esc_url( __( 'https://wordpress.org/about/requirements/', 'health-check' ) ),
963
- __( 'Read more about what WordPress requires to run.', 'health-check' ),
964
- /* translators: accessibility text */
965
- __( '(opens in a new tab)', 'health-check' )
966
- ),
967
- 'test' => 'sql_server',
968
- );
969
-
970
- $db_dropin = file_exists( WP_CONTENT_DIR . '/db.php' );
971
-
972
- if ( ! $this->mysql_rec_version_check ) {
973
- $result['status'] = 'recommended';
974
-
975
- $result['label'] = __( 'Outdated SQL server', 'health-check' );
976
-
977
- $result['description'] .= sprintf(
978
- '<p>%s</p>',
979
- sprintf(
980
- /* translators: 1: The database engine in use (MySQL or MariaDB). 2: Database server recommended version number. */
981
- __( 'For optimal performance and security reasons, we recommend running %1$s version %2$s or higher. Contact your web hosting company to correct this.', 'health-check' ),
982
- ( $this->is_mariadb ? 'MariaDB' : 'MySQL' ),
983
- $this->health_check_mysql_rec_version
984
- )
985
- );
986
- }
987
-
988
- if ( ! $this->mysql_min_version_check ) {
989
- $result['status'] = 'critical';
990
-
991
- $result['label'] = __( 'Severely outdated SQL server', 'health-check' );
992
- $result['badge']['label'] = __( 'Security', 'health-check' );
993
-
994
- $result['description'] .= sprintf(
995
- '<p>%s</p>',
996
- sprintf(
997
- /* translators: 1: The database engine in use (MySQL or MariaDB). 2: Database server minimum version number. */
998
- __( 'WordPress requires %1$s version %2$s or higher. Contact your web hosting company to correct this.', 'health-check' ),
999
- ( $this->is_mariadb ? 'MariaDB' : 'MySQL' ),
1000
- $this->health_check_mysql_required_version
1001
- )
1002
- );
1003
- }
1004
-
1005
- if ( $db_dropin ) {
1006
- $result['description'] .= sprintf(
1007
- '<p>%s</p>',
1008
- wp_kses(
1009
- sprintf(
1010
- /* translators: 1: The name of the drop-in. 2: The name of the database engine. */
1011
- __( 'You are using a %1$s drop-in which might mean that a %2$s database is not being used.', 'health-check' ),
1012
- '<code>wp-content/db.php</code>',
1013
- ( $this->is_mariadb ? 'MariaDB' : 'MySQL' )
1014
- ),
1015
- array(
1016
- 'code' => true,
1017
- )
1018
- )
1019
- );
1020
- }
1021
-
1022
- return $result;
1023
- }
1024
-
1025
- /**
1026
- * Test if the database server is capable of using utf8mb4.
1027
- *
1028
- * @since 5.2.0
1029
- *
1030
- * @return array The test results.
1031
- */
1032
- public function get_test_utf8mb4_support() {
1033
- global $wpdb;
1034
-
1035
- $result = array(
1036
- 'label' => __( 'UTF8MB4 is supported', 'health-check' ),
1037
- 'status' => 'good',
1038
- 'badge' => array(
1039
- 'label' => __( 'Performance', 'health-check' ),
1040
- 'color' => 'blue',
1041
- ),
1042
- 'description' => sprintf(
1043
- '<p>%s</p>',
1044
- __( 'UTF8MB4 is a database storage attribute that makes sure your site can store non-English text and other strings (for instance emoticons) without unexpected problems.', 'health-check' )
1045
- ),
1046
- 'actions' => '',
1047
- 'test' => 'utf8mb4_support',
1048
- );
1049
-
1050
- if ( ! $this->is_mariadb ) {
1051
- if ( version_compare( $this->mysql_server_version, '5.5.3', '<' ) ) {
1052
- $result['status'] = 'recommended';
1053
-
1054
- $result['label'] = __( 'utf8mb4 requires a MySQL update', 'health-check' );
1055
-
1056
- $result['description'] .= sprintf(
1057
- '<p>%s</p>',
1058
- sprintf(
1059
- /* translators: %s: Version number. */
1060
- __( 'WordPress&#8217; utf8mb4 support requires MySQL version %s or greater. Please contact your server administrator.', 'health-check' ),
1061
- '5.5.3'
1062
- )
1063
- );
1064
- } else {
1065
- $result['description'] .= sprintf(
1066
- '<p>%s</p>',
1067
- __( 'Your MySQL version supports utf8mb4.', 'health-check' )
1068
- );
1069
- }
1070
- } else { // MariaDB introduced utf8mb4 support in 5.5.0
1071
- if ( version_compare( $this->mysql_server_version, '5.5.0', '<' ) ) {
1072
- $result['status'] = 'recommended';
1073
-
1074
- $result['label'] = __( 'utf8mb4 requires a MariaDB update', 'health-check' );
1075
-
1076
- $result['description'] .= sprintf(
1077
- '<p>%s</p>',
1078
- sprintf(
1079
- /* translators: %s: Version number. */
1080
- __( 'WordPress&#8217; utf8mb4 support requires MariaDB version %s or greater. Please contact your server administrator.', 'health-check' ),
1081
- '5.5.0'
1082
- )
1083
- );
1084
- } else {
1085
- $result['description'] .= sprintf(
1086
- '<p>%s</p>',
1087
- __( 'Your MariaDB version supports utf8mb4.', 'health-check' )
1088
- );
1089
- }
1090
- }
1091
-
1092
- if ( $wpdb->use_mysqli ) {
1093
- // phpcs:ignore WordPress.DB.RestrictedFunctions.mysql_mysqli_get_client_info
1094
- $mysql_client_version = mysqli_get_client_info();
1095
- } else {
1096
- // phpcs:ignore WordPress.DB.RestrictedFunctions.mysql_mysql_get_client_info
1097
- $mysql_client_version = mysql_get_client_info();
1098
- }
1099
-
1100
- /*
1101
- * libmysql has supported utf8mb4 since 5.5.3, same as the MySQL server.
1102
- * mysqlnd has supported utf8mb4 since 5.0.9.
1103
- */
1104
- if ( false !== strpos( $mysql_client_version, 'mysqlnd' ) ) {
1105
- $mysql_client_version = preg_replace( '/^\D+([\d.]+).*/', '$1', $mysql_client_version );
1106
- if ( version_compare( $mysql_client_version, '5.0.9', '<' ) ) {
1107
- $result['status'] = 'recommended';
1108
-
1109
- $result['label'] = __( 'utf8mb4 requires a newer client library', 'health-check' );
1110
-
1111
- $result['description'] .= sprintf(
1112
- '<p>%s</p>',
1113
- sprintf(
1114
- /* translators: 1: Name of the library, 2: Number of version. */
1115
- __( 'WordPress&#8217; utf8mb4 support requires MySQL client library (%1$s) version %2$s or newer. Please contact your server administrator.', 'health-check' ),
1116
- 'mysqlnd',
1117
- '5.0.9'
1118
- )
1119
- );
1120
- }
1121
- } else {
1122
- if ( version_compare( $mysql_client_version, '5.5.3', '<' ) ) {
1123
- $result['status'] = 'recommended';
1124
-
1125
- $result['label'] = __( 'utf8mb4 requires a newer client library', 'health-check' );
1126
-
1127
- $result['description'] .= sprintf(
1128
- '<p>%s</p>',
1129
- sprintf(
1130
- /* translators: 1: Name of the library, 2: Number of version. */
1131
- __( 'WordPress&#8217; utf8mb4 support requires MySQL client library (%1$s) version %2$s or newer. Please contact your server administrator.', 'health-check' ),
1132
- 'libmysql',
1133
- '5.5.3'
1134
- )
1135
- );
1136
- }
1137
- }
1138
-
1139
- return $result;
1140
- }
1141
-
1142
- /**
1143
- * Test if the site can communicate with WordPress.org.
1144
- *
1145
- * @since 5.2.0
1146
- *
1147
- * @return array The test results.
1148
- */
1149
- public function get_test_dotorg_communication() {
1150
- $result = array(
1151
- 'label' => __( 'Can communicate with WordPress.org', 'health-check' ),
1152
- 'status' => '',
1153
- 'badge' => array(
1154
- 'label' => __( 'Security', 'health-check' ),
1155
- 'color' => 'blue',
1156
- ),
1157
- 'description' => sprintf(
1158
- '<p>%s</p>',
1159
- __( 'Communicating with the WordPress servers is used to check for new versions, and to both install and update WordPress core, themes or plugins.', 'health-check' )
1160
- ),
1161
- 'actions' => '',
1162
- 'test' => 'dotorg_communication',
1163
- );
1164
-
1165
- $wp_dotorg = wp_remote_get(
1166
- 'https://api.wordpress.org',
1167
- array(
1168
- 'timeout' => 10,
1169
- )
1170
- );
1171
- if ( ! is_wp_error( $wp_dotorg ) ) {
1172
- $result['status'] = 'good';
1173
- } else {
1174
- $result['status'] = 'critical';
1175
-
1176
- $result['label'] = __( 'Could not reach WordPress.org', 'health-check' );
1177
-
1178
- $result['description'] .= sprintf(
1179
- '<p>%s</p>',
1180
- sprintf(
1181
- '<span class="error"><span class="screen-reader-text">%s</span></span> %s',
1182
- __( 'Error', 'health-check' ),
1183
- sprintf(
1184
- /* translators: 1: The IP address WordPress.org resolves to. 2: The error returned by the lookup. */
1185
- __( 'Your site is unable to reach WordPress.org at %1$s, and returned the error: %2$s', 'health-check' ),
1186
- gethostbyname( 'api.wordpress.org' ),
1187
- $wp_dotorg->get_error_message()
1188
- )
1189
- )
1190
- );
1191
-
1192
- $result['actions'] = sprintf(
1193
- '<p><a href="%s" target="_blank" rel="noopener noreferrer">%s <span class="screen-reader-text">%s</span><span aria-hidden="true" class="dashicons dashicons-external"></span></a></p>',
1194
- /* translators: Localized Support reference. */
1195
- esc_url( __( 'https://wordpress.org/support', 'health-check' ) ),
1196
- __( 'Get help resolving this issue.', 'health-check' ),
1197
- /* translators: accessibility text */
1198
- __( '(opens in a new tab)', 'health-check' )
1199
- );
1200
- }
1201
-
1202
- return $result;
1203
- }
1204
-
1205
- public function json_test_dotorg_communication() {
1206
- wp_send_json_success( $this->get_test_dotorg_communication() );
1207
- }
1208
-
1209
- /**
1210
- * Test if the site is using timezones relative to their location, or by using an offset value.
1211
- *
1212
- * Daylight Savings Time (DST) may affect the times used and shown by your site, and using an UTC offset,
1213
- * instead of a localized timezone, means that the site does not get automatic DST updates.
1214
- *
1215
- * This check looks for default or UTC values and recommends changing to a fixed location.
1216
- *
1217
- * @return array The test results.
1218
- */
1219
- public function get_test_timezone_not_utc() {
1220
- $result = array(
1221
- 'label' => __( 'Your site uses localized timezones', 'health-check' ),
1222
- 'status' => 'good',
1223
- 'badge' => array(
1224
- 'label' => __( 'Performance', 'health-check' ),
1225
- 'color' => 'blue',
1226
- ),
1227
- 'description' => sprintf(
1228
- '<p>%s</p>',
1229
- __( 'Daylight Savings Time (DST) may affect the times used and shown by your site, and using an UTC offset, instead of a localized timezone, means that the site does not get automatic DST updates.', 'health-check' )
1230
- ),
1231
- 'actions' => '',
1232
- 'test' => 'timezone_not_utc',
1233
- );
1234
-
1235
- $timezone = get_option( 'timezone_string', null );
1236
-
1237
- if ( empty( $timezone ) || 'UTC' === substr( $timezone, 0, 3 ) ) {
1238
- $result['status'] = 'recommended';
1239
- $result['label'] = __( 'Your site is not using localized timezones', 'health-check' );
1240
-
1241
- $result['actions'] .= sprintf(
1242
- '<p><a href="%s">%s</a></p>',
1243
- esc_url( admin_url( 'options-general.php' ) ),
1244
- __( 'Update your site timezone', 'health-check' )
1245
- );
1246
- }
1247
-
1248
- return $result;
1249
- }
1250
-
1251
- /**
1252
- * Test if debug information is enabled.
1253
- *
1254
- * When WP_DEBUG is enabled, errors and information may be disclosed to site visitors, or it may be
1255
- * logged to a publicly accessible file.
1256
- *
1257
- * Debugging is also frequently left enabled after looking for errors on a site, as site owners do
1258
- * not understand the implications of this.
1259
- *
1260
- * @since 5.2.0
1261
- *
1262
- * @return array The test results.
1263
- */
1264
- public function get_test_is_in_debug_mode() {
1265
- $result = array(
1266
- 'label' => __( 'Your site is not set to output debug information', 'health-check' ),
1267
- 'status' => 'good',
1268
- 'badge' => array(
1269
- 'label' => __( 'Security', 'health-check' ),
1270
- 'color' => 'blue',
1271
- ),
1272
- 'description' => sprintf(
1273
- '<p>%s</p>',
1274
- __( 'Debug mode is often enabled to gather more details about an error or site failure, but may contain sensitive information which should not be available on a publicly available website.', 'health-check' )
1275
- ),
1276
- 'actions' => sprintf(
1277
- '<p><a href="%s" target="_blank" rel="noopener noreferrer">%s <span class="screen-reader-text">%s</span><span aria-hidden="true" class="dashicons dashicons-external"></span></a></p>',
1278
- /* translators: Documentation explaining debugging in WordPress. */
1279
- esc_url( __( 'https://wordpress.org/support/article/debugging-in-wordpress/', 'health-check' ) ),
1280
- __( 'Read about debugging in WordPress.', 'health-check' ),
1281
- /* translators: accessibility text */
1282
- __( '(opens in a new tab)', 'health-check' )
1283
- ),
1284
- 'test' => 'is_in_debug_mode',
1285
- );
1286
-
1287
- if ( defined( 'WP_DEBUG' ) && WP_DEBUG ) {
1288
- if ( defined( 'WP_DEBUG_LOG' ) && WP_DEBUG_LOG ) {
1289
- $result['label'] = __( 'Your site is set to log errors to a potentially public file.', 'health-check' );
1290
-
1291
- $result['status'] = 'critical';
1292
-
1293
- $result['description'] .= sprintf(
1294
- '<p>%s</p>',
1295
- sprintf(
1296
- /* translators: %s: WP_DEBUG_LOG */
1297
- __( 'The value, %s, has been added to this website&#8217;s configuration file. This means any errors on the site will be written to a file which is potentially available to normal users.', 'health-check' ),
1298
- '<code>WP_DEBUG_LOG</code>'
1299
- )
1300
- );
1301
- }
1302
-
1303
- if ( defined( 'WP_DEBUG_DISPLAY' ) && WP_DEBUG_DISPLAY ) {
1304
- $result['label'] = __( 'Your site is set to display errors to site visitors', 'health-check' );
1305
-
1306
- $result['status'] = 'critical';
1307
-
1308
- $result['description'] .= sprintf(
1309
- '<p>%s</p>',
1310
- sprintf(
1311
- /* translators: 1: WP_DEBUG_DISPLAY, 2: WP_DEBUG */
1312
- __( 'The value, %1$s, has either been enabled by %2$s or added to your configuration file. This will make errors display on the front end of your site.', 'health-check' ),
1313
- '<code>WP_DEBUG_DISPLAY</code>',
1314
- '<code>WP_DEBUG</code>'
1315
- )
1316
- );
1317
- }
1318
- }
1319
-
1320
- return $result;
1321
- }
1322
-
1323
- public function json_test_is_in_debug_mode() {
1324
- wp_send_json_success( $this->get_test_is_in_debug_mode() );
1325
- }
1326
-
1327
- /**
1328
- * Test if your site is serving content over HTTPS.
1329
- *
1330
- * Many sites have varying degrees of HTTPS support, the most common of which is sites that have it
1331
- * enabled, but only if you visit the right site address.
1332
- *
1333
- * @since 5.2.0
1334
- *
1335
- * @return array The test results.
1336
- */
1337
- public function get_test_https_status() {
1338
- $result = array(
1339
- 'label' => __( 'Your website is using an active HTTPS connection.', 'health-check' ),
1340
- 'status' => 'good',
1341
- 'badge' => array(
1342
- 'label' => __( 'Security', 'health-check' ),
1343
- 'color' => 'blue',
1344
- ),
1345
- 'description' => sprintf(
1346
- '<p>%s</p>',
1347
- __( 'An HTTPS connection is needed for many features on the web today, it also gains the trust of your visitors by helping to protecting their online privacy.', 'health-check' )
1348
- ),
1349
- 'actions' => sprintf(
1350
- '<p><a href="%s" target="_blank" rel="noopener noreferrer">%s <span class="screen-reader-text">%s</span><span aria-hidden="true" class="dashicons dashicons-external"></span></a></p>',
1351
- /* translators: Documentation explaining HTTPS and why it should be used. */
1352
- esc_url( __( 'https://wordpress.org/support/article/why-should-i-use-https/', 'health-check' ) ),
1353
- __( 'Read more about why you should use HTTPS', 'health-check' ),
1354
- /* translators: accessibility text */
1355
- __( '(opens in a new tab)', 'health-check' )
1356
- ),
1357
- 'test' => 'https_status',
1358
- );
1359
-
1360
- if ( is_ssl() ) {
1361
- $wp_url = get_bloginfo( 'wpurl' );
1362
- $site_url = get_bloginfo( 'url' );
1363
-
1364
- if ( 'https' !== substr( $wp_url, 0, 5 ) || 'https' !== substr( $site_url, 0, 5 ) ) {
1365
- $result['status'] = 'recommended';
1366
-
1367
- $result['label'] = __( 'Only parts of your site are using HTTPS', 'health-check' );
1368
-
1369
- $result['description'] = sprintf(
1370
- '<p>%s</p>',
1371
- sprintf(
1372
- /* translators: %s: URL to Settings > General to change options. */
1373
- __( 'You are accessing this website using HTTPS, but your <a href="%s">WordPress Address</a> is not set up to use HTTPS by default.', 'health-check' ),
1374
- esc_url( admin_url( 'options-general.php' ) )
1375
- )
1376
- );
1377
-
1378
- $result['actions'] .= sprintf(
1379
- '<p><a href="%s">%s</a></p>',
1380
- esc_url( admin_url( 'options-general.php' ) ),
1381
- __( 'Update your site addresses', 'health-check' )
1382
- );
1383
- }
1384
- } else {
1385
- $result['status'] = 'recommended';
1386
-
1387
- $result['label'] = __( 'Your site does not use HTTPS', 'health-check' );
1388
- }
1389
-
1390
- return $result;
1391
- }
1392
-
1393
- /**
1394
- * Check if the HTTP API can handle SSL/TLS requests.
1395
- *
1396
- * @since 5.2.0
1397
- *
1398
- * @return array The test results.
1399
- */
1400
- public function get_test_ssl_support() {
1401
- $result = array(
1402
- 'label' => '',
1403
- 'status' => '',
1404
- 'badge' => array(
1405
- 'label' => __( 'Security', 'health-check' ),
1406
- 'color' => 'blue',
1407
- ),
1408
- 'description' => sprintf(
1409
- '<p>%s</p>',
1410
- __( 'Securely communicating between servers are needed for transactions such as fetching files, conducting sales on store sites, and much more.', 'health-check' )
1411
- ),
1412
- 'actions' => '',
1413
- 'test' => 'ssl_support',
1414
- );
1415
-
1416
- $supports_https = wp_http_supports( array( 'ssl' ) );
1417
-
1418
- if ( $supports_https ) {
1419
- $result['status'] = 'good';
1420
-
1421
- $result['label'] = __( 'Your site can communicate securely with other services', 'health-check' );
1422
- } else {
1423
- $result['status'] = 'critical';
1424
-
1425
- $result['label'] = __( 'Your site is unable to communicate securely with other services', 'health-check' );
1426
-
1427
- $result['description'] .= sprintf(
1428
- '<p>%s</p>',
1429
- __( 'Talk to your web host about OpenSSL support for PHP.', 'health-check' )
1430
- );
1431
- }
1432
-
1433
- return $result;
1434
- }
1435
-
1436
- /**
1437
- * Test if scheduled events run as intended.
1438
- *
1439
- * If scheduled events are not running, this may indicate something with WP_Cron is not working as intended,
1440
- * or that there are orphaned events hanging around from older code.
1441
- *
1442
- * @since 5.2.0
1443
- *
1444
- * @return array The test results.
1445
- */
1446
- public function get_test_scheduled_events() {
1447
- $result = array(
1448
- 'label' => __( 'Scheduled events are running', 'health-check' ),
1449
- 'status' => 'good',
1450
- 'badge' => array(
1451
- 'label' => __( 'Performance', 'health-check' ),
1452
- 'color' => 'blue',
1453
- ),
1454
- 'description' => sprintf(
1455
- '<p>%s</p>',
1456
- __( 'Scheduled events are what periodically looks for updates to plugins, themes and WordPress itself. It is also what makes sure scheduled posts are published on time. It may also be used by various plugins to make sure that planned actions are executed.', 'health-check' )
1457
- ),
1458
- 'actions' => '',
1459
- 'test' => 'scheduled_events',
1460
- );
1461
-
1462
- $schedule = new Health_Check_WP_Cron();
1463
-
1464
- if ( is_wp_error( $schedule->has_missed_cron() ) ) {
1465
- $result['status'] = 'critical';
1466
-
1467
- $result['label'] = __( 'It was not possible to check your scheduled events', 'health-check' );
1468
-
1469
- $result['description'] = sprintf(
1470
- '<p>%s</p>',
1471
- sprintf(
1472
- /* translators: %s: The error message returned while from the cron scheduler. */
1473
- __( 'While trying to test your site&#8217;s scheduled events, the following error was returned: %s', 'health-check' ),
1474
- $schedule->has_missed_cron()->get_error_message()
1475
- )
1476
- );
1477
- } elseif ( $schedule->has_missed_cron() ) {
1478
- $result['status'] = 'recommended';
1479
-
1480
- $result['label'] = __( 'A scheduled event has failed', 'health-check' );
1481
-
1482
- $result['description'] = sprintf(
1483
- '<p>%s</p>',
1484
- sprintf(
1485
- /* translators: %s: The name of the failed cron event. */
1486
- __( 'The scheduled event, %s, failed to run. Your site still works, but this may indicate that scheduling posts or automated updates may not work as intended.', 'health-check' ),
1487
- $schedule->last_missed_cron
1488
- )
1489
- );
1490
- } elseif ( $schedule->has_late_cron() ) {
1491
- $result['status'] = 'recommended';
1492
-
1493
- $result['label'] = __( 'A scheduled event is late', 'health-check' );
1494
-
1495
- $result['description'] = sprintf(
1496
- '<p>%s</p>',
1497
- sprintf(
1498
- /* translators: %s: The name of the late cron event. */
1499
- __( 'The scheduled event, %s, is late to run. Your site still works, but this may indicate that scheduling posts or automated updates may not work as intended.', 'health-check' ),
1500
- $schedule->last_late_cron
1501
- )
1502
- );
1503
- }
1504
-
1505
- return $result;
1506
- }
1507
-
1508
- /**
1509
- * Test if WordPress can run automated background updates.
1510
- *
1511
- * Background updates in WordPress are primarily used for minor releases and security updates. It's important
1512
- * to either have these working, or be aware that they are intentionally disabled for whatever reason.
1513
- *
1514
- * @since 5.2.0
1515
- *
1516
- * @return array The test results.
1517
- */
1518
- public function get_test_background_updates() {
1519
- $result = array(
1520
- 'label' => __( 'Background updates are working', 'health-check' ),
1521
- 'status' => 'good',
1522
- 'badge' => array(
1523
- 'label' => __( 'Security', 'health-check' ),
1524
- 'color' => 'blue',
1525
- ),
1526
- 'description' => sprintf(
1527
- '<p>%s</p>',
1528
- __( 'Background updates ensure that WordPress can auto-update if a security update is released for the version you are currently using.', 'health-check' )
1529
- ),
1530
- 'actions' => '',
1531
- 'test' => 'background_updates',
1532
- );
1533
-
1534
- // Run the auto-update tests in a separate class,
1535
- // as there are many considerations to be made.
1536
- $automatic_updates = new Health_Check_Auto_Updates();
1537
- $tests = $automatic_updates->run_tests();
1538
-
1539
- $output = '<ul>';
1540
-
1541
- foreach ( $tests as $test ) {
1542
- $severity_string = __( 'Passed', 'health-check' );
1543
-
1544
- if ( 'fail' === $test->severity ) {
1545
- $result['label'] = __( 'Background updates are not working as expected', 'health-check' );
1546
-
1547
- $result['status'] = 'critical';
1548
-
1549
- $severity_string = __( 'Error', 'health-check' );
1550
- }
1551
-
1552
- if ( 'warning' === $test->severity && 'good' === $result['status'] ) {
1553
- $result['label'] = __( 'Background updates may not be working properly', 'health-check' );
1554
-
1555
- $result['status'] = 'recommended';
1556
-
1557
- $severity_string = __( 'Warning', 'health-check' );
1558
- }
1559
-
1560
- $output .= sprintf(
1561
- '<li><span class="%s"><span class="screen-reader-text">%s</span></span> %s</li>',
1562
- esc_attr( $test->severity ),
1563
- $severity_string,
1564
- $test->description
1565
- );
1566
- }
1567
-
1568
- $output .= '</ul>';
1569
-
1570
- if ( 'good' !== $result['status'] ) {
1571
- $result['description'] .= sprintf(
1572
- '<p>%s</p>',
1573
- $output
1574
- );
1575
- }
1576
-
1577
- return $result;
1578
- }
1579
-
1580
- public function json_test_background_updates() {
1581
- wp_send_json_success( $this->get_test_background_updates() );
1582
- }
1583
-
1584
- public function get_test_extension_updates() {
1585
- $result = array(
1586
- 'label' => esc_html__( 'Plugin and theme updates are working', 'health-check' ),
1587
- 'status' => 'good',
1588
- 'badge' => array(
1589
- 'label' => esc_html__( 'Security', 'health-check' ),
1590
- 'color' => 'red',
1591
- ),
1592
- 'description' => sprintf(
1593
- '<p>%s</p>',
1594
- esc_html__( 'Plugins or themes may have their own way of handling updates, which could break or negatively impact normal updates in WordPress.', 'health-check' )
1595
- ),
1596
- 'actions' => '',
1597
- 'test' => 'extension_updates',
1598
- );
1599
-
1600
- $updates = new Health_Check_Updates();
1601
- $tests = $updates->run_tests();
1602
-
1603
- $output = '<ul>';
1604
-
1605
- foreach ( $tests as $test ) {
1606
- $severity_string = esc_html__( 'Passed', 'health-check' );
1607
-
1608
- if ( 'fail' === $test->severity ) {
1609
- $result['label'] = esc_html__( 'Plugin or theme updates are not working', 'health-check' );
1610
-
1611
- $result['status'] = 'critical';
1612
-
1613
- $severity_string = esc_html__( 'Error', 'health-check' );
1614
- }
1615
-
1616
- if ( 'warning' === $test->severity && 'good' === $result['status'] ) {
1617
- $result['label'] = esc_html__( 'Some plugin or theme updates may not work as expected', 'health-check' );
1618
-
1619
- $result['status'] = 'recommended';
1620
-
1621
- $severity_string = esc_html__( 'Warning', 'health-check' );
1622
- }
1623
-
1624
- $output .= sprintf(
1625
- '<li><span class="%s"><span class="screen-reader-text">%s</span></span> %s</li>',
1626
- esc_attr( $test->severity ),
1627
- $severity_string,
1628
- $test->desc
1629
- );
1630
- }
1631
-
1632
- $output .= '</ul>';
1633
-
1634
- if ( 'critical' === $result['status'] ) {
1635
- $result['description'] .= sprintf(
1636
- '<p>%s</p>',
1637
- $output
1638
- );
1639
- }
1640
-
1641
- return $result;
1642
- }
1643
-
1644
- /**
1645
- * Test if loopbacks work as expected.
1646
- *
1647
- * A loopback is when WordPress queries itself, for example to start a new WP_Cron instance, or when editing a
1648
- * plugin or theme. This has shown itself to be a recurring issue as code can very easily break this interaction.
1649
- *
1650
- * @since 5.2.0
1651
- *
1652
- * @return array The test results.
1653
- */
1654
- public function get_test_loopback_requests() {
1655
- $result = array(
1656
- 'label' => __( 'Your site can perform loopback requests', 'health-check' ),
1657
- 'status' => 'good',
1658
- 'badge' => array(
1659
- 'label' => __( 'Performance', 'health-check' ),
1660
- 'color' => 'blue',
1661
- ),
1662
- 'description' => sprintf(
1663
- '<p>%s</p>',
1664
- __( 'Loopback requests are used to run scheduled events, and are also used by the built-in editors for themes and plugins to verify code stability.', 'health-check' )
1665
- ),
1666
- 'actions' => '',
1667
- 'test' => 'loopback_requests',
1668
- );
1669
-
1670
- $loopback = new Health_Check_Loopback();
1671
-
1672
- $check_loopback = $loopback->can_perform_loopback();
1673
-
1674
- $result['status'] = $check_loopback->status;
1675
-
1676
- if ( 'good' !== $check_loopback->status ) {
1677
- $result['label'] = __( 'Your site could not complete a loopback request', 'health-check' );
1678
-
1679
- $result['description'] .= sprintf(
1680
- '<p>%s</p>',
1681
- $check_loopback->message
1682
- );
1683
- }
1684
-
1685
- return $result;
1686
- }
1687
-
1688
- public function json_test_loopback_requests() {
1689
- wp_send_json_success( $this->get_test_loopback_requests() );
1690
- }
1691
-
1692
- /**
1693
- * Test if HTTP requests are blocked.
1694
- *
1695
- * It's possible to block all outgoing communication (with the possibility of whitelisting hosts) via the
1696
- * HTTP API. This may create problems for users as many features are running as services these days.
1697
- *
1698
- * @since 5.2.0
1699
- *
1700
- * @return array The test results.
1701
- */
1702
- public function get_test_http_requests() {
1703
- $result = array(
1704
- 'label' => __( 'HTTP requests seem to be working as expected', 'health-check' ),
1705
- 'status' => 'good',
1706
- 'badge' => array(
1707
- 'label' => __( 'Performance', 'health-check' ),
1708
- 'color' => 'blue',
1709
- ),
1710
- 'description' => sprintf(
1711
- '<p>%s</p>',
1712
- __( 'It is possible for site maintainers to block all, or some, communication to other sites and services. If set up incorrectly, this may prevent plugins and themes from working as intended.', 'health-check' )
1713
- ),
1714
- 'actions' => '',
1715
- 'test' => 'http_requests',
1716
- );
1717
-
1718
- $blocked = false;
1719
- $hosts = array();
1720
-
1721
- if ( defined( 'WP_HTTP_BLOCK_EXTERNAL' ) ) {
1722
- $blocked = true;
1723
- }
1724
-
1725
- if ( defined( 'WP_ACCESSIBLE_HOSTS' ) ) {
1726
- $hosts = explode( ',', WP_ACCESSIBLE_HOSTS );
1727
- }
1728
-
1729
- if ( $blocked && 0 === sizeof( $hosts ) ) {
1730
- $result['status'] = 'critical';
1731
-
1732
- $result['label'] = __( 'HTTP requests are blocked', 'health-check' );
1733
-
1734
- $result['description'] .= sprintf(
1735
- '<p>%s</p>',
1736
- sprintf(
1737
- /* translators: %s: Name of the constant used. */
1738
- __( 'HTTP requests have been blocked by the %s constant, with no allowed hosts.', 'health-check' ),
1739
- '<code>WP_HTTP_BLOCK_EXTERNAL</code>'
1740
- )
1741
- );
1742
- }
1743
-
1744
- if ( $blocked && 0 < sizeof( $hosts ) ) {
1745
- $result['status'] = 'recommended';
1746
-
1747
- $result['label'] = __( 'HTTP requests are partially blocked', 'health-check' );
1748
-
1749
- $result['description'] .= sprintf(
1750
- '<p>%s</p>',
1751
- sprintf(
1752
- /* translators: 1: Name of the constant used. 2: List of hostnames whitelisted. */
1753
- __( 'HTTP requests have been blocked by the %1$s constant, with some hosts whitelisted: %2$s.', 'health-check' ),
1754
- '<code>WP_HTTP_BLOCK_EXTERNAL</code>',
1755
- implode( ',', $hosts )
1756
- )
1757
- );
1758
- }
1759
-
1760
- return $result;
1761
- }
1762
-
1763
- /**
1764
- * Test if the REST API is accessible.
1765
- *
1766
- * Various security measures may block the REST API from working, or it may have been disabled in general.
1767
- * This is required for the new block editor to work, so we explicitly test for this.
1768
- *
1769
- * @since 5.2.0
1770
- *
1771
- * @return array The test results.
1772
- */
1773
- public function get_test_rest_availability() {
1774
- $result = array(
1775
- 'label' => __( 'The REST API is available', 'health-check' ),
1776
- 'status' => 'good',
1777
- 'badge' => array(
1778
- 'label' => __( 'Performance', 'health-check' ),
1779
- 'color' => 'blue',
1780
- ),
1781
- 'description' => sprintf(
1782
- '<p>%s</p>',
1783
- __( 'The REST API is one way WordPress, and other applications, communicate with the server. One example is the block editor screen, which relies on this to display, and save, your posts and pages.', 'health-check' )
1784
- ),
1785
- 'actions' => '',
1786
- 'test' => 'rest_availability',
1787
- );
1788
-
1789
- $cookies = wp_unslash( $_COOKIE );
1790
- $timeout = 10;
1791
- $headers = array(
1792
- 'Cache-Control' => 'no-cache',
1793
- 'X-WP-Nonce' => wp_create_nonce( 'wp_rest' ),
1794
- );
1795
-
1796
- // Include Basic auth in loopback requests.
1797
- if ( isset( $_SERVER['PHP_AUTH_USER'] ) && isset( $_SERVER['PHP_AUTH_PW'] ) ) {
1798
- $headers['Authorization'] = 'Basic ' . base64_encode( wp_unslash( $_SERVER['PHP_AUTH_USER'] ) . ':' . wp_unslash( $_SERVER['PHP_AUTH_PW'] ) );
1799
- }
1800
-
1801
- $url = rest_url( 'wp/v2/types/post' );
1802
-
1803
- // The context for this is editing with the new block editor.
1804
- $url = add_query_arg(
1805
- array(
1806
- 'context' => 'edit',
1807
- ),
1808
- $url
1809
- );
1810
-
1811
- $r = wp_remote_get( $url, compact( 'cookies', 'headers', 'timeout' ) );
1812
-
1813
- if ( is_wp_error( $r ) ) {
1814
- $result['status'] = 'critical';
1815
-
1816
- $result['label'] = __( 'The REST API encountered an error', 'health-check' );
1817
-
1818
- $result['description'] .= sprintf(
1819
- '<p>%s</p>',
1820
- sprintf(
1821
- '%s<br>%s',
1822
- __( 'The REST API request failed due to an error.', 'health-check' ),
1823
- sprintf(
1824
- /* translators: 1: The HTTP response code. 2: The error message returned. */
1825
- __( 'Error: [%1$s] %2$s', 'health-check' ),
1826
- wp_remote_retrieve_response_code( $r ),
1827
- $r->get_error_message()
1828
- )
1829
- )
1830
- );
1831
- } elseif ( 200 !== wp_remote_retrieve_response_code( $r ) ) {
1832
- $result['status'] = 'recommended';
1833
-
1834
- $result['label'] = __( 'The REST API encountered an unexpected result', 'health-check' );
1835
-
1836
- $result['description'] .= sprintf(
1837
- '<p>%s</p>',
1838
- sprintf(
1839
- /* translators: 1: The HTTP response code returned. 2: The error message returned. */
1840
- __( 'The REST API call gave the following unexpected result: (%1$d) %2$s.', 'health-check' ),
1841
- wp_remote_retrieve_response_code( $r ),
1842
- wp_remote_retrieve_body( $r )
1843
- )
1844
- );
1845
- } else {
1846
- $json = json_decode( wp_remote_retrieve_body( $r ), true );
1847
-
1848
- if ( false !== $json && ! isset( $json['capabilities'] ) ) {
1849
- $result['status'] = 'recommended';
1850
-
1851
- $result['label'] = __( 'The REST API did not behave correctly', 'health-check' );
1852
-
1853
- $result['description'] .= sprintf(
1854
- '<p>%s</p>',
1855
- sprintf(
1856
- /* translators: %s: the name of the query parameter being tested. */
1857
- __( 'The REST API did not process the %s query parameter correctly.', 'health-check' ),
1858
- '<code>context</code>'
1859
- )
1860
- );
1861
- }
1862
- }
1863
-
1864
- return $result;
1865
- }
1866
-
1867
- /**
1868
- * Return a set of tests that belong to the site status page.
1869
- *
1870
- * Each site status test is defined here, they may be `direct` tests, that run on page load, or `async` tests
1871
- * which will run later down the line via JavaScript calls to improve page performance and hopefully also user
1872
- * experiences.
1873
- *
1874
- * @since 5.2.0
1875
- *
1876
- * @return array The list of tests to run.
1877
- */
1878
- public static function get_tests() {
1879
- global $health_check_site_status;
1880
-
1881
- $tests = array(
1882
- 'direct' => array(
1883
- 'wordpress_version' => array(
1884
- 'label' => __( 'WordPress Version', 'health-check' ),
1885
- 'test' => array( $health_check_site_status, 'get_test_wordpress_version' ),
1886
- ),
1887
- 'plugin_version' => array(
1888
- 'label' => __( 'Plugin Versions', 'health-check' ),
1889
- 'test' => array( $health_check_site_status, 'get_test_plugin_version' ),
1890
- ),
1891
- 'theme_version' => array(
1892
- 'label' => __( 'Theme Versions', 'health-check' ),
1893
- 'test' => array( $health_check_site_status, 'get_test_theme_version' ),
1894
- ),
1895
- 'php_version' => array(
1896
- 'label' => __( 'PHP Version', 'health-check' ),
1897
- 'test' => array( $health_check_site_status, 'get_test_php_version' ),
1898
- ),
1899
- 'sql_server' => array(
1900
- 'label' => __( 'Database Server version', 'health-check' ),
1901
- 'test' => array( $health_check_site_status, 'get_test_sql_server' ),
1902
- ),
1903
- 'php_extensions' => array(
1904
- 'label' => __( 'PHP Extensions', 'health-check' ),
1905
- 'test' => array( $health_check_site_status, 'get_test_php_extensions' ),
1906
- ),
1907
- 'utf8mb4_support' => array(
1908
- 'label' => __( 'MySQL utf8mb4 support', 'health-check' ),
1909
- 'test' => array( $health_check_site_status, 'get_test_utf8mb4_support' ),
1910
- ),
1911
- 'https_status' => array(
1912
- 'label' => __( 'HTTPS status', 'health-check' ),
1913
- 'test' => array( $health_check_site_status, 'get_test_https_status' ),
1914
- ),
1915
- 'ssl_support' => array(
1916
- 'label' => __( 'Secure communication', 'health-check' ),
1917
- 'test' => array( $health_check_site_status, 'get_test_ssl_support' ),
1918
- ),
1919
- 'scheduled_events' => array(
1920
- 'label' => __( 'Scheduled events', 'health-check' ),
1921
- 'test' => array( $health_check_site_status, 'get_test_scheduled_events' ),
1922
- ),
1923
- 'http_requests' => array(
1924
- 'label' => __( 'HTTP Requests', 'health-check' ),
1925
- 'test' => array( $health_check_site_status, 'get_test_http_requests' ),
1926
- ),
1927
- 'debug_enabled' => array(
1928
- 'label' => __( 'Debugging enabled', 'health-check' ),
1929
- 'test' => array( $health_check_site_status, 'get_test_is_in_debug_mode' ),
1930
- ),
1931
- 'timezones' => array(
1932
- 'label' => __( 'Timezone', 'health-check' ),
1933
- 'test' => array( $health_check_site_status, 'get_test_timezone_not_utc' ),
1934
- ),
1935
- ),
1936
- 'async' => array(
1937
- 'dotorg_communication' => array(
1938
- 'label' => __( 'Communication with WordPress.org', 'health-check' ),
1939
- 'test' => 'dotorg_communication',
1940
- ),
1941
- 'background_updates' => array(
1942
- 'label' => __( 'Background updates', 'health-check' ),
1943
- 'test' => 'background_updates',
1944
- ),
1945
- 'loopback_requests' => array(
1946
- 'label' => __( 'Loopback request', 'health-check' ),
1947
- 'test' => 'loopback_requests',
1948
- ),
1949
- ),
1950
- );
1951
-
1952
- // Conditionally include REST rules if the function for it exists.
1953
- if ( function_exists( 'rest_url' ) ) {
1954
- $tests['direct']['rest_availability'] = array(
1955
- 'label' => __( 'REST API availability', 'health-check' ),
1956
- 'test' => array( $health_check_site_status, 'get_test_rest_availability' ),
1957
- );
1958
- }
1959
-
1960
- /**
1961
- * Add or modify which site status tests are run on a site.
1962
- *
1963
- * The site health is determined by a set of tests based on best practices from
1964
- * both the WordPress Hosting Team, but also web standards in general.
1965
- *
1966
- * Some sites may not have the same requirements, for example the automatic update
1967
- * checks may be handled by a host, and are therefore disabled in core.
1968
- * Or maybe you want to introduce a new test, is caching enabled/disabled/stale for example.
1969
- *
1970
- * Tests may be added either as direct, or asynchronous ones. Any test that may require some time
1971
- * to complete should run asynchronously, to avoid extended loading periods within wp-admin.
1972
- *
1973
- * @since 5.2.0
1974
- *
1975
- * @param array $test_type {
1976
- * An associative array, where the `$test_type` is either `direct` or
1977
- * `async`, to declare if the test should run via AJAX calls after page load.
1978
- *
1979
- * @type array $identifier {
1980
- * `$identifier` should be a unique identifier for the test that should run.
1981
- * Plugins and themes are encouraged to prefix test identifiers with their slug
1982
- * to avoid any collisions between tests.
1983
- *
1984
- * @type string $label A friendly label for your test to identify it by.
1985
- * @type mixed $test A callable to perform a direct test, or a string AJAX action to be called
1986
- * to perform an async test.
1987
- * }
1988
- * }
1989
- */
1990
- $tests = apply_filters( 'site_status_tests', $tests );
1991
-
1992
- return $tests;
1993
- }
1994
-
1995
- public function scheduled_check() {
1996
- // Bootstrap wp-admin, as WP_Cron doesn't do this for us.
1997
- require_once( trailingslashit( ABSPATH ) . 'wp-admin/includes/admin.php' );
1998
-
1999
- $bulk_tests = Health_Check_Site_Status::get_tests();
2000
-
2001
- $results = array();
2002
-
2003
- $site_status = array(
2004
- 'good' => 0,
2005
- 'recommended' => 0,
2006
- 'critical' => 0,
2007
- );
2008
-
2009
- $tests = array_merge( $bulk_tests['direct'], $bulk_tests['async'] );
2010
-
2011
- foreach ( $tests as $test ) {
2012
- $function = sprintf(
2013
- 'get_test_%s',
2014
- $test['test']
2015
- );
2016
-
2017
- if ( method_exists( $this, $function ) && is_callable( array( $this, $function ) ) ) {
2018
- $results[] = call_user_func( array( $this, $function ) );
2019
- } else {
2020
- $results[] = call_user_func( $test['test'] );
2021
- }
2022
- }
2023
-
2024
- foreach ( $results as $result ) {
2025
- if ( 'critical' === $result['status'] ) {
2026
- $site_status['critical']++;
2027
- } elseif ( 'recommended' === $result['status'] ) {
2028
- $site_status['recommended']++;
2029
- } else {
2030
- $site_status['good']++;
2031
- }
2032
- }
2033
-
2034
- set_transient( 'health-check-site-status-result', json_encode( $site_status ) );
2035
- }
2036
- }
2037
-
2038
- global $health_check_site_status;
2039
- $health_check_site_status = new Health_Check_Site_Status();
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
includes/class-health-check-updates.php DELETED
@@ -1,592 +0,0 @@
1
- <?php
2
- /**
3
- * Class for testing plugin/theme updates in the WordPress code.
4
- *
5
- * @package Health Check
6
- */
7
-
8
- // Make sure the file is not directly accessible.
9
- if ( ! defined( 'ABSPATH' ) ) {
10
- die( 'We\'re sorry, but you can not directly access this file.' );
11
- }
12
-
13
- /**
14
- * Class Health_Check_Updates
15
- */
16
- class Health_Check_Updates {
17
- private $plugins_before;
18
- private $plugins_after;
19
- private static $plugins_blocked;
20
- private $themes_before;
21
- private $themes_after;
22
- private static $themes_blocked;
23
-
24
- /**
25
- * Health_Check_Updates constructor.
26
- *
27
- * @uses Health_Check_Updates::init()
28
- *
29
- * @return void
30
- */
31
- public function __construct() {
32
- $this->init();
33
- }
34
-
35
- /**
36
- * Initiate the plugin class.
37
- *
38
- * @return void
39
- */
40
- public function init() {
41
- $this->plugins_before = (array) array();
42
- $this->plugins_after = (array) array();
43
- self::$plugins_blocked = (bool) false;
44
-
45
- $this->themes_before = (array) array();
46
- $this->themes_after = (array) array();
47
- self::$themes_blocked = (bool) false;
48
- }
49
-
50
- /**
51
- * Run tests to determine if auto-updates can run.
52
- *
53
- * @uses get_class_methods()
54
- * @uses substr()
55
- * @uses call_user_func()
56
- *
57
- * @return array
58
- */
59
- public function run_tests() {
60
- $tests = array();
61
-
62
- foreach ( get_class_methods( $this ) as $method ) {
63
- if ( 'test_' !== substr( $method, 0, 5 ) ) {
64
- continue;
65
- }
66
-
67
- $result = call_user_func( array( $this, $method ) );
68
-
69
- if ( false === $result || null === $result ) {
70
- continue;
71
- }
72
-
73
- $result = (object) $result;
74
-
75
- if ( empty( $result->severity ) ) {
76
- $result->severity = 'warning';
77
- }
78
-
79
- $tests[ $method ] = $result;
80
- }
81
-
82
- return $tests;
83
- }
84
-
85
- /**
86
- * Check if plugin updates have been tampered with.
87
- *
88
- * @uses Health_Check_Updates::check_plugin_update_hooks()
89
- * @uses esc_html__()
90
- * @uses Health_Check_Updates::check_plugin_update_pre_request()
91
- * @uses Health_Check_Updates::check_plugin_update_request_args()
92
- *
93
- * @return array
94
- */
95
- function test_plugin_updates() {
96
- // Check if any update hooks have been removed.
97
- $hooks = $this->check_plugin_update_hooks();
98
- if ( ! $hooks ) {
99
- return array(
100
- 'desc' => esc_html__( 'Plugin update hooks have been removed.', 'health-check' ),
101
- 'severity' => 'fail',
102
- );
103
- }
104
-
105
- // Check if update requests are being blocked.
106
- $blocked = $this->check_plugin_update_pre_request();
107
- if ( true === $blocked ) {
108
- return array(
109
- 'desc' => esc_html__( 'Plugin update requests have been blocked.', 'health-check' ),
110
- 'severity' => 'fail',
111
- );
112
- }
113
-
114
- // Check if plugins have been removed from the update requests.
115
- $diff = (array) $this->check_plugin_update_request_args();
116
- if ( 0 !== count( $diff ) ) {
117
- return array(
118
- 'desc' => sprintf(
119
- /* translators: %s: List of plugin names. */
120
- esc_html__( 'The following Plugins have been removed from update checks: %s.', 'health-check' ),
121
- implode( ',', $diff )
122
- ),
123
- 'severity' => 'warning',
124
- );
125
- }
126
-
127
- return array(
128
- 'desc' => esc_html__( 'Plugin updates should be working as expected.', 'health-check' ),
129
- 'severity' => 'pass',
130
- );
131
- }
132
-
133
- /**
134
- * Check if any plugin update hooks have been removed.
135
- *
136
- * @uses has_filter()
137
- * @uses wp_next_scheduled()
138
- *
139
- * @return array
140
- */
141
- function check_plugin_update_hooks() {
142
- $test1 = has_filter( 'load-plugins.php', 'wp_update_plugins' );
143
- $test2 = has_filter( 'load-update.php', 'wp_update_plugins' );
144
- $test3 = has_filter( 'load-update-core.php', 'wp_update_plugins' );
145
- $test4 = has_filter( 'wp_update_plugins', 'wp_update_plugins' );
146
- $test5 = has_filter( 'admin_init', '_maybe_update_plugins' );
147
- $test6 = wp_next_scheduled( 'wp_update_plugins' );
148
-
149
- return $test1 && $test2 && $test3 && $test4 && $test5 && $test6;
150
- }
151
-
152
- /**
153
- * Check if plugin update request checks are being tampered with at the 'pre_http_request' filter.
154
- *
155
- * @uses add_action()
156
- * @uses Health_Check_Updates::wp_plugin_update_fake_request()
157
- * @uses esc_html__()
158
- *
159
- * @return array
160
- */
161
- function check_plugin_update_pre_request() {
162
- add_action( 'pre_http_request', array( $this, 'plugin_pre_request_check' ), PHP_INT_MAX, 3 );
163
- add_action( 'pre_http_request', array( $this, 'block_fake_request' ), PHP_INT_MAX, 3 );
164
-
165
- $this->plugin_update_fake_request();
166
-
167
- remove_action( 'pre_http_request', array( $this, 'plugin_pre_request_check' ), PHP_INT_MAX );
168
- remove_action( 'pre_http_request', array( $this, 'block_fake_request' ), PHP_INT_MAX );
169
-
170
- return self::$plugins_blocked;
171
- }
172
-
173
- /**
174
- * Check plugin update requests to see if they are being blocked.
175
- *
176
- * @param bool $pre If not false, request cancelled.
177
- * @param array $r Request parameters.
178
- * @param string $url Request URL.
179
- * @return bool
180
- */
181
- function plugin_pre_request_check( $pre, $r, $url ) {
182
- $check_url = 'api.wordpress.org/plugins/update-check/1.1/';
183
- if ( 0 !== substr_compare( $url, $check_url, -strlen( $check_url ) ) ) {
184
- return $pre; // Not a plugin update request.
185
- }
186
-
187
- // If not false something is blocking update checks
188
- if ( false !== $pre ) {
189
- self::$plugins_blocked = (bool) true;
190
- }
191
-
192
- return $pre;
193
- }
194
-
195
- /**
196
- * Check if plugins are being removed at the 'http_request_args' filter.
197
- *
198
- * @uses add_action()
199
- * @uses Health_Check_Updates::wp_plugin_update_fake_request()
200
- * @uses remove_action()
201
- *
202
- * @return array
203
- */
204
- function check_plugin_update_request_args() {
205
- add_action( 'http_request_args', array( $this, 'plugin_request_args_before' ), 1, 2 );
206
- add_action( 'http_request_args', array( $this, 'plugin_request_args_after' ), PHP_INT_MAX, 2 );
207
- add_action( 'pre_http_request', array( $this, 'block_fake_request' ), PHP_INT_MAX, 3 );
208
-
209
- $this->plugin_update_fake_request();
210
-
211
- remove_action( 'http_request_args', array( $this, 'plugin_request_args_before' ), 1 );
212
- remove_action( 'http_request_args', array( $this, 'plugin_request_args_after' ), PHP_INT_MAX );
213
- remove_action( 'pre_http_request', array( $this, 'block_fake_request' ), PHP_INT_MAX );
214
-
215
- $diff = array_diff_key( $this->plugins_before['plugins'], $this->plugins_after['plugins'] );
216
-
217
- $titles = array();
218
- foreach ( $diff as $item ) {
219
- $titles[] = $item['Title'];
220
- }
221
-
222
- return $titles;
223
- }
224
-
225
- /**
226
- * Record the list of plugins from plugin update requests at the start of filtering.
227
- *
228
- * @param array $r Request parameters.
229
- * @param string $url Request URL.
230
- * @return array
231
- */
232
- function plugin_request_args_before( $r, $url ) {
233
- $check_url = 'api.wordpress.org/plugins/update-check/1.1/';
234
- if ( 0 !== substr_compare( $url, $check_url, -strlen( $check_url ) ) ) {
235
- return $r; // Not a plugin update request.
236
- }
237
-
238
- $this->plugins_before = (array) json_decode( $r['body']['plugins'], true );
239
-
240
- return $r;
241
- }
242
-
243
- /**
244
- * Record the list of plugins from plugin update requests at the end of filtering.
245
- *
246
- * @param array $r Request parameters.
247
- * @param string $url Request URL.
248
- * @return array
249
- */
250
- function plugin_request_args_after( $r, $url ) {
251
- $check_url = 'api.wordpress.org/plugins/update-check/1.1/';
252
- if ( 0 !== substr_compare( $url, $check_url, -strlen( $check_url ) ) ) {
253
- return $r; // Not a plugin update request.
254
- }
255
-
256
- $this->plugins_after = (array) json_decode( $r['body']['plugins'], true );
257
-
258
- return $r;
259
- }
260
-
261
- /**
262
- * Create and trigger a fake plugin update check request.
263
- *
264
- * @uses get_plugins()
265
- * @uses get_option()
266
- * @uses wp_get_installed_translations()
267
- * @uses apply_filters()
268
- * @uses wp_json_encode()
269
- * @uses get_bloginfo()
270
- * @uses home_url()
271
- * @uses wp_http_supports()
272
- * @uses set_url_scheme()
273
- * @uses wp_remote_post()
274
- *
275
- * @return void
276
- */
277
- function plugin_update_fake_request() {
278
- if ( ! function_exists( 'get_plugins' ) ) {
279
- require_once( ABSPATH . 'wp-admin/includes/plugin.php' );
280
- }
281
-
282
- // Prepare data for the request.
283
- $plugins = get_plugins();
284
- $active = get_option( 'active_plugins', array() );
285
- $to_send = compact( 'plugins', 'active' );
286
- $translations = wp_get_installed_translations( 'plugins' );
287
- $locales = array_values( get_available_languages() );
288
- $locales = (array) apply_filters( 'plugins_update_check_locales', $locales );
289
- $locales = array_unique( $locales );
290
- $timeout = 3 + (int) ( count( $plugins ) / 10 );
291
-
292
- // Setup the request options.
293
- if ( function_exists( 'wp_json_encode' ) ) {
294
- $options = array(
295
- 'timeout' => $timeout,
296
- 'body' => array(
297
- 'plugins' => wp_json_encode( $to_send ),
298
- 'translations' => wp_json_encode( $translations ),
299
- 'locale' => wp_json_encode( $locales ),
300
- 'all' => wp_json_encode( true ),
301
- ),
302
- 'user-agent' => 'WordPress/' . get_bloginfo( 'version' ) . '; ' . home_url( '/' ),
303
- );
304
- } else {
305
- $options = array(
306
- 'timeout' => $timeout,
307
- 'body' => array(
308
- 'plugins' => json_encode( $to_send ),
309
- 'translations' => json_encode( $translations ),
310
- 'locale' => json_encode( $locales ),
311
- 'all' => json_encode( true ),
312
- ),
313
- 'user-agent' => 'WordPress/' . get_bloginfo( 'version' ) . '; ' . home_url( '/' ),
314
- );
315
- }
316
-
317
- // Set the URL
318
- $http_url = 'http://api.wordpress.org/plugins/update-check/1.1/';
319
- $url = wp_http_supports( array( 'ssl' ) ) ? set_url_scheme( $http_url, 'https' ) : $http_url;
320
-
321
- // Ignore the response. Just need the hooks to fire.
322
- wp_remote_post( $url, $options );
323
- }
324
-
325
- /**
326
- * Check if theme updates have been tampered with.
327
- *
328
- * @uses Health_Check_Updates::check_theme_update_hooks()
329
- * @uses esc_html__()
330
- * @uses Health_Check_Updates::check_theme_update_pre_request()
331
- * @uses Health_Check_Updates::check_theme_update_request_args()
332
- *
333
- * @return array
334
- */
335
- function test_constant_theme_updates() {
336
- // Check if any update hooks have been removed.
337
- $hooks = $this->check_theme_update_hooks();
338
- if ( ! $hooks ) {
339
- return array(
340
- 'desc' => esc_html__( 'Theme update hooks have been removed.', 'health-check' ),
341
- 'severity' => 'fail',
342
- );
343
- }
344
-
345
- // Check if update requests are being blocked.
346
- $blocked = $this->check_theme_update_pre_request();
347
- if ( true === $blocked ) {
348
- return array(
349
- 'desc' => esc_html__( 'Theme update requests have been blocked.', 'health-check' ),
350
- 'severity' => 'fail',
351
- );
352
- }
353
-
354
- // Check if themes have been removed from the update requests.
355
- $diff = (array) $this->check_theme_update_request_args();
356
- if ( 0 !== count( $diff ) ) {
357
- return array(
358
- 'desc' => sprintf(
359
- /* translators: %s: List of theme names. */
360
- esc_html__( 'The following Themes have been removed from update checks: %s.', 'health-check' ),
361
- implode( ',', $diff )
362
- ),
363
- 'severity' => 'warning',
364
- );
365
- }
366
-
367
- return array(
368
- 'desc' => esc_html__( 'Theme updates should be working as expected.', 'health-check' ),
369
- 'severity' => 'pass',
370
- );
371
- }
372
-
373
- /**
374
- * Check if any theme update hooks have been removed.
375
- *
376
- * @uses has_filter()
377
- * @uses wp_next_scheduled()
378
- *
379
- * @return array
380
- */
381
- function check_theme_update_hooks() {
382
- $test1 = has_filter( 'load-themes.php', 'wp_update_themes' );
383
- $test2 = has_filter( 'load-update.php', 'wp_update_themes' );
384
- $test3 = has_filter( 'load-update-core.php', 'wp_update_themes' );
385
- $test4 = has_filter( 'wp_update_themes', 'wp_update_themes' );
386
- $test5 = has_filter( 'admin_init', '_maybe_update_themes' );
387
- $test6 = wp_next_scheduled( 'wp_update_themes' );
388
-
389
- return $test1 && $test2 && $test3 && $test4 && $test5 && $test6;
390
- }
391
-
392
- /**
393
- * Check if theme update request checks are being tampered with at the 'pre_http_request' filter.
394
- *
395
- * @uses add_action()
396
- * @uses Health_Check_Updates::wp_theme_update_fake_request()
397
- * @uses esc_html__()
398
- *
399
- * @return array
400
- */
401
- function check_theme_update_pre_request() {
402
- add_action( 'pre_http_request', array( $this, 'theme_pre_request_check' ), PHP_INT_MAX, 3 );
403
- add_action( 'pre_http_request', array( $this, 'block_fake_request' ), PHP_INT_MAX, 3 );
404
-
405
- $this->theme_update_fake_request();
406
-
407
- remove_action( 'pre_http_request', array( $this, 'theme_pre_request_check' ), PHP_INT_MAX );
408
- remove_action( 'pre_http_request', array( $this, 'block_fake_request' ), PHP_INT_MAX );
409
-
410
- return self::$themes_blocked;
411
- }
412
-
413
- /**
414
- * Check theme update requests to see if they are being blocked.
415
- *
416
- * @param bool $pre If not false, request cancelled.
417
- * @param array $r Request parameters.
418
- * @param string $url Request URL.
419
- * @return bool
420
- */
421
- function theme_pre_request_check( $pre, $r, $url ) {
422
- $check_url = 'api.wordpress.org/themes/update-check/1.1/';
423
- if ( 0 !== substr_compare( $url, $check_url, -strlen( $check_url ) ) ) {
424
- return $pre; // Not a theme update request.
425
- }
426
-
427
- // If not false something is blocking update checks
428
- if ( false !== $pre ) {
429
- self::$themes_blocked = (bool) true;
430
- }
431
-
432
- return $pre;
433
- }
434
-
435
- /**
436
- * Check if themes are being removed at the 'http_request_args' filter.
437
- *
438
- * @uses add_action()
439
- * @uses Health_Check_Updates::wp_theme_update_fake_request()
440
- * @uses remove_action()
441
- *
442
- * @return array
443
- */
444
- function check_theme_update_request_args() {
445
- add_action( 'http_request_args', array( $this, 'theme_request_args_before' ), 1, 2 );
446
- add_action( 'http_request_args', array( $this, 'theme_request_args_after' ), PHP_INT_MAX, 2 );
447
- add_action( 'pre_http_request', array( $this, 'block_fake_request' ), PHP_INT_MAX, 3 );
448
-
449
- $this->theme_update_fake_request();
450
-
451
- remove_action( 'http_request_args', array( $this, 'theme_request_args_before' ), 1 );
452
- remove_action( 'http_request_args', array( $this, 'theme_request_args_after' ), PHP_INT_MAX );
453
- remove_action( 'pre_http_request', array( $this, 'block_fake_request' ), PHP_INT_MAX );
454
-
455
- $diff = array_diff_key( $this->themes_before['themes'], $this->themes_after['themes'] );
456
-
457
- $titles = array();
458
- foreach ( $diff as $item ) {
459
- $titles[] = $item['Title'];
460
- }
461
-
462
- return $titles;
463
- }
464
-
465
- /**
466
- * Record the list of themes from theme update requests at the start of filtering.
467
- *
468
- * @param array $r Request parameters.
469
- * @param string $url Request URL.
470
- * @return array
471
- */
472
- function theme_request_args_before( $r, $url ) {
473
- $check_url = 'api.wordpress.org/themes/update-check/1.1/';
474
- if ( 0 !== substr_compare( $url, $check_url, -strlen( $check_url ) ) ) {
475
- return $r; // Not a theme update request.
476
- }
477
-
478
- $this->themes_before = (array) json_decode( $r['body']['themes'], true );
479
-
480
- return $r;
481
- }
482
-
483
- /**
484
- * Record the list of themes from theme update requests at the end of filtering.
485
- *
486
- * @param array $r Request parameters.
487
- * @param string $url Request URL.
488
- * @return array
489
- */
490
- function theme_request_args_after( $r, $url ) {
491
- $check_url = 'api.wordpress.org/themes/update-check/1.1/';
492
- if ( 0 !== substr_compare( $url, $check_url, -strlen( $check_url ) ) ) {
493
- return $r; // Not a theme update request.
494
- }
495
-
496
- $this->themes_after = (array) json_decode( $r['body']['themes'], true );
497
-
498
- return $r;
499
- }
500
-
501
- /**
502
- * Create and trigger a fake theme update check request.
503
- *
504
- * @uses wp_get_themes()
505
- * @uses wp_get_installed_translations()
506
- * @uses get_option()
507
- * @uses get_available_languages()
508
- * @uses wp_json_encode()
509
- * @uses get_bloginfo()
510
- * @uses home_url()
511
- * @uses wp_http_supports()
512
- * @uses set_url_scheme()
513
- * @uses wp_remote_post()
514
- *
515
- * @return void
516
- */
517
- function theme_update_fake_request() {
518
- $themes = array();
519
- $checked = array();
520
- $request = array();
521
- $installed_themes = wp_get_themes();
522
- $translations = wp_get_installed_translations( 'themes' );
523
- $request['active'] = get_option( 'stylesheet' );
524
-
525
- foreach ( $installed_themes as $theme ) {
526
- $checked[ $theme->get_stylesheet() ] = $theme->get( 'Version' );
527
-
528
- $themes[ $theme->get_stylesheet() ] = array(
529
- 'Name' => $theme->get( 'Name' ),
530
- 'Title' => $theme->get( 'Name' ),
531
- 'Version' => $theme->get( 'Version' ),
532
- 'Author' => $theme->get( 'Author' ),
533
- 'Author URI' => $theme->get( 'AuthorURI' ),
534
- 'Template' => $theme->get_template(),
535
- 'Stylesheet' => $theme->get_stylesheet(),
536
- );
537
- }
538
-
539
- $request['themes'] = $themes;
540
-
541
- $locales = array_values( get_available_languages() );
542
- $timeout = 3 + (int) ( count( $themes ) / 10 );
543
-
544
- if ( function_exists( 'wp_json_encode' ) ) {
545
- $options = array(
546
- 'timeout' => $timeout,
547
- 'body' => array(
548
- 'themes' => wp_json_encode( $request ),
549
- 'translations' => wp_json_encode( $translations ),
550
- 'locale' => wp_json_encode( $locales ),
551
- ),
552
- 'user-agent' => 'WordPress/' . get_bloginfo( 'version' ) . '; ' . home_url( '/' ),
553
- );
554
- } else {
555
- $options = array(
556
- 'timeout' => $timeout,
557
- 'body' => array(
558
- 'themes' => json_encode( $request ),
559
- 'translations' => json_encode( $translations ),
560
- 'locale' => json_encode( $locales ),
561
- ),
562
- 'user-agent' => 'WordPress/' . get_bloginfo( 'version' ) . '; ' . home_url( '/' ),
563
- );
564
- }
565
-
566
- // Set the URL
567
- $http_url = 'http://api.wordpress.org/themes/update-check/1.1/';
568
- $url = wp_http_supports( array( 'ssl' ) ) ? set_url_scheme( $http_url, 'https' ) : $http_url;
569
-
570
- // Ignore the response. Just need the hooks to fire.
571
- wp_remote_post( $url, $options );
572
- }
573
-
574
- /**
575
- * Blocks the fake update requests, ensuring they do not slow down page loads.
576
- *
577
- * @param bool $pre If not false, request cancelled.
578
- * @param array $r Request parameters.
579
- * @param string $url Request URL.
580
- * @return bool
581
- */
582
- function block_fake_request( $pre, $r, $url ) {
583
- switch ( $url ) {
584
- case 'https://api.wordpress.org/plugins/update-check/1.1/':
585
- return 'block_request';
586
- case 'https://api.wordpress.org/themes/update-check/1.1/':
587
- return 'block_request';
588
- default:
589
- return $pre;
590
- }
591
- }
592
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
includes/class-health-check-wp-cron.php DELETED
@@ -1,143 +0,0 @@
1
- <?php
2
- /**
3
- * Perform tests to see if WP_Cron is operating as it should.
4
- *
5
- * @package Health Check
6
- */
7
-
8
- // Make sure the file is not directly accessible.
9
- if ( ! defined( 'ABSPATH' ) ) {
10
- die( 'We\'re sorry, but you can not directly access this file.' );
11
- }
12
-
13
- /**
14
- * Class Health_Check_WP_Cron
15
- */
16
- class Health_Check_WP_Cron {
17
- public $schedules;
18
- public $crons;
19
- public $last_missed_cron = null;
20
- public $last_late_cron = null;
21
- private $timeout_missed_cron = null;
22
- private $timeout_late_cron = null;
23
-
24
- /**
25
- * Health_Check_WP_Cron constructor.
26
- */
27
- public function __construct() {
28
- $this->init();
29
-
30
- $this->timeout_late_cron = 0;
31
- $this->timeout_missed_cron = - 5 * MINUTE_IN_SECONDS;
32
-
33
- if ( defined( 'DISABLE_WP_CRON' ) && DISABLE_WP_CRON ) {
34
- $this->timeout_late_cron = - 15 * MINUTE_IN_SECONDS;
35
- $this->timeout_missed_cron = - 1 * HOUR_IN_SECONDS;
36
- }
37
- }
38
-
39
- /**
40
- * Initiate the class
41
- *
42
- * @uses wp_get_schedules()
43
- * @uses Health_Check_WP_Cron::get_cron_tasks()
44
- *
45
- * @return void
46
- */
47
- public function init() {
48
- $this->schedules = wp_get_schedules();
49
- $this->get_cron_tasks();
50
- }
51
-
52
- /**
53
- * Populate our list of cron events and store them to a class-wide variable.
54
- *
55
- * Derived from `get_cron_events()` in WP Crontrol (https://plugins.svn.wordpress.org/wp-crontrol)
56
- * by John Blackburn.
57
- *
58
- * @uses _get_cron_array()
59
- * @uses WP_Error
60
- *
61
- * @return void
62
- */
63
- private function get_cron_tasks() {
64
- $cron_tasks = _get_cron_array();
65
-
66
- if ( empty( $cron_tasks ) ) {
67
- $this->crons = new WP_Error( 'no_tasks', __( 'No scheduled events exist on this site.', 'health-check' ) );
68
- return;
69
- }
70
-
71
- $this->crons = array();
72
-
73
- foreach ( $cron_tasks as $time => $cron ) {
74
- foreach ( $cron as $hook => $dings ) {
75
- foreach ( $dings as $sig => $data ) {
76
-
77
- $this->crons[ "$hook-$sig-$time" ] = (object) array(
78
- 'hook' => $hook,
79
- 'time' => $time,
80
- 'sig' => $sig,
81
- 'args' => $data['args'],
82
- 'schedule' => $data['schedule'],
83
- 'interval' => isset( $data['interval'] ) ? $data['interval'] : null,
84
- );
85
-
86
- }
87
- }
88
- }
89
- }
90
-
91
- /**
92
- * Check if any scheduled tasks have been missed.
93
- *
94
- * Returns a boolean value of `true` if a scheduled task has been missed and ends processing.
95
- * If the list of crons is an instance of WP_Error, return the instance instead of a boolean value.
96
- *
97
- * @uses is_wp_error()
98
- * @uses time()
99
- *
100
- * @return bool|WP_Error
101
- */
102
- public function has_missed_cron() {
103
- if ( is_wp_error( $this->crons ) ) {
104
- return $this->crons;
105
- }
106
-
107
- foreach ( $this->crons as $id => $cron ) {
108
- if ( ( $cron->time - time() ) < $this->timeout_missed_cron ) {
109
- $this->last_missed_cron = $cron->hook;
110
- return true;
111
- }
112
- }
113
-
114
- return false;
115
- }
116
-
117
- /**
118
- * Check if any scheduled tasks are late.
119
- *
120
- * Returns a boolean value of `true` if a scheduled task is late and ends processing. If the list of
121
- * crons is an instance of WP_Error, return the instance instead of a boolean value.
122
- *
123
- * @return bool|WP_Error true if a cron is late, false if it wasn't. WP_Error if the cron is set to that.
124
- */
125
- public function has_late_cron() {
126
- if ( is_wp_error( $this->crons ) ) {
127
- return $this->crons;
128
- }
129
-
130
- foreach ( $this->crons as $id => $cron ) {
131
- $cron_offset = $cron->time - time();
132
- if (
133
- $cron_offset >= $this->timeout_missed_cron &&
134
- $cron_offset < $this->timeout_late_cron
135
- ) {
136
- $this->last_late_cron = $cron->hook;
137
- return true;
138
- }
139
- }
140
-
141
- return false;
142
- }
143
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
modals/js-result-warnings.php DELETED
@@ -1,17 +0,0 @@
1
- <?php
2
-
3
- // Make sure the file is not directly accessible.
4
- if ( ! defined( 'ABSPATH' ) ) {
5
- die( 'We\'re sorry, but you can not directly access this file.' );
6
- }
7
-
8
- ?>
9
-
10
- <div class="health-check-modal" data-modal-action="" data-parent-field="">
11
- <div class="modal-content">
12
- <span class="modal-close">&times;</span>
13
- <div id="dynamic-content">
14
- &nbsp;
15
- </div>
16
- </div>
17
- </div>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
{assets/mu-plugin → mu-plugin}/health-check-troubleshooting-mode.php RENAMED
@@ -2,7 +2,7 @@
2
  /*
3
  Plugin Name: Health Check Troubleshooting Mode
4
  Description: Conditionally disabled themes or plugins on your site for a given session, used to rule out conflicts during troubleshooting.
5
- Version: 1.7.2
6
  */
7
 
8
  if ( ! defined( 'ABSPATH' ) ) {
@@ -10,7 +10,7 @@ if ( ! defined( 'ABSPATH' ) ) {
10
  }
11
 
12
  // Set the MU plugin version.
13
- define( 'HEALTH_CHECK_TROUBLESHOOTING_MODE_PLUGIN_VERSION', '1.7.2' );
14
 
15
  class Health_Check_Troubleshooting_MU {
16
  private $disable_hash = null;
@@ -29,9 +29,14 @@ class Health_Check_Troubleshooting_MU {
29
  'health-check-change-active-theme',
30
  'health-check-troubleshoot-enable-plugin',
31
  'health-check-troubleshoot-disable-plugin',
 
 
 
32
  );
33
 
34
  private $default_themes = array(
 
 
35
  'twentytwenty',
36
  'twentynineteen',
37
  'twentyseventeen',
@@ -57,41 +62,51 @@ class Health_Check_Troubleshooting_MU {
57
  * @return void
58
  */
59
  public function init() {
60
- add_action( 'admin_bar_menu', array( $this, 'health_check_troubleshoot_menu_bar' ), 999 );
61
-
62
  add_filter( 'option_active_plugins', array( $this, 'health_check_loopback_test_disable_plugins' ) );
63
  add_filter( 'option_active_sitewide_plugins', array( $this, 'health_check_loopback_test_disable_plugins' ) );
64
 
65
  add_filter( 'pre_option_template', array( $this, 'health_check_troubleshoot_theme_template' ) );
66
  add_filter( 'pre_option_stylesheet', array( $this, 'health_check_troubleshoot_theme_stylesheet' ) );
67
 
68
- add_filter( 'wp_fatal_error_handler_enabled', array( $this, 'wp_fatal_error_handler_enabled' ) );
69
-
70
  add_filter( 'bulk_actions-plugins', array( $this, 'remove_plugin_bulk_actions' ) );
71
  add_filter( 'handle_bulk_actions-plugins', array( $this, 'handle_plugin_bulk_actions' ), 10, 3 );
72
 
73
- add_action( 'admin_notices', array( $this, 'prompt_install_default_theme' ) );
74
- add_filter( 'user_has_cap', array( $this, 'remove_plugin_theme_install' ) );
75
 
76
- add_action( 'plugin_action_links', array( $this, 'plugin_actions' ), 50, 4 );
 
 
 
77
 
78
- add_action( 'admin_notices', array( $this, 'display_dashboard_widget' ) );
79
- add_action( 'admin_footer', array( $this, 'dashboard_widget_scripts' ) );
 
80
 
81
- add_action( 'wp_logout', array( $this, 'health_check_troubleshooter_mode_logout' ) );
82
- add_action( 'init', array( $this, 'health_check_troubleshoot_get_captures' ) );
83
 
84
- add_action( 'admin_enqueue_scripts', array( $this, 'enqueue_assets' ) );
85
 
86
- /*
87
- * Plugin activations can be forced by other tools in things like themes, so let's
88
- * attempt to work around that by forcing plugin lists back and forth.
89
- *
90
- * This is not an ideal scenario, but one we must accept as reality.
91
- */
92
- add_action( 'activated_plugin', array( $this, 'plugin_activated' ) );
93
 
94
- $this->load_options();
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
95
  }
96
 
97
  /**
@@ -113,35 +128,17 @@ class Health_Check_Troubleshooting_MU {
113
  * @return void
114
  */
115
  public function enqueue_assets() {
116
- if ( ! $this->is_troubleshooting() || ! is_admin() ) {
117
  return;
118
  }
119
 
120
- wp_enqueue_style( 'health-check', plugins_url( '/health-check/assets/css/health-check.css' ), array(), HEALTH_CHECK_TROUBLESHOOTING_MODE_PLUGIN_VERSION );
121
 
122
  if ( ! wp_script_is( 'site-health', 'registered' ) ) {
123
- wp_enqueue_script( 'site-health', plugins_url( '/health-check/assets/javascript/health-check.js' ), array( 'jquery', 'wp-a11y', 'wp-util' ), HEALTH_CHECK_TROUBLESHOOTING_MODE_PLUGIN_VERSION, true );
124
  }
125
 
126
- wp_enqueue_script( 'health-check', plugins_url( '/health-check/assets/javascript/troubleshooting-mode.js' ), array( 'site-health' ), HEALTH_CHECK_TROUBLESHOOTING_MODE_PLUGIN_VERSION, true );
127
- }
128
-
129
- /**
130
- * Allow troubleshooting Mode to override the WSOD protection introduced in WordPress 5.2.0
131
- *
132
- * This will prevent incorrect reporting of errors while testing sites, without touching the
133
- * settings put in by site admins in regular scenarios.
134
- *
135
- * @param bool $enabled
136
- *
137
- * @return bool
138
- */
139
- public function wp_fatal_error_handler_enabled( $enabled ) {
140
- if ( ! $this->is_troubleshooting() ) {
141
- return $enabled;
142
- }
143
-
144
- return false;
145
  }
146
 
147
  /**
@@ -154,7 +151,7 @@ class Health_Check_Troubleshooting_MU {
154
  * @return void
155
  */
156
  public function prompt_install_default_theme() {
157
- if ( ! $this->is_troubleshooting() || $this->has_default_theme() ) {
158
  return;
159
  }
160
 
@@ -185,10 +182,6 @@ class Health_Check_Troubleshooting_MU {
185
  * @return array
186
  */
187
  public function remove_plugin_theme_install( $caps ) {
188
- if ( ! $this->is_troubleshooting() ) {
189
- return $caps;
190
- }
191
-
192
  $caps['switch_themes'] = false;
193
 
194
  /*
@@ -214,10 +207,6 @@ class Health_Check_Troubleshooting_MU {
214
  * @return void
215
  */
216
  public function plugin_activated() {
217
- if ( ! $this->is_troubleshooting() ) {
218
- return;
219
- }
220
-
221
  // Force the database entry for active plugins if someone tried changing plugins while in Troubleshooting Mode.
222
  update_option( 'active_plugins', $this->active_plugins );
223
  }
@@ -335,10 +324,6 @@ class Health_Check_Troubleshooting_MU {
335
  * @return array
336
  */
337
  public function plugin_actions( $actions, $plugin_file, $plugin_data, $context ) {
338
- if ( ! $this->is_troubleshooting() ) {
339
- return $actions;
340
- }
341
-
342
  if ( 'mustuse' === $context ) {
343
  return $actions;
344
  }
@@ -601,10 +586,6 @@ class Health_Check_Troubleshooting_MU {
601
  * @return void
602
  */
603
  function health_check_troubleshooter_mode_logout() {
604
- if ( ! $this->is_troubleshooting() ) {
605
- return;
606
- }
607
-
608
  if ( isset( $_COOKIE['wp-health-check-disable-plugins'] ) ) {
609
  $this->disable_troubleshooting_mode();
610
  }
@@ -629,10 +610,6 @@ class Health_Check_Troubleshooting_MU {
629
  * @return void
630
  */
631
  function health_check_troubleshoot_get_captures() {
632
- if ( ! $this->is_troubleshooting() ) {
633
- return;
634
- }
635
-
636
  // Disable Troubleshooting Mode.
637
  if ( isset( $_GET['health-check-disable-troubleshooting'] ) ) {
638
  $this->disable_troubleshooting_mode();
@@ -657,16 +634,48 @@ class Health_Check_Troubleshooting_MU {
657
 
658
  update_option( 'health-check-allowed-plugins', $this->allowed_plugins );
659
 
660
- if ( ! $this->test_site_state() ) {
661
- $this->allowed_plugins = $old_allowed_plugins;
662
- update_option( 'health-check-allowed-plugins', $old_allowed_plugins );
663
-
664
  $this->add_dashboard_notice(
665
  sprintf(
666
- // translators: %s: The plugin slug that was enabled.
667
- __( 'When enabling the plugin, %s, a site failure occurred. Because of this the change was automatically reverted.', 'health-check' ),
668
  $_GET['health-check-troubleshoot-enable-plugin']
669
  ),
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
670
  'warning'
671
  );
672
  }
@@ -683,16 +692,48 @@ class Health_Check_Troubleshooting_MU {
683
 
684
  update_option( 'health-check-allowed-plugins', $this->allowed_plugins );
685
 
686
- if ( ! $this->test_site_state() ) {
687
- $this->allowed_plugins = $old_allowed_plugins;
688
- update_option( 'health-check-allowed-plugins', $old_allowed_plugins );
689
-
690
  $this->add_dashboard_notice(
691
  sprintf(
692
- // translators: %s: The plugin slug that was disabled.
693
- __( 'When disabling the plugin, %s, a site failure occurred. Because of this the change was automatically reverted.', 'health-check' ),
694
  $_GET['health-check-troubleshoot-disable-plugin']
695
  ),
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
696
  'warning'
697
  );
698
  }
@@ -707,15 +748,47 @@ class Health_Check_Troubleshooting_MU {
707
 
708
  update_option( 'health-check-current-theme', $_GET['health-check-change-active-theme'] );
709
 
710
- if ( ! $this->test_site_state() ) {
711
- update_option( 'health-check-current-theme', $old_theme );
712
-
713
  $this->add_dashboard_notice(
714
  sprintf(
715
- // translators: %s: The theme slug that was switched to.
716
- __( 'When switching the active theme to %s, a site failure occurred. Because of this we reverted the theme to the one you used previously.', 'health-check' ),
717
  $_GET['health-check-change-active-theme']
718
  ),
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
719
  'warning'
720
  );
721
  }
@@ -749,10 +822,6 @@ class Health_Check_Troubleshooting_MU {
749
  * @return void
750
  */
751
  function health_check_troubleshoot_menu_bar( $wp_menu ) {
752
- if ( ! $this->is_troubleshooting() ) {
753
- return;
754
- }
755
-
756
  // We need some admin functions to make this a better user experience, so include that file.
757
  if ( ! is_admin() ) {
758
  require_once( trailingslashit( ABSPATH ) . 'wp-admin/includes/plugin.php' );
@@ -760,8 +829,8 @@ class Health_Check_Troubleshooting_MU {
760
 
761
  // Make sure the updater tools are available since WordPress 5.5.0 auto-updates were introduced.
762
  if ( ! function_exists( 'wp_is_auto_update_enabled_for_type' ) ) {
763
- require_once( trailingslashit( ABSPATH ) . 'wp-admin/includes/update.php' );
764
- }
765
 
766
  // Ensure the theme functions are available to us on every page.
767
  include_once( trailingslashit( ABSPATH ) . 'wp-admin/includes/theme.php' );
@@ -938,10 +1007,6 @@ class Health_Check_Troubleshooting_MU {
938
  }
939
 
940
  public function dashboard_widget_scripts() {
941
- if ( ! $this->is_troubleshooting() ) {
942
- return;
943
- }
944
-
945
  // Check that it's the dashboard page, we don't want to disturb any other pages.
946
  $screen = get_current_screen();
947
  if ( 'dashboard' !== $screen->id && 'plugins' !== $screen->id ) {
@@ -950,10 +1015,6 @@ class Health_Check_Troubleshooting_MU {
950
  }
951
 
952
  public function display_dashboard_widget() {
953
- if ( ! $this->is_troubleshooting() ) {
954
- return;
955
- }
956
-
957
  // Check that it's the dashboard page, we don't want to disturb any other pages.
958
  $screen = get_current_screen();
959
  if ( 'dashboard' !== $screen->id && 'plugins' !== $screen->id ) {
@@ -1005,6 +1066,10 @@ class Health_Check_Troubleshooting_MU {
1005
  <p>
1006
  <?php _e( 'Here you can enable individual plugins or themes, helping you to find out what might be causing strange behaviors on your site. Do note that <strong>any changes you make to settings will be kept</strong> when you disable Troubleshooting Mode.', 'health-check' ); ?>
1007
  </p>
 
 
 
 
1008
  </div>
1009
  </div>
1010
 
@@ -1089,7 +1154,12 @@ class Health_Check_Troubleshooting_MU {
1089
  '<li><button type="button" class="show-remaining button button-link">%s</button></li>',
1090
  sprintf(
1091
  // translators: %d: Amount of hidden plugins.
1092
- __( 'Show %d remaining plugins', 'health-check' ),
 
 
 
 
 
1093
  ( is_countable( $this->active_plugins ) ? ( count( $this->active_plugins ) - 5 ) : 0 )
1094
  )
1095
  );
@@ -1168,7 +1238,12 @@ class Health_Check_Troubleshooting_MU {
1168
  '<li><button type="button" class="show-remaining button button-link">%s</button></li>',
1169
  sprintf(
1170
  // translators: %d: Amount of hidden themes.
1171
- __( 'Show %d remaining themes', 'health-check' ),
 
 
 
 
 
1172
  ( is_countable( $themes ) ? ( count( $themes ) - 5 ) : 0 )
1173
  )
1174
  );
@@ -1220,7 +1295,16 @@ class Health_Check_Troubleshooting_MU {
1220
  printf(
1221
  '<div class="notice notice-%s inline"><p>%s</p></div>',
1222
  esc_attr( $notice['severity'] ),
1223
- esc_html( $notice['message'] )
 
 
 
 
 
 
 
 
 
1224
  );
1225
  }
1226
  ?>
2
  /*
3
  Plugin Name: Health Check Troubleshooting Mode
4
  Description: Conditionally disabled themes or plugins on your site for a given session, used to rule out conflicts during troubleshooting.
5
+ Version: 1.8.0
6
  */
7
 
8
  if ( ! defined( 'ABSPATH' ) ) {
10
  }
11
 
12
  // Set the MU plugin version.
13
+ define( 'HEALTH_CHECK_TROUBLESHOOTING_MODE_PLUGIN_VERSION', '1.8.0' );
14
 
15
  class Health_Check_Troubleshooting_MU {
16
  private $disable_hash = null;
29
  'health-check-change-active-theme',
30
  'health-check-troubleshoot-enable-plugin',
31
  'health-check-troubleshoot-disable-plugin',
32
+ 'health-check-plugin-force-enable',
33
+ 'health-check-plugin-force-disable',
34
+ 'health-check-theme-force-switch',
35
  );
36
 
37
  private $default_themes = array(
38
+ 'twentytwentytwo',
39
+ 'twentytwentyone',
40
  'twentytwenty',
41
  'twentynineteen',
42
  'twentyseventeen',
62
  * @return void
63
  */
64
  public function init() {
 
 
65
  add_filter( 'option_active_plugins', array( $this, 'health_check_loopback_test_disable_plugins' ) );
66
  add_filter( 'option_active_sitewide_plugins', array( $this, 'health_check_loopback_test_disable_plugins' ) );
67
 
68
  add_filter( 'pre_option_template', array( $this, 'health_check_troubleshoot_theme_template' ) );
69
  add_filter( 'pre_option_stylesheet', array( $this, 'health_check_troubleshoot_theme_stylesheet' ) );
70
 
 
 
71
  add_filter( 'bulk_actions-plugins', array( $this, 'remove_plugin_bulk_actions' ) );
72
  add_filter( 'handle_bulk_actions-plugins', array( $this, 'handle_plugin_bulk_actions' ), 10, 3 );
73
 
74
+ $this->load_options();
 
75
 
76
+ // If troubleshooting mode is enabled, add special filters and actions.
77
+ if ( $this->is_troubleshooting() ) {
78
+ // Attempt to avoid cache entries from a troubleshooting session.
79
+ wp_suspend_cache_addition( true );
80
 
81
+ // Add nocache headers for browser caches.
82
+ add_action( 'init', 'nocache_headers' );
83
+ add_action( 'admin_init', 'nocache_headers' );
84
 
85
+ add_action( 'admin_enqueue_scripts', array( $this, 'enqueue_assets' ) );
 
86
 
87
+ add_action( 'admin_bar_menu', array( $this, 'health_check_troubleshoot_menu_bar' ), 999 );
88
 
89
+ add_filter( 'wp_fatal_error_handler_enabled', '__return_false' );
 
 
 
 
 
 
90
 
91
+ add_action( 'admin_notices', array( $this, 'prompt_install_default_theme' ) );
92
+ add_filter( 'user_has_cap', array( $this, 'remove_plugin_theme_install' ) );
93
+
94
+ add_action( 'plugin_action_links', array( $this, 'plugin_actions' ), 50, 4 );
95
+
96
+ add_action( 'admin_notices', array( $this, 'display_dashboard_widget' ) );
97
+ add_action( 'admin_footer', array( $this, 'dashboard_widget_scripts' ) );
98
+
99
+ add_action( 'wp_logout', array( $this, 'health_check_troubleshooter_mode_logout' ) );
100
+ add_action( 'init', array( $this, 'health_check_troubleshoot_get_captures' ) );
101
+
102
+ /*
103
+ * Plugin activations can be forced by other tools in things like themes, so let's
104
+ * attempt to work around that by forcing plugin lists back and forth.
105
+ *
106
+ * This is not an ideal scenario, but one we must accept as reality.
107
+ */
108
+ add_action( 'activated_plugin', array( $this, 'plugin_activated' ) );
109
+ }
110
  }
111
 
112
  /**
128
  * @return void
129
  */
130
  public function enqueue_assets() {
131
+ if ( ! is_admin() ) {
132
  return;
133
  }
134
 
135
+ wp_enqueue_style( 'health-check', plugins_url( '/health-check/build/health-check.css' ), array(), HEALTH_CHECK_TROUBLESHOOTING_MODE_PLUGIN_VERSION );
136
 
137
  if ( ! wp_script_is( 'site-health', 'registered' ) ) {
138
+ wp_enqueue_script( 'site-health', plugins_url( '/health-check/build/health-check.js' ), array( 'jquery', 'wp-a11y', 'wp-util' ), HEALTH_CHECK_TROUBLESHOOTING_MODE_PLUGIN_VERSION, true );
139
  }
140
 
141
+ wp_enqueue_script( 'health-check', plugins_url( '/health-check/build/troubleshooting-mode.js' ), array( 'site-health' ), HEALTH_CHECK_TROUBLESHOOTING_MODE_PLUGIN_VERSION, true );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
142
  }
143
 
144
  /**
151
  * @return void
152
  */
153
  public function prompt_install_default_theme() {
154
+ if ( $this->has_default_theme() ) {
155
  return;
156
  }
157
 
182
  * @return array
183
  */
184
  public function remove_plugin_theme_install( $caps ) {
 
 
 
 
185
  $caps['switch_themes'] = false;
186
 
187
  /*
207
  * @return void
208
  */
209
  public function plugin_activated() {
 
 
 
 
210
  // Force the database entry for active plugins if someone tried changing plugins while in Troubleshooting Mode.
211
  update_option( 'active_plugins', $this->active_plugins );
212
  }
324
  * @return array
325
  */
326
  public function plugin_actions( $actions, $plugin_file, $plugin_data, $context ) {
 
 
 
 
327
  if ( 'mustuse' === $context ) {
328
  return $actions;
329
  }
586
  * @return void
587
  */
588
  function health_check_troubleshooter_mode_logout() {
 
 
 
 
589
  if ( isset( $_COOKIE['wp-health-check-disable-plugins'] ) ) {
590
  $this->disable_troubleshooting_mode();
591
  }
610
  * @return void
611
  */
612
  function health_check_troubleshoot_get_captures() {
 
 
 
 
613
  // Disable Troubleshooting Mode.
614
  if ( isset( $_GET['health-check-disable-troubleshooting'] ) ) {
615
  $this->disable_troubleshooting_mode();
634
 
635
  update_option( 'health-check-allowed-plugins', $this->allowed_plugins );
636
 
637
+ if ( isset( $_GET['health-check-plugin-force-enable'] ) ) {
 
 
 
638
  $this->add_dashboard_notice(
639
  sprintf(
640
+ // translators: %s: The plugin slug.
641
+ 'The %s plugin was forcefully enabled.',
642
  $_GET['health-check-troubleshoot-enable-plugin']
643
  ),
644
+ 'info'
645
+ );
646
+ }
647
+
648
+ if ( ! $this->test_site_state() && ! isset( $_GET['health-check-plugin-force-enable'] ) ) {
649
+ $this->allowed_plugins = $old_allowed_plugins;
650
+ update_option( 'health-check-allowed-plugins', $old_allowed_plugins );
651
+
652
+ $notice = sprintf(
653
+ // Translators: %1$s: The link-button markup to force enable the plugin. %2$s: The force-enable link markup.
654
+ __( 'When enabling the plugin, %1$s, a site failure occurred. Because of this the change was automatically reverted. %2$s', 'health-check' ),
655
+ $_GET['health-check-troubleshoot-enable-plugin'],
656
+ sprintf(
657
+ '<a href="%s" aria-label="%s">%s</a>',
658
+ esc_url(
659
+ add_query_arg(
660
+ array(
661
+ 'health-check-troubleshoot-enable-plugin' => $_GET['health-check-troubleshoot-enable-plugin'],
662
+ 'health-check-plugin-force-enable' => 'true',
663
+ )
664
+ )
665
+ ),
666
+ esc_attr(
667
+ sprintf(
668
+ // translators: %s: Plugin name.
669
+ __( 'Force-enable the plugin, %s, even though the loopback checks failed.', 'health-check' ),
670
+ $_GET['health-check-troubleshoot-enable-plugin']
671
+ )
672
+ ),
673
+ __( 'Enable anyway', 'health-check' )
674
+ )
675
+ );
676
+
677
+ $this->add_dashboard_notice(
678
+ $notice,
679
  'warning'
680
  );
681
  }
692
 
693
  update_option( 'health-check-allowed-plugins', $this->allowed_plugins );
694
 
695
+ if ( isset( $_GET['health-check-plugin-force-disable'] ) ) {
 
 
 
696
  $this->add_dashboard_notice(
697
  sprintf(
698
+ // translators: %s: The plugin slug.
699
+ 'The %s plugin was forcefully disabled.',
700
  $_GET['health-check-troubleshoot-disable-plugin']
701
  ),
702
+ 'info'
703
+ );
704
+ }
705
+
706
+ if ( ! $this->test_site_state() && ! isset( $_GET['health-check-plugin-force-disable'] ) ) {
707
+ $this->allowed_plugins = $old_allowed_plugins;
708
+ update_option( 'health-check-allowed-plugins', $old_allowed_plugins );
709
+
710
+ $notice = sprintf(
711
+ // Translators: %1$s: The plugin slug that was disabled. %2$s: The force-disable link markup.
712
+ __( 'When disabling the plugin, %1$s, a site failure occurred. Because of this the change was automatically reverted. %2$s', 'health-check' ),
713
+ $_GET['health-check-troubleshoot-disable-plugin'],
714
+ sprintf(
715
+ '<a href="%1$s" aria-label="%2$s">%3$s</a>',
716
+ esc_url(
717
+ add_query_arg(
718
+ array(
719
+ 'health-check-troubleshoot-disable-plugin' => $_GET['health-check-troubleshoot-disable-plugin'],
720
+ 'health-check-plugin-force-disable' => 'true',
721
+ )
722
+ )
723
+ ),
724
+ esc_attr(
725
+ sprintf(
726
+ // translators: %s: Plugin name.
727
+ __( 'Force-disable the plugin, %s, even though the loopback checks failed.', 'health-check' ),
728
+ $_GET['health-check-troubleshoot-disable-plugin']
729
+ )
730
+ ),
731
+ __( 'Disable anyway', 'health-check' )
732
+ )
733
+ );
734
+
735
+ $this->add_dashboard_notice(
736
+ $notice,
737
  'warning'
738
  );
739
  }
748
 
749
  update_option( 'health-check-current-theme', $_GET['health-check-change-active-theme'] );
750
 
751
+ if ( isset( $_GET['health-check-theme-force-switch'] ) ) {
 
 
752
  $this->add_dashboard_notice(
753
  sprintf(
754
+ // translators: %s: The theme slug.
755
+ 'The theme was forcefully switched to %s.',
756
  $_GET['health-check-change-active-theme']
757
  ),
758
+ 'info'
759
+ );
760
+ }
761
+
762
+ if ( ! $this->test_site_state() && ! isset( $_GET['health-check-theme-force-switch'] ) ) {
763
+ update_option( 'health-check-current-theme', $old_theme );
764
+
765
+ $notice = sprintf(
766
+ // Translators: %1$s: The theme slug that was switched to.. %2$s: The force-enable link markup.
767
+ __( 'When switching the active theme to %1$s, a site failure occurred. Because of this we reverted the theme to the one you used previously. %2$s', 'health-check' ),
768
+ $_GET['health-check-change-active-theme'],
769
+ sprintf(
770
+ '<a href="%s" aria-label="%s">%s</a>',
771
+ esc_url(
772
+ add_query_arg(
773
+ array(
774
+ 'health-check-change-active-theme' => $_GET['health-check-change-active-theme'],
775
+ 'health-check-theme-force-switch' => 'true',
776
+ )
777
+ )
778
+ ),
779
+ esc_attr(
780
+ sprintf(
781
+ // translators: %s: Plugin name.
782
+ __( 'Force-switch to the %s theme, even though the loopback checks failed.', 'health-check' ),
783
+ $_GET['health-check-change-active-theme']
784
+ )
785
+ ),
786
+ __( 'Switch anyway', 'health-check' )
787
+ )
788
+ );
789
+
790
+ $this->add_dashboard_notice(
791
+ $notice,
792
  'warning'
793
  );
794
  }
822
  * @return void
823
  */
824
  function health_check_troubleshoot_menu_bar( $wp_menu ) {
 
 
 
 
825
  // We need some admin functions to make this a better user experience, so include that file.
826
  if ( ! is_admin() ) {
827
  require_once( trailingslashit( ABSPATH ) . 'wp-admin/includes/plugin.php' );
829
 
830
  // Make sure the updater tools are available since WordPress 5.5.0 auto-updates were introduced.
831
  if ( ! function_exists( 'wp_is_auto_update_enabled_for_type' ) ) {
832
+ require_once( trailingslashit( ABSPATH ) . 'wp-admin/includes/update.php' );
833
+ }
834
 
835
  // Ensure the theme functions are available to us on every page.
836
  include_once( trailingslashit( ABSPATH ) . 'wp-admin/includes/theme.php' );
1007
  }
1008
 
1009
  public function dashboard_widget_scripts() {
 
 
 
 
1010
  // Check that it's the dashboard page, we don't want to disturb any other pages.
1011
  $screen = get_current_screen();
1012
  if ( 'dashboard' !== $screen->id && 'plugins' !== $screen->id ) {
1015
  }
1016
 
1017
  public function display_dashboard_widget() {
 
 
 
 
1018
  // Check that it's the dashboard page, we don't want to disturb any other pages.
1019
  $screen = get_current_screen();
1020
  if ( 'dashboard' !== $screen->id && 'plugins' !== $screen->id ) {
1066
  <p>
1067
  <?php _e( 'Here you can enable individual plugins or themes, helping you to find out what might be causing strange behaviors on your site. Do note that <strong>any changes you make to settings will be kept</strong> when you disable Troubleshooting Mode.', 'health-check' ); ?>
1068
  </p>
1069
+
1070
+ <p>
1071
+ <?php _e( 'The Health Check plugin will attempt to disable cache solutions on your site, but if you are using a custom caching solution, you may need to disable it manually when troubleshooting.', 'health-check' ); ?>
1072
+ </p>
1073
  </div>
1074
  </div>
1075
 
1154
  '<li><button type="button" class="show-remaining button button-link">%s</button></li>',
1155
  sprintf(
1156
  // translators: %d: Amount of hidden plugins.
1157
+ _n(
1158
+ 'Show %d remaining plugin',
1159
+ 'Show %d remaining plugins',
1160
+ ( is_countable( $this->active_plugins ) ? ( count( $this->active_plugins ) - 5 ) : 0 ),
1161
+ 'health-check'
1162
+ ),
1163
  ( is_countable( $this->active_plugins ) ? ( count( $this->active_plugins ) - 5 ) : 0 )
1164
  )
1165
  );
1238
  '<li><button type="button" class="show-remaining button button-link">%s</button></li>',
1239
  sprintf(
1240
  // translators: %d: Amount of hidden themes.
1241
+ _n(
1242
+ 'Show %d remaining theme',
1243
+ 'Show %d remaining themes',
1244
+ ( is_countable( $themes ) ? ( count( $themes ) - 5 ) : 0 ),
1245
+ 'health-check'
1246
+ ),
1247
  ( is_countable( $themes ) ? ( count( $themes ) - 5 ) : 0 )
1248
  )
1249
  );
1295
  printf(
1296
  '<div class="notice notice-%s inline"><p>%s</p></div>',
1297
  esc_attr( $notice['severity'] ),
1298
+ wp_kses(
1299
+ $notice['message'],
1300
+ array(
1301
+ 'a' => array(
1302
+ 'class' => true,
1303
+ 'href' => true,
1304
+ 'aria-label' => true,
1305
+ ),
1306
+ )
1307
+ )
1308
  );
1309
  }
1310
  ?>
package.json ADDED
@@ -0,0 +1,59 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "author": "The WordPress Community",
3
+ "bugs": {
4
+ "url": "https://github.com/WordPress/health-check/issues"
5
+ },
6
+ "description": "WordPress site health tester, and troubleshooting tools for end users and anyone providing support",
7
+ "devDependencies": {
8
+ "@wordpress/scripts": "~23.7.0",
9
+ "@wordpress/env": "~5.2.0",
10
+ "@wordpress/stylelint-config": "~20.0.2",
11
+ "postcss-scss": "~4.0.4"
12
+ },
13
+ "dependencies": {
14
+ "clipboard": "~2.0.11"
15
+ },
16
+ "engines": {
17
+ "node": ">=16"
18
+ },
19
+ "keywords": [
20
+ "support",
21
+ "wordpress"
22
+ ],
23
+ "homepage": "https://github.com/WordPress/health-check",
24
+ "license": "GPL-2.0+",
25
+ "name": "health-check",
26
+ "repository": {
27
+ "type": "git",
28
+ "url": "https://github.com/WordPress/health-check"
29
+ },
30
+ "version": "0.1.0",
31
+ "scripts": {
32
+ "build": "wp-scripts build",
33
+ "lint:css": "wp-scripts lint-style './src/styles/**/*.scss'",
34
+ "lint:js": "wp-scripts lint-js ./src/javascript/**/*.js",
35
+ "watch": "wp-scripts start",
36
+ "wp-env": "wp-env",
37
+ "plugin-zip": "wp-scripts plugin-zip"
38
+ },
39
+ "stylelint": {
40
+ "extends": "@wordpress/stylelint-config",
41
+ "customSyntax": "postcss-scss",
42
+ "rules": {
43
+ "no-descending-specificity": null,
44
+ "no-invalid-position-at-import-rule": null
45
+ }
46
+ },
47
+ "files": [
48
+ "mu-plugin/**",
49
+ "HealthCheck/**",
50
+ "modals/**",
51
+ "pages/**",
52
+ "build/**",
53
+ "compat.php",
54
+ "health-check.php",
55
+ "uninstall.php",
56
+ "changelog.txt",
57
+ "readme.txt"
58
+ ]
59
+ }
pages/debug-data.php CHANGED
@@ -10,117 +10,120 @@ if ( ! defined( 'ABSPATH' ) ) {
10
  die( 'We\'re sorry, but you can not directly access this file.' );
11
  }
12
 
13
- Health_Check_Debug_Data::check_for_updates();
14
 
15
- $info = Health_Check_Debug_Data::debug_data();
16
  ?>
17
 
18
- <h2>
19
- <?php esc_html_e( 'Site Health Info', 'health-check' ); ?>
20
- </h2>
21
 
22
- <p>
23
  <?php
24
- printf(
25
- /* translators: %s: URL to Site Health Status page */
26
- __( 'This page can show you every detail about the configuration of your WordPress website. For any improvements that could be made, see the <a href="%s">Site Health Status</a> page.', 'health-check' ),
27
- esc_url( admin_url( 'site-health.php' ) )
28
- );
29
- ?>
30
- </p>
31
- <p>
32
- <?php _e( 'If you want to export a handy list of all the information on this page, you can use the button below to copy it to the clipboard. You can then paste it in a text file and save it to your device, or paste it in an email exchange with a support engineer or theme/plugin developer for example.', 'health-check' ); ?>
33
- </p>
34
-
35
- <div class="site-health-copy-buttons">
36
- <div class="copy-button-wrapper">
37
- <button type="button" class="button copy-button" data-clipboard-text="<?php echo esc_attr( Health_Check_Debug_Data::format( $info, 'debug' ) ); ?>">
38
- <?php _e( 'Copy site info to clipboard', 'health-check' ); ?>
39
- </button>
40
- <span class="success" aria-hidden="true"><?php _e( 'Copied!', 'health-check' ); ?></span>
41
- </div>
42
- </div>
43
 
44
- <div id="health-check-debug" class="health-check-accordion">
45
 
46
- <?php
47
- $sizes_fields = array( 'uploads_size', 'themes_size', 'plugins_size', 'wordpress_size', 'database_size', 'total_size' );
48
 
49
- foreach ( $info as $section => $details ) {
50
- if ( ! isset( $details['fields'] ) || empty( $details['fields'] ) ) {
51
- continue;
52
- }
53
  ?>
54
- <h3 class="health-check-accordion-heading">
55
- <button aria-expanded="false" class="health-check-accordion-trigger" aria-controls="health-check-accordion-block-<?php echo esc_attr( $section ); ?>" type="button">
56
- <span class="title">
57
- <?php echo esc_html( $details['label'] ); ?>
58
- <?php
59
-
60
- if ( isset( $details['show_count'] ) && $details['show_count'] ) {
61
- printf( '(%d)', count( $details['fields'] ) );
62
- }
63
 
64
- ?>
65
- </span>
66
- <?php
67
 
68
- if ( 'wp-paths-sizes' === $section ) {
69
- ?>
70
- <span class="health-check-wp-paths-sizes spinner"></span>
71
- <?php
72
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
73
 
74
- ?>
75
- <span class="icon"></span>
76
- </button>
77
- </h3>
78
 
79
- <div id="health-check-accordion-block-<?php echo esc_attr( $section ); ?>" class="health-check-accordion-panel" hidden="hidden">
80
  <?php
81
 
82
- if ( isset( $details['description'] ) && ! empty( $details['description'] ) ) {
83
- printf( '<p>%s</p>', $details['description'] );
84
- }
85
 
86
- ?>
87
- <table class="widefat striped health-check-table" role="presentation">
88
- <tbody>
89
- <?php
90
-
91
- foreach ( $details['fields'] as $field_name => $field ) {
92
- if ( is_array( $field['value'] ) ) {
93
- $values = '<ul>';
94
 
95
- foreach ( $field['value'] as $name => $value ) {
96
- $values .= sprintf( '<li>%s: %s</li>', esc_html( $name ), esc_html( $value ) );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
97
  }
98
 
99
- $values .= '</ul>';
100
- } else {
101
- $values = esc_html( $field['value'] );
102
- }
 
 
 
103
 
104
- if ( in_array( $field_name, $sizes_fields, true ) ) {
105
- printf( '<tr><td>%s</td><td class="%s">%s</td></tr>', esc_html( $field['label'] ), esc_attr( $field_name ), $values );
106
- } else {
107
- printf( '<tr><td>%s</td><td>%s</td></tr>', esc_html( $field['label'] ), $values );
108
  }
109
- }
110
 
111
- ?>
112
- </tbody>
113
- </table>
114
- </div>
115
- <?php } ?>
116
- </div>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
117
 
118
- <div class="site-health-view-more">
119
- <?php
120
- printf(
121
- '<a href="%s" class="button button-primary">%s</a>',
122
- esc_url( admin_url( 'tools.php?page=health-check&tab=phpinfo' ) ),
123
- esc_html__( 'View extended PHP information', 'health-check' )
124
- );
125
- ?>
126
  </div>
10
  die( 'We\'re sorry, but you can not directly access this file.' );
11
  }
12
 
13
+ WP_Debug_Data::check_for_updates();
14
 
15
+ $info = WP_Debug_Data::debug_data();
16
  ?>
17
 
18
+ <div class="notice notice-error hide-if-js">
19
+ <p><?php _e( 'The Site Health check requires JavaScript.' ); ?></p>
20
+ </div>
21
 
22
+ <div class="health-check-body health-check-debug-tab hide-if-no-js">
23
  <?php
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
24
 
25
+ WP_Debug_Data::check_for_updates();
26
 
27
+ $info = WP_Debug_Data::debug_data();
 
28
 
 
 
 
 
29
  ?>
 
 
 
 
 
 
 
 
 
30
 
31
+ <h2>
32
+ <?php _e( 'Site Health Info' ); ?>
33
+ </h2>
34
 
35
+ <p>
36
+ <?php
37
+ /* translators: %s: URL to Site Health Status page. */
38
+ printf( __( 'This page can show you every detail about the configuration of your WordPress website. For any improvements that could be made, see the <a href="%s">Site Health Status</a> page.' ), esc_url( admin_url( 'site-health.php' ) ) );
39
+ ?>
40
+ </p>
41
+ <p>
42
+ <?php _e( 'If you want to export a handy list of all the information on this page, you can use the button below to copy it to the clipboard. You can then paste it in a text file and save it to your device, or paste it in an email exchange with a support engineer or theme/plugin developer for example.' ); ?>
43
+ </p>
44
+
45
+ <div class="site-health-copy-buttons">
46
+ <div class="copy-button-wrapper">
47
+ <button type="button" class="button copy-button" data-clipboard-text="<?php echo esc_attr( WP_Debug_Data::format( $info, 'debug' ) ); ?>">
48
+ <?php _e( 'Copy site info to clipboard' ); ?>
49
+ </button>
50
+ <span class="success hidden" aria-hidden="true"><?php _e( 'Copied!' ); ?></span>
51
+ </div>
52
+ </div>
53
 
54
+ <div id="health-check-debug" class="health-check-accordion">
 
 
 
55
 
 
56
  <?php
57
 
58
+ $sizes_fields = array( 'uploads_size', 'themes_size', 'plugins_size', 'wordpress_size', 'database_size', 'total_size' );
 
 
59
 
60
+ foreach ( $info as $section => $details ) {
61
+ if ( ! isset( $details['fields'] ) || empty( $details['fields'] ) ) {
62
+ continue;
63
+ }
 
 
 
 
64
 
65
+ ?>
66
+ <h3 class="health-check-accordion-heading">
67
+ <button aria-expanded="false" class="health-check-accordion-trigger" aria-controls="health-check-accordion-block-<?php echo esc_attr( $section ); ?>" type="button">
68
+ <span class="title">
69
+ <?php echo esc_html( $details['label'] ); ?>
70
+ <?php
71
+
72
+ if ( isset( $details['show_count'] ) && $details['show_count'] ) {
73
+ printf( '(%d)', count( $details['fields'] ) );
74
+ }
75
+
76
+ ?>
77
+ </span>
78
+ <?php
79
+
80
+ if ( 'wp-paths-sizes' === $section ) {
81
+ ?>
82
+ <span class="health-check-wp-paths-sizes spinner"></span>
83
+ <?php
84
  }
85
 
86
+ ?>
87
+ <span class="icon"></span>
88
+ </button>
89
+ </h3>
90
+
91
+ <div id="health-check-accordion-block-<?php echo esc_attr( $section ); ?>" class="health-check-accordion-panel" hidden="hidden">
92
+ <?php
93
 
94
+ if ( isset( $details['description'] ) && ! empty( $details['description'] ) ) {
95
+ printf( '<p>%s</p>', $details['description'] );
 
 
96
  }
 
97
 
98
+ ?>
99
+ <table class="widefat striped health-check-table" role="presentation">
100
+ <tbody>
101
+ <?php
102
+
103
+ foreach ( $details['fields'] as $field_name => $field ) {
104
+ if ( is_array( $field['value'] ) ) {
105
+ $values = '<ul>';
106
+
107
+ foreach ( $field['value'] as $name => $value ) {
108
+ $values .= sprintf( '<li>%s: %s</li>', esc_html( $name ), esc_html( $value ) );
109
+ }
110
+
111
+ $values .= '</ul>';
112
+ } else {
113
+ $values = esc_html( $field['value'] );
114
+ }
115
+
116
+ if ( in_array( $field_name, $sizes_fields, true ) ) {
117
+ printf( '<tr><td>%s</td><td class="%s">%s</td></tr>', esc_html( $field['label'] ), esc_attr( $field_name ), $values );
118
+ } else {
119
+ printf( '<tr><td>%s</td><td>%s</td></tr>', esc_html( $field['label'] ), $values );
120
+ }
121
+ }
122
 
123
+ ?>
124
+ </tbody>
125
+ </table>
126
+ </div>
127
+ <?php } ?>
128
+ </div>
 
 
129
  </div>
pages/phpinfo.php CHANGED
@@ -11,6 +11,8 @@ if ( ! defined( 'ABSPATH' ) ) {
11
  }
12
  ?>
13
 
 
 
14
  <h2>
15
  <?php esc_html_e( 'Extended PHP Information', 'health-check' ); ?>
16
  </h2>
@@ -25,15 +27,8 @@ if ( ! function_exists( 'phpinfo' ) ) {
25
  </p>
26
  </div>
27
 
28
- <?php } else { ?>
29
-
30
- <div class="notice notice-warning inline">
31
- <p>
32
- <?php esc_html_e( 'Some scenarios require you to look up more detailed server configurations than what is normally required. This page allows you to view all available configuration options for your PHP setup. Please be advised that WordPress does not guarantee that any information shown on this page may not be considered private.', 'health-check' ); ?>
33
- </p>
34
- </div>
35
-
36
  <?php
 
37
  ob_start();
38
  phpinfo();
39
  $phpinfo_raw = ob_get_clean();
@@ -65,3 +60,5 @@ if ( ! function_exists( 'phpinfo' ) ) {
65
 
66
  <?php
67
  }
 
 
11
  }
12
  ?>
13
 
14
+ <div class="health-check-body">
15
+
16
  <h2>
17
  <?php esc_html_e( 'Extended PHP Information', 'health-check' ); ?>
18
  </h2>
27
  </p>
28
  </div>
29
 
 
 
 
 
 
 
 
 
30
  <?php
31
+ } else {
32
  ob_start();
33
  phpinfo();
34
  $phpinfo_raw = ob_get_clean();
60
 
61
  <?php
62
  }
63
+ ?>
64
+ </div>
pages/site-health-header.php CHANGED
@@ -18,31 +18,27 @@ if ( ! defined( 'ABSPATH' ) ) {
18
  </h1>
19
  </div>
20
 
21
- <div class="health-check-title-section site-health-progress-wrapper loading hide-if-no-js">
22
- <div class="site-health-progress">
23
- <svg role="img" aria-hidden="true" focusable="false" width="100%" height="100%" viewBox="0 0 200 200" version="1.1" xmlns="http://www.w3.org/2000/svg">
24
- <circle r="90" cx="100" cy="100" fill="transparent" stroke-dasharray="565.48" stroke-dashoffset="0"></circle>
25
- <circle id="bar" r="90" cx="100" cy="100" fill="transparent" stroke-dasharray="565.48" stroke-dashoffset="0"></circle>
26
- </svg>
27
- </div>
28
- <div class="site-health-progress-label">
29
- <?php _e( 'Results are still loading&hellip;', 'health-check' ); ?>
30
- </div>
31
- </div>
32
-
33
  <nav class="health-check-tabs-wrapper hide-if-no-js" aria-label="<?php esc_attr_e( 'Secondary menu', 'health-check' ); ?>">
34
  <?php
35
  $tabs = Health_Check::tabs();
36
  $current_tab = Health_Check::current_tab();
37
 
38
  foreach ( $tabs as $tab => $label ) {
 
 
 
 
 
 
 
 
 
 
 
 
39
  printf(
40
  '<a href="%s" class="health-check-tab health-check-%s-tab %s"%s>%s</a>',
41
- sprintf(
42
- '%s&tab=%s',
43
- menu_page_url( 'health-check', false ),
44
- $tab
45
- ),
46
  esc_attr( $tab ),
47
  ( $current_tab === $tab ? 'active' : '' ),
48
  ( $current_tab === $tab ? ' aria-current="true"' : '' ),
18
  </h1>
19
  </div>
20
 
 
 
 
 
 
 
 
 
 
 
 
 
21
  <nav class="health-check-tabs-wrapper hide-if-no-js" aria-label="<?php esc_attr_e( 'Secondary menu', 'health-check' ); ?>">
22
  <?php
23
  $tabs = Health_Check::tabs();
24
  $current_tab = Health_Check::current_tab();
25
 
26
  foreach ( $tabs as $tab => $label ) {
27
+ if ( ! empty( $tab ) ) {
28
+ $url = add_query_arg(
29
+ array(
30
+ 'page' => 'site-health',
31
+ 'tab' => $tab,
32
+ ),
33
+ admin_url( 'tools.php?page=site-health' )
34
+ );
35
+ } else {
36
+ $url = admin_url( 'tools.php?page=site-health' );
37
+ }
38
+
39
  printf(
40
  '<a href="%s" class="health-check-tab health-check-%s-tab %s"%s>%s</a>',
41
+ esc_url( $url ),
 
 
 
 
42
  esc_attr( $tab ),
43
  ( $current_tab === $tab ? 'active' : '' ),
44
  ( $current_tab === $tab ? ' aria-current="true"' : '' ),
pages/site-status.php CHANGED
@@ -9,87 +9,36 @@
9
  if ( ! defined( 'ABSPATH' ) ) {
10
  die( 'We\'re sorry, but you can not directly access this file.' );
11
  }
12
-
13
- global $health_check_site_status;
14
  ?>
15
 
16
- <div class="site-status-all-clear hide">
17
- <p class="icon">
18
- <span class="dashicons dashicons-yes"></span>
19
  </p>
20
 
21
- <p class="encouragement">
22
- <?php _e( 'Great job!', 'health-check' ); ?>
23
- </p>
24
 
25
  <p>
26
- <?php _e( 'Everything is running smoothly here.', 'health-check' ); ?>
 
 
 
 
 
 
27
  </p>
28
- </div>
29
 
30
- <div class="site-status-has-issues">
31
- <h2>
32
- <?php _e( 'Site Health Status', 'health-check' ); ?>
33
- </h2>
34
-
35
- <p><?php _e( 'The site health check shows critical information about your WordPress configuration and items that require your attention.', 'health-check' ); ?></p>
36
-
37
- <div class="site-health-issues-wrapper" id="health-check-issues-critical">
38
- <h3 class="site-health-issue-count-title">
39
- <?php
40
- /* translators: %s: number of critical issues found */
41
- printf( _n( '%s Critical issue', '%s Critical issues', 0, 'health-check' ), '<span class="issue-count">0</span>' );
42
- ?>
43
- </h3>
44
 
45
- <div id="health-check-site-status-critical" class="health-check-accordion issues"></div>
46
- </div>
47
-
48
- <div class="site-health-issues-wrapper" id="health-check-issues-recommended">
49
- <h3 class="site-health-issue-count-title">
50
- <?php
51
- /* translators: %s: number of recommended improvements */
52
- printf( _n( '%s Recommended improvement', '%s Recommended improvements', 0, 'health-check' ), '<span class="issue-count">0</span>' );
53
- ?>
54
- </h3>
55
-
56
- <div id="health-check-site-status-recommended" class="health-check-accordion issues"></div>
57
- </div>
58
- </div>
59
-
60
- <div class="site-health-view-more">
61
- <button type="button" class="button site-health-view-passed" aria-expanded="false" aria-controls="health-check-issues-good">
62
- <?php _e( 'Passed tests', 'health-check' ); ?>
63
- <span class="icon"></span>
64
- </button>
65
- </div>
66
 
67
- <div class="site-health-issues-wrapper hidden" id="health-check-issues-good">
68
- <h3 class="site-health-issue-count-title">
69
- <?php
70
- /* translators: %s: number of items with no issues */
71
- printf( _n( '%s Item with no issues detected', '%s Items with no issues detected', 0, 'health-check' ), '<span class="issue-count">0</span>' );
72
- ?>
73
- </h3>
74
 
75
- <div id="health-check-site-status-good" class="health-check-accordion issues"></div>
 
 
76
  </div>
77
-
78
- <script id="tmpl-health-check-issue" type="text/template">
79
- <h4 class="health-check-accordion-heading">
80
- <button aria-expanded="false" class="health-check-accordion-trigger" aria-controls="health-check-accordion-block-{{ data.test }}" type="button">
81
- <span class="title">{{ data.label }}</span>
82
- <span class="badge {{ data.badge.color }}">{{ data.badge.label }}</span>
83
- <span class="icon"></span>
84
- </button>
85
- </h4>
86
- <div id="health-check-accordion-block-{{ data.test }}" class="health-check-accordion-panel" hidden="hidden">
87
- {{{ data.description }}}
88
- <div class="actions">
89
- <p class="button-container">{{{ data.actions }}}</p>
90
- </div>
91
- </div>
92
- </script>
93
-
94
- <?php
95
- include_once( HEALTH_CHECK_PLUGIN_DIRECTORY . '/modals/js-result-warnings.php' );
9
  if ( ! defined( 'ABSPATH' ) ) {
10
  die( 'We\'re sorry, but you can not directly access this file.' );
11
  }
 
 
12
  ?>
13
 
14
+ <div class="site-status-all-clear">
15
+ <p class="icon wp-logo">
16
+ <span class="dashicons dashicons-wordpress"></span>
17
  </p>
18
 
19
+ <h2 class="encouragement">
20
+ <?php _e( 'WordPress update needed!', 'health-check' ); ?>
21
+ </h2>
22
 
23
  <p>
24
+ <?php
25
+ printf(
26
+ // translators: %s: The current WordPress version used on this site.
27
+ __( 'You are running an older version of WordPress, version %s. The Site Health features from this plugin were added to version 5.2 of WordPress.', 'health-check' ),
28
+ get_bloginfo( 'version' )
29
+ );
30
+ ?>
31
  </p>
 
32
 
33
+ <br>
 
 
 
 
 
 
 
 
 
 
 
 
 
34
 
35
+ <p>
36
+ <?php _e( 'Due to this, some functionality has been removed from the plugin, you can find these features in a more recent version of WordPress it self.', 'health-check' ); ?>
37
+ </p>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
38
 
39
+ <br>
 
 
 
 
 
 
40
 
41
+ <p>
42
+ <?php _e( 'The plugin itself still offers you the ability to troubleshoot issues with your installation, and various tools associated with this functionality.', 'health-check' ); ?>
43
+ </p>
44
  </div>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
pages/tools.php CHANGED
@@ -12,51 +12,52 @@ if ( ! defined( 'ABSPATH' ) ) {
12
 
13
  ?>
14
 
15
- <h2>
16
- <?php esc_html_e( 'Tools', 'health-check' ); ?>
17
- </h2>
18
-
19
- <div id="health-check-tools" role="presentation" class="health-check-accordion">
20
- <?php
21
- /**
22
- * Filter the features available under the Tools tab.
23
- *
24
- * You may introduce your own, or modify the behavior of existing tools here,
25
- * although we recommend not modifying anything provided by the plugin it self.
26
- *
27
- * Any interactive elements should be introduced using JavaScript and/or CSS, either
28
- * inline, or by enqueueing them via the appropriate actions.
29
- *
30
- * @param array $args {
31
- * An unassociated array of tabs, listed in the order they are registered.
32
- *
33
- * @type array $tab {
34
- * An associated array containing the tab title, and content.
35
- *
36
- * @type string $label A pre-escaped string used to label your tool section.
37
- * @type string $content The content of your tool tab, with any code you may need.
38
- * }
39
- * }
40
- */
41
- $tabs = apply_filters( 'health_check_tools_tab', array() );
42
-
43
- foreach ( $tabs as $count => $tab ) :
44
- ?>
45
-
46
- <h3 class="health-check-accordion-heading">
47
- <button aria-expanded="false" class="health-check-accordion-trigger" aria-controls="health-check-accordion-block-<?php echo esc_attr( $count ); ?>" type="button">
48
- <span class="title">
49
- <?php echo $tab['label']; ?>
50
- </span>
51
- <span class="icon"></span>
52
- </button>
53
- </h3>
54
- <div id="health-check-accordion-block-<?php echo esc_attr( $count ); ?>" class="health-check-accordion-panel" hidden="hidden">
55
- <?php echo $tab['content']; ?>
 
 
 
 
56
  </div>
57
 
58
- <?php endforeach; ?>
59
  </div>
60
-
61
- <?php
62
- include_once( HEALTH_CHECK_PLUGIN_DIRECTORY . '/modals/diff.php' );
12
 
13
  ?>
14
 
15
+ <div class="health-check-body">
16
+ <h2>
17
+ <?php esc_html_e( 'Tools', 'health-check' ); ?>
18
+ </h2>
19
+
20
+ <div id="health-check-tools" role="presentation" class="health-check-accordion">
21
+ <?php
22
+ /**
23
+ * Filter the features available under the Tools tab.
24
+ *
25
+ * You may introduce your own, or modify the behavior of existing tools here,
26
+ * although we recommend not modifying anything provided by the plugin it self.
27
+ *
28
+ * Any interactive elements should be introduced using JavaScript and/or CSS, either
29
+ * inline, or by enqueueing them via the appropriate actions.
30
+ *
31
+ * @param array $args {
32
+ * An unassociated array of tabs, listed in the order they are registered.
33
+ *
34
+ * @type array $tab {
35
+ * An associated array containing the tab title, and content.
36
+ *
37
+ * @type string $label A pre-escaped string used to label your tool section.
38
+ * @type string $content The content of your tool tab, with any code you may need.
39
+ * }
40
+ * }
41
+ */
42
+ $tabs = apply_filters( 'health_check_tools_tab', array() );
43
+
44
+ foreach ( $tabs as $count => $tab ) :
45
+ ?>
46
+
47
+ <h3 class="health-check-accordion-heading">
48
+ <button aria-expanded="false" class="health-check-accordion-trigger" aria-controls="health-check-accordion-block-<?php echo esc_attr( $count ); ?>" type="button">
49
+ <span class="title">
50
+ <?php echo $tab['label']; ?>
51
+ </span>
52
+ <span class="icon"></span>
53
+ </button>
54
+ </h3>
55
+ <div id="health-check-accordion-block-<?php echo esc_attr( $count ); ?>" class="health-check-accordion-panel" hidden="hidden">
56
+ <?php echo $tab['content']; ?>
57
+ </div>
58
+
59
+ <?php endforeach; ?>
60
  </div>
61
 
62
+ <?php include_once( HEALTH_CHECK_PLUGIN_DIRECTORY . '/modals/diff.php' ); ?>
63
  </div>
 
 
 
pages/troubleshoot.php CHANGED
@@ -12,26 +12,27 @@ if ( ! defined( 'ABSPATH' ) ) {
12
 
13
  ?>
14
 
15
- <h2>
16
- <?php esc_html_e( 'Troubleshooting mode', 'health-check' ); ?>
17
- </h2>
18
-
19
- <p>
20
- <?php esc_html_e( 'When troubleshooting issues on your site, you are likely to be told to disable all plugins and switch to the default theme.', 'health-check' ); ?>
21
- <?php esc_html_e( 'Understandably, you do not wish to do so as it may affect your site visitors, leaving them with lost functionality.', 'health-check' ); ?>
22
- </p>
23
-
24
- <p>
25
- <?php esc_html_e( 'By enabling the Troubleshooting Mode, all plugins will appear inactive and your site will switch to the default theme only for you. All other users will see your site as usual.', 'health-check' ); ?>
26
- </p>
27
-
28
- <p>
29
- <?php esc_html_e( 'A Troubleshooting Mode menu is added to your admin bar, which will allow you to enable plugins individually, switch back to your current theme, and disable Troubleshooting Mode.', 'health-check' ); ?>
30
- </p>
31
-
32
- <p>
33
- <?php esc_html_e( 'Please note, that due to how Must Use plugins work, any such plugin will not be disabled for the troubleshooting session.', 'health-check' ); ?>
34
- </p>
35
-
36
- <?php
37
- Health_Check_Troubleshoot::show_enable_troubleshoot_form();
 
12
 
13
  ?>
14
 
15
+ <div class="health-check-body">
16
+ <h2>
17
+ <?php esc_html_e( 'Troubleshooting mode', 'health-check' ); ?>
18
+ </h2>
19
+
20
+ <p>
21
+ <?php esc_html_e( 'When troubleshooting issues on your site, you are likely to be told to disable all plugins and switch to the default theme.', 'health-check' ); ?>
22
+ <?php esc_html_e( 'Understandably, you do not wish to do so as it may affect your site visitors, leaving them with lost functionality.', 'health-check' ); ?>
23
+ </p>
24
+
25
+ <p>
26
+ <?php esc_html_e( 'By enabling the Troubleshooting Mode, all plugins will appear inactive and your site will switch to the default theme only for you. All other users will see your site as usual.', 'health-check' ); ?>
27
+ </p>
28
+
29
+ <p>
30
+ <?php esc_html_e( 'A Troubleshooting Mode menu is added to your admin bar, which will allow you to enable plugins individually, switch back to your current theme, and disable Troubleshooting Mode.', 'health-check' ); ?>
31
+ </p>
32
+
33
+ <p>
34
+ <?php esc_html_e( 'Please note, that due to how Must Use plugins work, any such plugin will not be disabled for the troubleshooting session.', 'health-check' ); ?>
35
+ </p>
36
+
37
+ <?php Health_Check_Troubleshoot::show_enable_troubleshoot_form(); ?>
38
+ </div>
readme.txt CHANGED
@@ -1,97 +1,107 @@
1
- === Health Check & Troubleshooting ===
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: 6.0
7
- Stable tag: 1.4.5
8
- License: GPLv2
9
- License URI: https://www.gnu.org/licenses/gpl-2.0.html
10
-
11
- Health Check identifies common problems, and helps you troubleshoot plugin and theme conflicts.
12
-
13
- == Description ==
14
-
15
- This plugin will perform a number of checks on your WordPress installation to detect common configuration errors and known issues, and also allows plugins and themes to add their own checks.
16
-
17
- The debug section, which allows you to gather information about your WordPress and server configuration that you may easily share with support representatives for themes, plugins or on the official WordPress.org support forums.
18
-
19
- Troubleshooting allows you to have a clean WordPress session, where all plugins are disabled, and a default theme is used, but only for your user until you disable it or log out.
20
-
21
- The Tools section allows you to check that WordPress files have not been tampered with, that emails can be sent, and if your plugins are compatible with any PHP version updates in the future.
22
-
23
- For a more extensive example of how to efficiently use the Health Check plugin, check out the [WordPress.org support team handbook page about this plugin](https://make.wordpress.org/support/handbook/appendix/troubleshooting-using-the-health-check/).
24
-
25
- Feedback is welcome both through the [WordPress.org forums](https://wordpress.org/support/plugin/health-check), the [GitHub project page](https://github.com/WordPress/health-check), or on [Slack](https://make.wordpress.org/chat) in either [#forums](https://wordpress.slack.com/messages/forums/) or [#core-site-health](https://wordpress.slack.com/messages/core-site-health/).
26
-
27
- == Frequently Asked Questions ==
28
-
29
- = I am unable to access my site after enabling troubleshooting =
30
-
31
- If you should find your self stuck in Troubleshooting Mode for any reason, you can easily disable it by clearing your cookies.
32
-
33
- Are you unfamiliar with how to clear your cookies? No worries, you may also close all your browser windows, or perform a computer restart and it will clear this specific cookie automatically.
34
-
35
- = The PHP compatibility says this plugin only work with PHP version X? =
36
-
37
- The plugin is made to be a support tool for as many users as possible, this means it needs code that is written for older sites as well.
38
-
39
- Tools that check for PHP compatibility do not know how to separate this code from the real code, so it will give a false positive response.
40
-
41
- At this time, the plugin has been tested with every version of PHP from 5.2 through 7.3, and works with all of these.
42
-
43
- == Screenshots ==
44
-
45
- 1. The health check screen after the automated tests have gone over the system.
46
- 2. The debug information, with the copy and paste field expanded.
47
- 3. A selection of tools that can be ran on your site.
48
- 4. Troubleshooting mode enabled, showing your website Dashboard
49
-
50
- == Changelog ==
51
-
52
- = v1.4.5 =
53
- * Fix Troubleshooting Mode throwing errors in frontend on WordPress 5.5
54
-
55
- = v1.4.4 =
56
- * Fixed hidden JavaScript warning when using troubleshooting mode on the Dashboard
57
- * Fixed plugin and theme lists staying hidden in troubleshooting mode on the Dashboard
58
-
59
- = v1.4.3 =
60
- * Compatibility with WordPress 5.4
61
-
62
- = v1.4.2 =
63
- * Fix missing headers for a loopback request in the debug section
64
-
65
- = v1.4.1 =
66
- * Fixed SQL version checks for various MariaDB installs.
67
- * Fixed a warning being generated in logfiles for first-time users with no existing Site Health history.
68
- * Added missing translation function for the new PHP compatibility tool.
69
-
70
- = v1.4.0 =
71
- * Fix a bug when viewing the Site Health page if enabling the Health Check plugin in troubleshooting mode.
72
- * Fix an inconsistency with how database versions are checked.
73
- * Fix the file comparison view on Windows systems if there are modified core files.
74
- * Fix a bug where some premium plugins could not be enabled in troubleshooting mode
75
- * Improved styles for older browsers.
76
- * Improved the PHP module checks to allow for constant checks as well. Should help with some edge case tests.
77
- * Improved the core file integrity checker.
78
- * Improved testing of WP_cron, now works properly for those running a "real cron" outside of WordPress.
79
- * Improved the htaccess rule test to only run if using an Apache server that supports these.
80
- * Modify the Site Health grading indicator.
81
- * Modified strings to make them clearer.
82
- * Added server headers to the Debug information.
83
- * Added polyfills for core features from WordPress 5.2 so they work for older sites.
84
- * Added a link to the Site Health page from the plugin overview.
85
- * Added a custom capability, `view_site_health_checks` for the plugin.
86
- * Added support for parent/child theme output in the Debug screen.
87
- * Added system user information to the Debug information.
88
- * Added a Site Health test for timezone localization.
89
- * Added `mbstring` and `json` (again) as requirements to the list of PHP extensions.
90
- * Added a missing toggle to the list of plugins/themes to the troubleshooting dashboard widget.
91
- * Added bulk actions to enable or disable plugins when troubleshooting, or to initiate troubleshooting mode.
92
- * Added plugin compatibility checker ot the tools section.
93
- * Added a dashboard widget to show your Site Health status at a glance when logging in.
94
- * Added filters for Site Health test results.
95
- * Added WP-CLI support, you can now run `wp health-check status` for a list of test and their status.
96
- * Moved compatibility functions out of primary files and into a `compat.php` so they can be conditionally loaded.
97
- * Disable the Fatal Error (WSOD) protection in WordPress while in troubleshooting mode.
 
 
 
 
 
 
 
 
 
 
1
+ === Health Check & Troubleshooting ===
2
+ Tags: health check
3
+ Contributors: wordpressdotorg, westi, pento, Clorith
4
+ Requires at least: 4.4
5
+ Requires PHP: 5.6
6
+ Tested up to: 6.0
7
+ Stable tag: 1.5.0
8
+ License: GPLv2
9
+ License URI: https://www.gnu.org/licenses/gpl-2.0.html
10
+
11
+ Health Check identifies common problems, and helps you troubleshoot plugin and theme conflicts.
12
+
13
+ == Description ==
14
+
15
+ This plugin will perform a number of checks on your WordPress installation to detect common configuration errors and known issues, and also allows plugins and themes to add their own checks.
16
+
17
+ The debug section, which allows you to gather information about your WordPress and server configuration that you may easily share with support representatives for themes, plugins or on the official WordPress.org support forums.
18
+
19
+ Troubleshooting allows you to have a clean WordPress session, where all plugins are disabled, and a default theme is used, but only for your user until you disable it or log out.
20
+
21
+ The Tools section allows you to check that WordPress files have not been tampered with, that emails can be sent, and if your plugins are compatible with any PHP version updates in the future.
22
+
23
+ For a more extensive example of how to efficiently use the Health Check plugin, check out the [WordPress.org support team handbook page about this plugin](https://make.wordpress.org/support/handbook/appendix/troubleshooting-using-the-health-check/).
24
+
25
+ Feedback is welcome both through the [WordPress.org forums](https://wordpress.org/support/plugin/health-check), the [GitHub project page](https://github.com/WordPress/health-check), or on [Slack](https://make.wordpress.org/chat) in either [#forums](https://wordpress.slack.com/messages/forums/) or [#core-site-health](https://wordpress.slack.com/messages/core-site-health/).
26
+
27
+ == Frequently Asked Questions ==
28
+
29
+ = I am unable to access my site after enabling troubleshooting =
30
+
31
+ If you should find your self stuck in Troubleshooting Mode for any reason, you can easily disable it by clearing your cookies.
32
+
33
+ Are you unfamiliar with how to clear your cookies? No worries, you may also close all your browser windows, or perform a computer restart and it will clear this specific cookie automatically.
34
+
35
+ = The PHP compatibility says this plugin only work with PHP version X? =
36
+
37
+ The plugin is made to be a support tool for as many users as possible, this means it needs code that is written for older sites as well.
38
+
39
+ Tools that check for PHP compatibility do not know how to separate this code from the real code, so it will give a false positive response.
40
+
41
+ At this time, the plugin has been tested with every version of PHP from 5.2 through 7.3, and works with all of these.
42
+
43
+ == Screenshots ==
44
+
45
+ 1. The health check screen after the automated tests have gone over the system.
46
+ 2. The debug information, with the copy and paste field expanded.
47
+ 3. A selection of tools that can be ran on your site.
48
+ 4. Troubleshooting mode enabled, showing your website Dashboard
49
+
50
+ == Changelog ==
51
+
52
+ = v1.5.0 (2022-09-10) =
53
+ * Added a custom filter for the Health Check plugin PHP Compatibility check.
54
+ * Added functions which will try to disable cache solutions during troubleshooting.
55
+ * Added ability to force changes if loopbacks fail during troubleshooting.
56
+ * Changed how JavaScript is built and bundled in the plugin.
57
+ * Changed the location of the `phpinfo()` check to the Tools section.
58
+ * Changed how troubleshooting mode implements its conditional actions and filters when enabled.
59
+ * Fixed styling issues for troubleshooting mode in WordPress 5.9.
60
+ * Removed Site Health Status from the plugin, as they were implemented in WordPress 5.2.
61
+
62
+ = v1.4.5 =
63
+ * Fix Troubleshooting Mode throwing errors in frontend on WordPress 5.5
64
+
65
+ = v1.4.4 =
66
+ * Fixed hidden JavaScript warning when using troubleshooting mode on the Dashboard
67
+ * Fixed plugin and theme lists staying hidden in troubleshooting mode on the Dashboard
68
+
69
+ = v1.4.3 =
70
+ * Compatibility with WordPress 5.4
71
+
72
+ = v1.4.2 =
73
+ * Fix missing headers for a loopback request in the debug section
74
+
75
+ = v1.4.1 =
76
+ * Fixed SQL version checks for various MariaDB installs.
77
+ * Fixed a warning being generated in logfiles for first-time users with no existing Site Health history.
78
+ * Added missing translation function for the new PHP compatibility tool.
79
+
80
+ = v1.4.0 =
81
+ * Fix a bug when viewing the Site Health page if enabling the Health Check plugin in troubleshooting mode.
82
+ * Fix an inconsistency with how database versions are checked.
83
+ * Fix the file comparison view on Windows systems if there are modified core files.
84
+ * Fix a bug where some premium plugins could not be enabled in troubleshooting mode
85
+ * Improved styles for older browsers.
86
+ * Improved the PHP module checks to allow for constant checks as well. Should help with some edge case tests.
87
+ * Improved the core file integrity checker.
88
+ * Improved testing of WP_cron, now works properly for those running a "real cron" outside of WordPress.
89
+ * Improved the htaccess rule test to only run if using an Apache server that supports these.
90
+ * Modify the Site Health grading indicator.
91
+ * Modified strings to make them clearer.
92
+ * Added server headers to the Debug information.
93
+ * Added polyfills for core features from WordPress 5.2 so they work for older sites.
94
+ * Added a link to the Site Health page from the plugin overview.
95
+ * Added a custom capability, `view_site_health_checks` for the plugin.
96
+ * Added support for parent/child theme output in the Debug screen.
97
+ * Added system user information to the Debug information.
98
+ * Added a Site Health test for timezone localization.
99
+ * Added `mbstring` and `json` (again) as requirements to the list of PHP extensions.
100
+ * Added a missing toggle to the list of plugins/themes to the troubleshooting dashboard widget.
101
+ * Added bulk actions to enable or disable plugins when troubleshooting, or to initiate troubleshooting mode.
102
+ * Added plugin compatibility checker ot the tools section.
103
+ * Added a dashboard widget to show your Site Health status at a glance when logging in.
104
+ * Added filters for Site Health test results.
105
+ * Added WP-CLI support, you can now run `wp health-check status` for a list of test and their status.
106
+ * Moved compatibility functions out of primary files and into a `compat.php` so they can be conditionally loaded.
107
+ * Disable the Fatal Error (WSOD) protection in WordPress while in troubleshooting mode.
uninstall.php CHANGED
@@ -30,7 +30,7 @@ $wpdb->delete(
30
  );
31
 
32
  // Remove any transients and similar which the plugin may have left behind.
33
- $wpdb->query( "DELETE FROM {$wpdb->options} WHERE `option_name` LIKE '_transient_%_health-check%'" );
34
 
35
  // Remove the old Must-Use plugin if it was implemented.
36
  if ( file_exists( trailingslashit( WPMU_PLUGIN_DIR ) . 'health-check-disable-plugins.php' ) ) {
30
  );
31
 
32
  // Remove any transients and similar which the plugin may have left behind.
33
+ $wpdb->query( "DELETE FROM {$wpdb->options} WHERE `option_name` LIKE '_transient_health-check%'" );
34
 
35
  // Remove the old Must-Use plugin if it was implemented.
36
  if ( file_exists( trailingslashit( WPMU_PLUGIN_DIR ) . 'health-check-disable-plugins.php' ) ) {