Version Description
Download this release
Release Info
Developer | Clorith |
Plugin | Health Check |
Version | 1.1.1 |
Comparing to | |
See all releases |
Code changes from version 1.1.0 to 1.1.1
assets/mu-plugin/health-check-disable-plugins.php
DELETED
@@ -1,598 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
/*
|
3 |
-
Plugin Name: Health Check Disable Plugins
|
4 |
-
Description: Conditionally disabled plugins on your site for a given session, used to rule out plugin interactions during troubleshooting.
|
5 |
-
Version: 1.3
|
6 |
-
*/
|
7 |
-
|
8 |
-
if ( ! defined( 'ABSPATH' ) ) {
|
9 |
-
die( 'We\'re sorry, but you can not directly access this file.' );
|
10 |
-
}
|
11 |
-
|
12 |
-
class Health_Check_Troubleshooting_MU {
|
13 |
-
private $override_active = true;
|
14 |
-
private $default_theme = true;
|
15 |
-
private $active_plugins = array();
|
16 |
-
|
17 |
-
private $available_query_args = array(
|
18 |
-
'health-check-disable-plugins',
|
19 |
-
'health-check-disable-plugins-hash',
|
20 |
-
'health-check-disable-troubleshooting',
|
21 |
-
'health-check-toggle-default-theme',
|
22 |
-
'health-check-troubleshoot-enable-plugin',
|
23 |
-
'health-check-troubleshoot-disable-plugin',
|
24 |
-
);
|
25 |
-
|
26 |
-
private $default_themes = array(
|
27 |
-
'twentyseventeen',
|
28 |
-
'twentysixteen',
|
29 |
-
'twentyfifteen',
|
30 |
-
'twentyfourteen',
|
31 |
-
'twentythirteen',
|
32 |
-
'twentytwelve',
|
33 |
-
'twentyeleven',
|
34 |
-
'twentyten',
|
35 |
-
);
|
36 |
-
|
37 |
-
/**
|
38 |
-
* Health_Check_Troubleshooting_MU constructor.
|
39 |
-
*/
|
40 |
-
public function __construct() {
|
41 |
-
$this->init();
|
42 |
-
}
|
43 |
-
|
44 |
-
/**
|
45 |
-
* Actually initiation of the plugin.
|
46 |
-
*
|
47 |
-
* @return void
|
48 |
-
*/
|
49 |
-
public function init() {
|
50 |
-
add_action( 'admin_bar_menu', array( $this, 'health_check_troubleshoot_menu_bar' ), 999 );
|
51 |
-
|
52 |
-
add_filter( 'option_active_plugins', array( $this, 'health_check_loopback_test_disable_plugins' ) );
|
53 |
-
add_filter( 'option_active_sitewide_plugins', array( $this, 'health_check_loopback_test_disable_plugins' ) );
|
54 |
-
|
55 |
-
add_filter( 'stylesheet', array( $this, 'health_check_troubleshoot_theme' ) );
|
56 |
-
add_filter( 'template', array( $this, 'health_check_troubleshoot_theme' ) );
|
57 |
-
|
58 |
-
add_action( 'admin_notices', array( $this, 'plugin_list_admin_notice' ) );
|
59 |
-
add_action( 'admin_notices', array( $this, 'prompt_install_default_theme' ) );
|
60 |
-
add_filter( 'user_has_cap', array( $this, 'remove_plugin_theme_install' ) );
|
61 |
-
|
62 |
-
add_action( 'plugin_action_links', array( $this, 'plugin_actions' ), 50, 4 );
|
63 |
-
|
64 |
-
add_action( 'wp_logout', array( $this, 'health_check_troubleshooter_mode_logout' ) );
|
65 |
-
add_action( 'init', array( $this, 'health_check_troubleshoot_get_captures' ) );
|
66 |
-
|
67 |
-
/*
|
68 |
-
* Plugin activations can be forced by other tools in things like themes, so let's
|
69 |
-
* attempt to work around that by forcing plugin lists back and forth.
|
70 |
-
*
|
71 |
-
* This is not an ideal scenario, but one we must accept as reality.
|
72 |
-
*/
|
73 |
-
add_action( 'activated_plugin', array( $this, 'plugin_activated' ) );
|
74 |
-
|
75 |
-
$this->default_theme = ( 'yes' === get_option( 'health-check-default-theme', 'yes' ) ? true : false );
|
76 |
-
$this->active_plugins = $this->get_unfiltered_plugin_list();
|
77 |
-
}
|
78 |
-
|
79 |
-
/**
|
80 |
-
* Add a prompt to install a default theme.
|
81 |
-
*
|
82 |
-
* If no default theme exists, we can't reliably assert if an issue is
|
83 |
-
* caused by the theme. In these cases we should provide an easy step
|
84 |
-
* to get to, and install, one of the default themes.
|
85 |
-
*
|
86 |
-
* @return void
|
87 |
-
*/
|
88 |
-
public function prompt_install_default_theme() {
|
89 |
-
if ( ! $this->is_troubleshooting() || $this->has_default_theme() ) {
|
90 |
-
return;
|
91 |
-
}
|
92 |
-
|
93 |
-
printf(
|
94 |
-
'<div class="notice notice-warning dismissable"><p>%s</p><p><a href="%s" class="button button-primary">%s</a></p></div>',
|
95 |
-
esc_html__( 'You don\'t have any of the default themes installed. A default theme helps you determine if your current theme is causing conflicts.', 'health-check' ),
|
96 |
-
esc_url( admin_url( sprintf(
|
97 |
-
'theme-install.php?theme=%s',
|
98 |
-
$this->default_themes[0]
|
99 |
-
) ) ),
|
100 |
-
esc_html__( 'Install a default theme', 'health-check' )
|
101 |
-
);
|
102 |
-
}
|
103 |
-
|
104 |
-
/**
|
105 |
-
* Remove the `Add` option for plugins and themes.
|
106 |
-
*
|
107 |
-
* When troubleshooting, adding or changing themes and plugins can
|
108 |
-
* lead to unexpected results. Remove these menu items to make it less
|
109 |
-
* likely that a user breaks their site through these.
|
110 |
-
*
|
111 |
-
* @param array $caps Array containing the current users capabilities.
|
112 |
-
*
|
113 |
-
* @return array
|
114 |
-
*/
|
115 |
-
public function remove_plugin_theme_install( $caps ) {
|
116 |
-
if ( ! $this->is_troubleshooting() ) {
|
117 |
-
return $caps;
|
118 |
-
}
|
119 |
-
|
120 |
-
$caps['switch_themes'] = false;
|
121 |
-
|
122 |
-
/*
|
123 |
-
* This is to early for `get_current_screen()`, so we have to do it the
|
124 |
-
* old fashioned way with `$_SERVER`.
|
125 |
-
*/
|
126 |
-
if ( 'plugin-install.php' === substr( $_SERVER['REQUEST_URI'], -18 ) ) {
|
127 |
-
$caps['activate_plugins'] = false;
|
128 |
-
}
|
129 |
-
|
130 |
-
return $caps;
|
131 |
-
}
|
132 |
-
|
133 |
-
/**
|
134 |
-
* Fire on plugin activation.
|
135 |
-
*
|
136 |
-
* When in Troubleshooting Mode, plugin activations
|
137 |
-
* will clear out the DB entry for `active_plugins`, this is bad.
|
138 |
-
*
|
139 |
-
* We fix this by re-setting the DB entry if anything tries
|
140 |
-
* to modify it during troubleshooting.
|
141 |
-
*
|
142 |
-
* @return void
|
143 |
-
*/
|
144 |
-
public function plugin_activated() {
|
145 |
-
if ( ! $this->is_troubleshooting() ) {
|
146 |
-
return;
|
147 |
-
}
|
148 |
-
|
149 |
-
// Force the database entry for active plugins if someone tried changing plugins while in Troubleshooting Mode.
|
150 |
-
update_option( 'active_plugins', $this->active_plugins );
|
151 |
-
}
|
152 |
-
|
153 |
-
/**
|
154 |
-
* Add a notice to the plugins screen.
|
155 |
-
*
|
156 |
-
* Make sure users are informed that all plugin actions are
|
157 |
-
* stripped away when they are troubleshooting.
|
158 |
-
*
|
159 |
-
* @return void
|
160 |
-
*/
|
161 |
-
public function plugin_list_admin_notice() {
|
162 |
-
if ( ! $this->is_troubleshooting() ) {
|
163 |
-
return;
|
164 |
-
}
|
165 |
-
global $current_screen;
|
166 |
-
|
167 |
-
// Only output our notice on the plugins screen.
|
168 |
-
if ( 'plugins' !== $current_screen->base ) {
|
169 |
-
return;
|
170 |
-
}
|
171 |
-
|
172 |
-
printf(
|
173 |
-
'<div class="notice notice-warning"><p>%s</p></div>',
|
174 |
-
esc_html__( 'Plugin actions are not available while in Troubleshooting Mode.', 'health-check' )
|
175 |
-
);
|
176 |
-
}
|
177 |
-
|
178 |
-
/**
|
179 |
-
* Modify plugin actions.
|
180 |
-
*
|
181 |
-
* While in Troubleshooting Mode, weird things will happen if you start
|
182 |
-
* modifying your plugin list. Prevent this, but also add in the ability
|
183 |
-
* to enable or disable a plugin during troubleshooting from this screen.
|
184 |
-
*
|
185 |
-
* @param $actions
|
186 |
-
* @param $plugin_file
|
187 |
-
* @param $plugin_data
|
188 |
-
* @param $context
|
189 |
-
*
|
190 |
-
* @return array
|
191 |
-
*/
|
192 |
-
public function plugin_actions( $actions, $plugin_file, $plugin_data, $context ) {
|
193 |
-
if ( ! $this->is_troubleshooting() ) {
|
194 |
-
return $actions;
|
195 |
-
}
|
196 |
-
|
197 |
-
if ( 'mustuse' === $context ) {
|
198 |
-
return $actions;
|
199 |
-
}
|
200 |
-
|
201 |
-
/*
|
202 |
-
* Disable all plugin actions when in Troubleshooting Mode.
|
203 |
-
*
|
204 |
-
* We intentionally remove all plugin actions to avoid accidental clicking, activating or deactivating plugins
|
205 |
-
* while our plugin is altering plugin data may lead to unexpected behaviors, so to keep things sane we do
|
206 |
-
* not allow users to perform any actions during this time.
|
207 |
-
*/
|
208 |
-
$actions = array();
|
209 |
-
|
210 |
-
// This isn't an active plugin, so does not apply to our troubleshooting scenarios.
|
211 |
-
if ( ! in_array( $plugin_file, $this->active_plugins ) ) {
|
212 |
-
return $actions;
|
213 |
-
}
|
214 |
-
|
215 |
-
// Set a slug if the plugin lives in the plugins directory root.
|
216 |
-
if ( ! stristr( $plugin_file, '/' ) ) {
|
217 |
-
$plugin_data['slug'] = $plugin_file;
|
218 |
-
}
|
219 |
-
|
220 |
-
$allowed_plugins = get_option( 'health-check-allowed-plugins', array() );
|
221 |
-
|
222 |
-
$plugin_slug = ( isset( $plugin_data['slug'] ) ? $plugin_data['slug'] : sanitize_title( $plugin_data['Name'] ) );
|
223 |
-
|
224 |
-
if ( in_array( $plugin_slug, $allowed_plugins ) ) {
|
225 |
-
$actions['troubleshoot-disable'] = sprintf(
|
226 |
-
'<a href="%s">%s</a>',
|
227 |
-
esc_url( add_query_arg( array(
|
228 |
-
'health-check-troubleshoot-disable-plugin' => $plugin_slug,
|
229 |
-
), admin_url( 'plugins.php' ) ) ),
|
230 |
-
esc_html__( 'Disable while troubleshooting', 'health-check' )
|
231 |
-
);
|
232 |
-
} else {
|
233 |
-
$actions['troubleshoot-disable'] = sprintf(
|
234 |
-
'<a href="%s">%s</a>',
|
235 |
-
esc_url( add_query_arg( array(
|
236 |
-
'health-check-troubleshoot-enable-plugin' => $plugin_slug,
|
237 |
-
), admin_url( 'plugins.php' ) ) ),
|
238 |
-
esc_html__( 'Enable while troubleshooting', 'health-check' )
|
239 |
-
);
|
240 |
-
}
|
241 |
-
|
242 |
-
return $actions;
|
243 |
-
}
|
244 |
-
|
245 |
-
/**
|
246 |
-
* Get the actual list of active plugins.
|
247 |
-
*
|
248 |
-
* When in Troubleshooting Mode we override the list of plugins,
|
249 |
-
* this function lets us grab the active plugins list without
|
250 |
-
* any interference.
|
251 |
-
*
|
252 |
-
* @return array Array of active plugins.
|
253 |
-
*/
|
254 |
-
private function get_unfiltered_plugin_list() {
|
255 |
-
$this->override_active = false;
|
256 |
-
$all_plugins = get_option( 'active_plugins' );
|
257 |
-
$this->override_active = true;
|
258 |
-
|
259 |
-
return $all_plugins;
|
260 |
-
}
|
261 |
-
|
262 |
-
/**
|
263 |
-
* Check if the user is currently in Troubleshooting Mode or not.
|
264 |
-
*
|
265 |
-
* @return bool
|
266 |
-
*/
|
267 |
-
private function is_troubleshooting() {
|
268 |
-
// Check if a session cookie to disable plugins has been set.
|
269 |
-
if ( isset( $_COOKIE['health-check-disable-plugins'] ) ) {
|
270 |
-
$_GET['health-check-disable-plugin-hash'] = $_COOKIE['health-check-disable-plugins'];
|
271 |
-
}
|
272 |
-
|
273 |
-
// If the disable hash isn't set, no need to interact with things.
|
274 |
-
if ( ! isset( $_GET['health-check-disable-plugin-hash'] ) ) {
|
275 |
-
return false;
|
276 |
-
}
|
277 |
-
|
278 |
-
// If the plugin hash is not valid, we also break out
|
279 |
-
$disable_hash = get_option( 'health-check-disable-plugin-hash', '' );
|
280 |
-
if ( $disable_hash !== $_GET['health-check-disable-plugin-hash'] ) {
|
281 |
-
return false;
|
282 |
-
}
|
283 |
-
|
284 |
-
return true;
|
285 |
-
}
|
286 |
-
|
287 |
-
/**
|
288 |
-
* Filter the plugins that are activated in WordPress.
|
289 |
-
*
|
290 |
-
* @param array $plugins An array of plugins marked as active.
|
291 |
-
*
|
292 |
-
* @return array
|
293 |
-
*/
|
294 |
-
function health_check_loopback_test_disable_plugins( $plugins ) {
|
295 |
-
if ( ! $this->is_troubleshooting() || ! $this->override_active ) {
|
296 |
-
return $plugins;
|
297 |
-
}
|
298 |
-
|
299 |
-
$allowed_plugins = get_option( 'health-check-allowed-plugins', array() );
|
300 |
-
|
301 |
-
// If we've received a comma-separated list of allowed plugins, we'll add them to the array of allowed plugins.
|
302 |
-
if ( isset( $_GET['health-check-allowed-plugins'] ) ) {
|
303 |
-
$allowed_plugins = explode( ',', $_GET['health-check-allowed-plugins'] );
|
304 |
-
}
|
305 |
-
|
306 |
-
foreach ( $plugins as $plugin_no => $plugin_path ) {
|
307 |
-
// Split up the plugin path, [0] is the slug and [1] holds the primary plugin file.
|
308 |
-
$plugin_parts = explode( '/', $plugin_path );
|
309 |
-
|
310 |
-
// We may want to allow individual, or groups of plugins, so introduce a skip-mechanic for those scenarios.
|
311 |
-
if ( in_array( $plugin_parts[0], $allowed_plugins ) ) {
|
312 |
-
continue;
|
313 |
-
}
|
314 |
-
|
315 |
-
// Remove the reference to this plugin.
|
316 |
-
unset( $plugins[ $plugin_no ] );
|
317 |
-
}
|
318 |
-
|
319 |
-
// Return a possibly modified list of activated plugins.
|
320 |
-
return $plugins;
|
321 |
-
}
|
322 |
-
|
323 |
-
/**
|
324 |
-
* Check if a default theme exists.
|
325 |
-
*
|
326 |
-
* If a default theme exists, return the most recent one, if not return `false`.
|
327 |
-
*
|
328 |
-
* @return bool|string
|
329 |
-
*/
|
330 |
-
function has_default_theme() {
|
331 |
-
foreach ( $this->default_themes as $default_theme ) {
|
332 |
-
if ( $this->theme_exists( $default_theme ) ) {
|
333 |
-
return $default_theme;
|
334 |
-
}
|
335 |
-
}
|
336 |
-
|
337 |
-
return false;
|
338 |
-
}
|
339 |
-
|
340 |
-
/**
|
341 |
-
* Check if a theme exists by looking for the slug.
|
342 |
-
*
|
343 |
-
* @param string $theme_slug
|
344 |
-
*
|
345 |
-
* @return bool
|
346 |
-
*/
|
347 |
-
function theme_exists( $theme_slug ) {
|
348 |
-
return is_dir( WP_CONTENT_DIR . '/themes/' . $theme_slug );
|
349 |
-
}
|
350 |
-
|
351 |
-
/**
|
352 |
-
* Check if theme overrides are active.
|
353 |
-
*
|
354 |
-
* @return bool
|
355 |
-
*/
|
356 |
-
function override_theme() {
|
357 |
-
if ( ! $this->is_troubleshooting() ) {
|
358 |
-
return false;
|
359 |
-
}
|
360 |
-
|
361 |
-
if ( ! $this->override_active ) {
|
362 |
-
return false;
|
363 |
-
}
|
364 |
-
|
365 |
-
if ( ! $this->default_theme ) {
|
366 |
-
return false;
|
367 |
-
}
|
368 |
-
|
369 |
-
return true;
|
370 |
-
}
|
371 |
-
|
372 |
-
/**
|
373 |
-
* Use a default theme.
|
374 |
-
*
|
375 |
-
* Attempt to set one of the default themes as the active one
|
376 |
-
* during Troubleshooting Mode, if one exists, if not fall
|
377 |
-
* back to always showing the active theme.
|
378 |
-
*
|
379 |
-
* @param string $theme The users active theme slug.
|
380 |
-
*
|
381 |
-
* @return string Theme slug to be perceived as the active theme.
|
382 |
-
*/
|
383 |
-
function health_check_troubleshoot_theme( $theme ) {
|
384 |
-
// Check if overrides are triggered if not break out.
|
385 |
-
if ( ! $this->override_theme() ) {
|
386 |
-
return $theme;
|
387 |
-
}
|
388 |
-
|
389 |
-
// Check if a default theme exists, and if so use it.
|
390 |
-
$default_theme = $this->has_default_theme();
|
391 |
-
if ( $default_theme ) {
|
392 |
-
$theme = $default_theme;
|
393 |
-
}
|
394 |
-
|
395 |
-
return $theme;
|
396 |
-
}
|
397 |
-
|
398 |
-
/**
|
399 |
-
* Disable Troubleshooting Mode on logout.
|
400 |
-
*
|
401 |
-
* If logged in, disable the Troubleshooting Mode when the logout
|
402 |
-
* event is fired, this ensures we start with a clean slate on
|
403 |
-
* the next login.
|
404 |
-
*
|
405 |
-
* @return void
|
406 |
-
*/
|
407 |
-
function health_check_troubleshooter_mode_logout() {
|
408 |
-
if ( ! $this->is_troubleshooting() ) {
|
409 |
-
return;
|
410 |
-
}
|
411 |
-
|
412 |
-
if ( isset( $_COOKIE['health-check-disable-plugins'] ) ) {
|
413 |
-
unset( $_COOKIE['health-check-disable-plugins'] );
|
414 |
-
setcookie( 'health-check-disable-plugins', null, 0, COOKIEPATH, COOKIE_DOMAIN );
|
415 |
-
delete_option( 'health-check-allowed-plugins' );
|
416 |
-
}
|
417 |
-
}
|
418 |
-
|
419 |
-
/**
|
420 |
-
* Catch query arguments.
|
421 |
-
*
|
422 |
-
* When in Troubleshooting Mode, look for various GET variables that trigger
|
423 |
-
* various plugin actions.
|
424 |
-
*
|
425 |
-
* @return void
|
426 |
-
*/
|
427 |
-
function health_check_troubleshoot_get_captures() {
|
428 |
-
if ( ! $this->is_troubleshooting() ) {
|
429 |
-
return;
|
430 |
-
}
|
431 |
-
|
432 |
-
// Disable Troubleshooting Mode.
|
433 |
-
if ( isset( $_GET['health-check-disable-troubleshooting'] ) ) {
|
434 |
-
unset( $_COOKIE['health-check-disable-plugins'] );
|
435 |
-
setcookie( 'health-check-disable-plugins', null, 0, COOKIEPATH, COOKIE_DOMAIN );
|
436 |
-
delete_option( 'health-check-allowed-plugins' );
|
437 |
-
|
438 |
-
wp_redirect( remove_query_arg( $this->available_query_args ) );
|
439 |
-
die();
|
440 |
-
}
|
441 |
-
|
442 |
-
// Enable an individual plugin.
|
443 |
-
if ( isset( $_GET['health-check-troubleshoot-enable-plugin'] ) ) {
|
444 |
-
$allowed_plugins = get_option( 'health-check-allowed-plugins', array() );
|
445 |
-
$allowed_plugins[ $_GET['health-check-troubleshoot-enable-plugin'] ] = $_GET['health-check-troubleshoot-enable-plugin'];
|
446 |
-
|
447 |
-
update_option( 'health-check-allowed-plugins', $allowed_plugins );
|
448 |
-
|
449 |
-
wp_redirect( remove_query_arg( $this->available_query_args ) );
|
450 |
-
die();
|
451 |
-
}
|
452 |
-
|
453 |
-
// Disable an individual plugin.
|
454 |
-
if ( isset( $_GET['health-check-troubleshoot-disable-plugin'] ) ) {
|
455 |
-
$allowed_plugins = get_option( 'health-check-allowed-plugins', array() );
|
456 |
-
unset( $allowed_plugins[ $_GET['health-check-troubleshoot-disable-plugin'] ] );
|
457 |
-
|
458 |
-
update_option( 'health-check-allowed-plugins', $allowed_plugins );
|
459 |
-
|
460 |
-
wp_redirect( remove_query_arg( $this->available_query_args ) );
|
461 |
-
die();
|
462 |
-
}
|
463 |
-
|
464 |
-
// Toggle between the active theme and a default theme.
|
465 |
-
if ( isset( $_GET['health-check-toggle-default-theme'] ) ) {
|
466 |
-
if ( $this->default_theme ) {
|
467 |
-
update_option( 'health-check-default-theme', 'no' );
|
468 |
-
} else {
|
469 |
-
update_option( 'health-check-default-theme', 'yes' );
|
470 |
-
}
|
471 |
-
|
472 |
-
wp_redirect( remove_query_arg( $this->available_query_args ) );
|
473 |
-
die();
|
474 |
-
}
|
475 |
-
}
|
476 |
-
|
477 |
-
/**
|
478 |
-
* Extend the admin bar.
|
479 |
-
*
|
480 |
-
* When in Troubleshooting Mode, introduce a new element to the admin bar to show
|
481 |
-
* enabled and disabled plugins (if conditions are met), switch between themes
|
482 |
-
* and disable Troubleshooting Mode altogether.
|
483 |
-
*
|
484 |
-
* @param WP_Admin_Bar $wp_menu
|
485 |
-
*
|
486 |
-
* @return void
|
487 |
-
*/
|
488 |
-
function health_check_troubleshoot_menu_bar( $wp_menu ) {
|
489 |
-
if ( ! $this->is_troubleshooting() ) {
|
490 |
-
return;
|
491 |
-
}
|
492 |
-
|
493 |
-
// Add top-level menu item.
|
494 |
-
$wp_menu->add_menu( array(
|
495 |
-
'id' => 'health-check',
|
496 |
-
'title' => esc_html__( 'Troubleshooting Mode', 'health-check' ),
|
497 |
-
) );
|
498 |
-
|
499 |
-
$allowed_plugins = get_option( 'health-check-allowed-plugins', array() );
|
500 |
-
|
501 |
-
// Add a link to manage plugins if there are more than 20 set to be active.
|
502 |
-
if ( count( $allowed_plugins ) > 20 ) {
|
503 |
-
$wp_menu->add_node( array(
|
504 |
-
'id' => 'health-check-plugins',
|
505 |
-
'title' => esc_html__( 'Manage active plugins', 'health-check' ),
|
506 |
-
'parent' => 'health-check',
|
507 |
-
'href' => admin_url( 'plugins.php' ),
|
508 |
-
) );
|
509 |
-
} else {
|
510 |
-
$wp_menu->add_node( array(
|
511 |
-
'id' => 'health-check-plugins',
|
512 |
-
'title' => esc_html__( 'Plugins', 'health-check' ),
|
513 |
-
'parent' => 'health-check',
|
514 |
-
) );
|
515 |
-
|
516 |
-
$wp_menu->add_group( array(
|
517 |
-
'id' => 'health-check-plugins-enabled',
|
518 |
-
'parent' => 'health-check-plugins',
|
519 |
-
) );
|
520 |
-
$wp_menu->add_group( array(
|
521 |
-
'id' => 'health-check-plugins-disabled',
|
522 |
-
'parent' => 'health-check-plugins',
|
523 |
-
) );
|
524 |
-
|
525 |
-
foreach ( $this->active_plugins as $single_plugin ) {
|
526 |
-
$plugin_slug = explode( '/', $single_plugin );
|
527 |
-
$plugin_slug = $plugin_slug[0];
|
528 |
-
|
529 |
-
$enabled = true;
|
530 |
-
|
531 |
-
if ( in_array( $plugin_slug, $allowed_plugins ) ) {
|
532 |
-
$label = sprintf(
|
533 |
-
// Translators: %s: Plugin slug.
|
534 |
-
esc_html__( 'Disable %s', 'health-check' ),
|
535 |
-
sprintf(
|
536 |
-
'<strong>%s</strong>',
|
537 |
-
$plugin_slug
|
538 |
-
)
|
539 |
-
);
|
540 |
-
$url = add_query_arg( array( 'health-check-troubleshoot-disable-plugin' => $plugin_slug ) );
|
541 |
-
} else {
|
542 |
-
$enabled = false;
|
543 |
-
$label = sprintf(
|
544 |
-
// Translators: %s: Plugin slug.
|
545 |
-
esc_html__( 'Enable %s', 'health-check' ),
|
546 |
-
sprintf(
|
547 |
-
'<strong>%s</strong>',
|
548 |
-
$plugin_slug
|
549 |
-
)
|
550 |
-
);
|
551 |
-
$url = add_query_arg( array( 'health-check-troubleshoot-enable-plugin' => $plugin_slug ) );
|
552 |
-
}
|
553 |
-
|
554 |
-
$wp_menu->add_node( array(
|
555 |
-
'id' => sprintf(
|
556 |
-
'health-check-plugin-%s',
|
557 |
-
$plugin_slug
|
558 |
-
),
|
559 |
-
'title' => $label,
|
560 |
-
'parent' => ( $enabled ? 'health-check-plugins-enabled' : 'health-check-plugins-disabled' ),
|
561 |
-
'href' => $url,
|
562 |
-
) );
|
563 |
-
}
|
564 |
-
}
|
565 |
-
|
566 |
-
$wp_menu->add_group( array(
|
567 |
-
'id' => 'health-check-theme',
|
568 |
-
'parent' => 'health-check',
|
569 |
-
) );
|
570 |
-
|
571 |
-
// Check if a default theme exists before we add a menu item to toggle it.
|
572 |
-
if ( $this->has_default_theme() ) {
|
573 |
-
// Add a link to switch between active themes.
|
574 |
-
$wp_menu->add_node( array(
|
575 |
-
'id' => 'health-check-default-theme',
|
576 |
-
'title' => ( $this->default_theme ? esc_html__( 'Use your current theme', 'health-check' ) : esc_html__( 'Use a default theme', 'health-check' ) ),
|
577 |
-
'parent' => 'health-check-theme',
|
578 |
-
'href' => add_query_arg( array( 'health-check-toggle-default-theme' => true ) ),
|
579 |
-
) );
|
580 |
-
}
|
581 |
-
|
582 |
-
$wp_menu->add_group( array(
|
583 |
-
'id' => 'health-check-status',
|
584 |
-
'parent' => 'health-check',
|
585 |
-
) );
|
586 |
-
|
587 |
-
// Add a link to disable Troubleshooting Mode.
|
588 |
-
$wp_menu->add_node( array(
|
589 |
-
'id' => 'health-check-disable',
|
590 |
-
'title' => esc_html__( 'Disable Troubleshooting Mode', 'health-check' ),
|
591 |
-
'parent' => 'health-check-status',
|
592 |
-
'href' => add_query_arg( array( 'health-check-disable-troubleshooting' => true ) ),
|
593 |
-
) );
|
594 |
-
}
|
595 |
-
|
596 |
-
}
|
597 |
-
|
598 |
-
new Health_Check_Troubleshooting_MU();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
health-check.php
CHANGED
@@ -8,7 +8,7 @@
|
|
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.1.
|
12 |
* Author URI: http://wordpress.org/plugins/health-check/
|
13 |
* Text Domain: health-check
|
14 |
*/
|
@@ -34,7 +34,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.1.
|
38 |
|
39 |
// Set the absolute path for the plugin.
|
40 |
define( 'HEALTH_CHECK_PLUGIN_DIRECTORY', plugin_dir_path( __FILE__ ) );
|
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.1.1
|
12 |
* Author URI: http://wordpress.org/plugins/health-check/
|
13 |
* Text Domain: health-check
|
14 |
*/
|
34 |
define( 'HEALTH_CHECK_MYSQL_REC_VERSION', '5.6' );
|
35 |
|
36 |
// Set the plugin version.
|
37 |
+
define( 'HEALTH_CHECK_PLUGIN_VERSION', '1.1.1' );
|
38 |
|
39 |
// Set the absolute path for the plugin.
|
40 |
define( 'HEALTH_CHECK_PLUGIN_DIRECTORY', plugin_dir_path( __FILE__ ) );
|
includes/class-health-check-troubleshoot.php
CHANGED
@@ -268,7 +268,7 @@ class Health_Check_Troubleshoot {
|
|
268 |
?>
|
269 |
<div class="notice inline">
|
270 |
|
271 |
-
<?php if ( class_exists( 'Health_Check_Troubleshooting_MU' ) && Health_Check_Troubleshooting_MU::is_troubleshooting() ) : ?>
|
272 |
|
273 |
<p style="text-align: center;">
|
274 |
<a class="button button-primary" href="<?php echo esc_url( add_query_arg( array( 'health-check-disable-troubleshooting' => true ) ) ); ?>">
|
268 |
?>
|
269 |
<div class="notice inline">
|
270 |
|
271 |
+
<?php if ( class_exists( 'Health_Check_Troubleshooting_MU' ) && is_callable( array( 'Health_Check_Troubleshooting_MU', 'is_troubleshooting' ) ) && Health_Check_Troubleshooting_MU::is_troubleshooting() ) : ?>
|
272 |
|
273 |
<p style="text-align: center;">
|
274 |
<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: 3.8
|
5 |
Tested up to: 4.9
|
6 |
-
Stable tag: 1.1.
|
7 |
License: GPLv2
|
8 |
License URI: https://www.gnu.org/licenses/gpl-2.0.html
|
9 |
|
@@ -35,6 +35,9 @@ In the future we may introduce more checks, and welcome feedback both through th
|
|
35 |
|
36 |
== Changelog ==
|
37 |
|
|
|
|
|
|
|
38 |
= v 1.1.0 =
|
39 |
* Check for theme, plugin and WordPress updates when visiting the debug tab.
|
40 |
* Improved wording on some failure situations.
|
3 |
Contributors: wordpressdotorg, westi, pento, Clorith
|
4 |
Requires at least: 3.8
|
5 |
Tested up to: 4.9
|
6 |
+
Stable tag: 1.1.1
|
7 |
License: GPLv2
|
8 |
License URI: https://www.gnu.org/licenses/gpl-2.0.html
|
9 |
|
35 |
|
36 |
== Changelog ==
|
37 |
|
38 |
+
= v 1.1.1 =
|
39 |
+
* Fixed a fatal error that would occur if a user had an older version of Troubleshooting Mode on their system.
|
40 |
+
|
41 |
= v 1.1.0 =
|
42 |
* Check for theme, plugin and WordPress updates when visiting the debug tab.
|
43 |
* Improved wording on some failure situations.
|