Health Check - Version 1.2.1

Version Description

Download this release

Release Info

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

Code changes from version 1.2.0 to 1.2.1

health-check.php CHANGED
@@ -4,11 +4,12 @@
4
  *
5
  * @package Health Check
6
  *
 
7
  * Plugin Name: Health Check & Troubleshooting
8
  * Plugin URI: http://wordpress.org/plugins/health-check/
9
  * Description: Checks the health of your WordPress install.
10
  * Author: The WordPress.org community
11
- * Version: 1.2.0
12
  * Author URI: http://wordpress.org/plugins/health-check/
13
  * Text Domain: health-check
14
  */
@@ -34,7 +35,7 @@ define( 'HEALTH_CHECK_MYSQL_MIN_VERSION', '5.0' );
34
  define( 'HEALTH_CHECK_MYSQL_REC_VERSION', '5.6' );
35
 
36
  // Set the plugin version.
37
- define( 'HEALTH_CHECK_PLUGIN_VERSION', '1.2.0' );
38
 
39
  // Set the absolute path for the plugin.
40
  define( 'HEALTH_CHECK_PLUGIN_DIRECTORY', plugin_dir_path( __FILE__ ) );
4
  *
5
  * @package Health Check
6
  *
7
+ * @wordpress-plugin
8
  * Plugin Name: Health Check & Troubleshooting
9
  * Plugin URI: http://wordpress.org/plugins/health-check/
10
  * Description: Checks the health of your WordPress install.
11
  * Author: The WordPress.org community
12
+ * Version: 1.2.1
13
  * Author URI: http://wordpress.org/plugins/health-check/
14
  * Text Domain: health-check
15
  */
35
  define( 'HEALTH_CHECK_MYSQL_REC_VERSION', '5.6' );
36
 
37
  // Set the plugin version.
38
+ define( 'HEALTH_CHECK_PLUGIN_VERSION', '1.2.1' );
39
 
40
  // Set the absolute path for the plugin.
41
  define( 'HEALTH_CHECK_PLUGIN_DIRECTORY', plugin_dir_path( __FILE__ ) );
includes/class-health-check-debug-data.php CHANGED
@@ -47,6 +47,7 @@ class Health_Check_Debug_Data {
47
 
48
  $core_current_version = get_bloginfo( 'version' );
49
  $core_updates = get_core_updates();
 
50
 
51
  foreach ( $core_updates as $core => $update ) {
52
  if ( 'upgrade' === $update->response ) {
47
 
48
  $core_current_version = get_bloginfo( 'version' );
49
  $core_updates = get_core_updates();
50
+ $core_update_needed = '';
51
 
52
  foreach ( $core_updates as $core => $update ) {
53
  if ( 'upgrade' === $update->response ) {
includes/class-health-check-site-status.php CHANGED
@@ -134,6 +134,36 @@ class Health_Check_Site_Status {
134
  }
135
  }
136
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
137
  public function test_plugin_version() {
138
  $plugins = get_plugins();
139
  $plugin_updates = get_plugin_updates();
@@ -144,12 +174,8 @@ class Health_Check_Site_Status {
144
  $plugins_total = 0;
145
  $plugins_needs_update = 0;
146
 
147
- if ( class_exists( 'Health_Check_Troubleshooting_MU' ) ) {
148
- $troubleshooting = new Health_Check_Troubleshooting_MU();
149
-
150
- if ( $troubleshooting->is_troubleshooting() ) {
151
- $show_unused_plugins = false;
152
- }
153
  }
154
 
155
  foreach ( $plugins as $plugin_path => $plugin ) {
@@ -233,12 +259,8 @@ class Health_Check_Site_Status {
233
  $has_unused_themes = false;
234
  $show_unused_themes = true;
235
 
236
- if ( class_exists( 'Health_Check_Troubleshooting_MU' ) ) {
237
- $troubleshooting = new Health_Check_Troubleshooting_MU();
238
-
239
- if ( $troubleshooting->is_troubleshooting() ) {
240
- $show_unused_themes = false;
241
- }
242
  }
243
 
244
  // Populate a list of all themes available in the install.
@@ -314,7 +336,7 @@ class Health_Check_Site_Status {
314
  // translators: %1$d: The amount of inactive themes. %2$s: The default theme for WordPress. %3$s: The currently active theme. %4$s: The active themes parent theme.
315
  esc_html( _n(
316
  'Your site has %1$d inactive theme. To enhance your sites security it is recommended to remove any unused themes. You should keep %2$s, the default WordPress theme, %3$s, your current theme and %4$s, the parent theme.',
317
- 'Your site has %1$d inactive themes. To enhance your sites security it is recommended to remove any unused themes. You should keep %2$s, the default WordPress theme, %3$s, your current theme and %4$s, the parent theme. ',
318
  $themes_inactive,
319
  'health-check'
320
  ) ),
134
  }
135
  }
136
 
137
+ /**
138
+ * Check if the user is currently in Troubleshooting Mode or not.
139
+ *
140
+ * @return bool
141
+ */
142
+ public function is_troubleshooting() {
143
+ // Check if a session cookie to disable plugins has been set.
144
+ if ( isset( $_COOKIE['health-check-disable-plugins'] ) ) {
145
+ $_GET['health-check-disable-plugin-hash'] = $_COOKIE['health-check-disable-plugins'];
146
+ }
147
+
148
+ // If the disable hash isn't set, no need to interact with things.
149
+ if ( ! isset( $_GET['health-check-disable-plugin-hash'] ) ) {
150
+ return false;
151
+ }
152
+
153
+ $disable_hash = get_option( 'health-check-disable-plugin-hash', null );
154
+
155
+ if ( empty( $disable_hash ) ) {
156
+ return false;
157
+ }
158
+
159
+ // If the plugin hash is not valid, we also break out
160
+ if ( $disable_hash !== $_GET['health-check-disable-plugin-hash'] ) {
161
+ return false;
162
+ }
163
+
164
+ return true;
165
+ }
166
+
167
  public function test_plugin_version() {
168
  $plugins = get_plugins();
169
  $plugin_updates = get_plugin_updates();
174
  $plugins_total = 0;
175
  $plugins_needs_update = 0;
176
 
177
+ if ( $this->is_troubleshooting() ) {
178
+ $show_unused_plugins = false;
 
 
 
 
179
  }
180
 
181
  foreach ( $plugins as $plugin_path => $plugin ) {
259
  $has_unused_themes = false;
260
  $show_unused_themes = true;
261
 
262
+ if ( $this->is_troubleshooting() ) {
263
+ $show_unused_themes = false;
 
 
 
 
264
  }
265
 
266
  // Populate a list of all themes available in the install.
336
  // translators: %1$d: The amount of inactive themes. %2$s: The default theme for WordPress. %3$s: The currently active theme. %4$s: The active themes parent theme.
337
  esc_html( _n(
338
  'Your site has %1$d inactive theme. To enhance your sites security it is recommended to remove any unused themes. You should keep %2$s, the default WordPress theme, %3$s, your current theme and %4$s, the parent theme.',
339
+ 'Your site has %1$d inactive themes. To enhance your sites security it is recommended to remove any unused themes. You should keep %2$s, the default WordPress theme, %3$s, your current theme and %4$s, the parent theme.',
340
  $themes_inactive,
341
  'health-check'
342
  ) ),
includes/class-health-check-troubleshoot.php CHANGED
@@ -68,6 +68,23 @@ class Health_Check_Troubleshoot {
68
  * @return bool
69
  */
70
  static function has_seen_warning() {
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
71
  $meta = get_user_meta( get_current_user_id(), 'health-check', true );
72
  if ( empty( $meta ) ) {
73
  return false;
@@ -275,7 +292,7 @@ class Health_Check_Troubleshoot {
275
  $troubleshooting = new Health_Check_Troubleshooting_MU();
276
  }
277
 
278
- if ( null !== $troubleshooting && $troubleshooting->is_troubleshooting() ) :
279
  ?>
280
  <p style="text-align: center;">
281
  <a class="button button-primary" href="<?php echo esc_url( add_query_arg( array( 'health-check-disable-troubleshooting' => true ) ) ); ?>">
68
  * @return bool
69
  */
70
  static function has_seen_warning() {
71
+ /**
72
+ * Filter who may see the backup warning from the plugin.
73
+ *
74
+ * The plugin displays a warning reminding users to keep backups when active.
75
+ * This filter allows anyone to declare what capability is needed to view the warning, it is set to
76
+ * the `manage_options` capability by default. This means the feature is available to any site admin,
77
+ * even in a multisite environment.
78
+ *
79
+ * @param string $capability Default manage_options. The capability required to see the warning.
80
+ */
81
+ $capability_to_see = apply_filters( 'health_check_backup_warning_required_capability', 'manage_options' );
82
+
83
+ // If the current user lacks the capabilities to use the plugin, pretend they've seen the warning so it isn't displayed.
84
+ if ( ! current_user_can( $capability_to_see ) ) {
85
+ return true;
86
+ }
87
+
88
  $meta = get_user_meta( get_current_user_id(), 'health-check', true );
89
  if ( empty( $meta ) ) {
90
  return false;
292
  $troubleshooting = new Health_Check_Troubleshooting_MU();
293
  }
294
 
295
+ if ( null !== $troubleshooting && is_callable( array( $troubleshooting, 'is_troubleshooting' ) ) && $troubleshooting->is_troubleshooting() ) :
296
  ?>
297
  <p style="text-align: center;">
298
  <a class="button button-primary" href="<?php echo esc_url( add_query_arg( array( 'health-check-disable-troubleshooting' => true ) ) ); ?>">
readme.txt CHANGED
@@ -3,7 +3,7 @@ Tags: health check
3
  Contributors: wordpressdotorg, westi, pento, Clorith
4
  Requires at least: 4.0
5
  Tested up to: 4.9
6
- Stable tag: 1.2.0
7
  License: GPLv2
8
  License URI: https://www.gnu.org/licenses/gpl-2.0.html
9
 
@@ -37,6 +37,11 @@ Are you unfamiliar with how to clear your cookies? No worries, you may also clos
37
 
38
  == Changelog ==
39
 
 
 
 
 
 
40
  = v 1.2.0 =
41
  * Changed plugin name, it now better describes the plugins two primary purposes.
42
  * Changed the `Health Check` tab, it's now named `Site Status`, as we used the old name too many places and it was confusing.
3
  Contributors: wordpressdotorg, westi, pento, Clorith
4
  Requires at least: 4.0
5
  Tested up to: 4.9
6
+ Stable tag: 1.2.1
7
  License: GPLv2
8
  License URI: https://www.gnu.org/licenses/gpl-2.0.html
9
 
37
 
38
  == Changelog ==
39
 
40
+ = v 1.2.1 =
41
+ * Make sure only those with access to the plugin see the backup encouragement notice.
42
+ * Make sure the `is_troubleshooting()` checks are available to the Site Status tester when the MU plugin may not have updated yet.
43
+ * Avoid a warning of an undefined variable if you have the latest WordPress version installed.
44
+
45
  = v 1.2.0 =
46
  * Changed plugin name, it now better describes the plugins two primary purposes.
47
  * Changed the `Health Check` tab, it's now named `Site Status`, as we used the old name too many places and it was confusing.