PluginProbe
SpinupWP / 1.5
SpinupWP v1.5
trunk 1.0 1.0.1 1.0.2 1.0.3 1.1 1.1.1 1.1.2 1.2 1.3 1.4 1.4.1 1.4.2 1.5 1.5.1 1.6 1.7 1.7.1 1.8.0 1.9.0 1.9.1
spinupwp / src / SiteHealth.php

SiteHealth.php in SpinupWP 1.5, at src/SiteHealth.php

80 lines 2.4 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 namespace SpinupWp;
4
5 class SiteHealth {
6
7 /**
8 * Init
9 */
10 public function init() {
11 add_filter( 'site_status_tests', array( $this, 'filter_site_health_checks' ) );
12 }
13
14 /**
15 * Add SpinupWP specific tests to the site health screen.
16 *
17 * @param array $tests
18 *
19 * @return array
20 */
21 public function filter_site_health_checks( $tests ) {
22 $tests['direct']['debug_enabled'] = array(
23 'label' => __( 'Debugging enabled' ),
24 'test' => array( $this, 'test_debug_mode' )
25 );
26
27 return $tests;
28 }
29
30 /**
31 * Test if debug information is enabled.
32 *
33 * Copied from `WP_Site_Health::get_test_is_in_debug_mode` but removed
34 * warning about `WP_DEBUG_LOG` constant because SpinupWP denies access
35 * to all *.log files.
36 *
37 * @return array The test results.
38 */
39 public function test_debug_mode() {
40 $result = array(
41 'label' => __( 'Your site is not set to output debug information' ),
42 'status' => 'good',
43 'badge' => array(
44 'label' => __( 'Security' ),
45 'color' => 'blue',
46 ),
47 'description' => sprintf(
48 '<p>%s</p>',
49 __( '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.' )
50 ),
51 'actions' => sprintf(
52 '<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>',
53 /* translators: Documentation explaining debugging in WordPress. */
54 esc_url( __( 'https://wordpress.org/support/article/debugging-in-wordpress/' ) ),
55 __( 'Read about debugging in WordPress.' ),
56 /* translators: accessibility text */
57 __( '(opens in a new tab)' )
58 ),
59 'test' => 'is_in_debug_mode',
60 );
61
62 if ( defined( 'WP_DEBUG' ) && WP_DEBUG && defined( 'WP_DEBUG_DISPLAY' ) && WP_DEBUG_DISPLAY ) {
63 $result['label'] = __( 'Your site is set to display errors to site visitors' );
64
65 $result['status'] = 'critical';
66
67 $result['description'] .= sprintf(
68 '<p>%s</p>',
69 sprintf(
70 /* translators: 1: WP_DEBUG_DISPLAY, 2: WP_DEBUG */
71 __( '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.' ),
72 '<code>WP_DEBUG_DISPLAY</code>',
73 '<code>WP_DEBUG</code>'
74 )
75 );
76 }
77
78 return $result;
79 }
80 }