WP_Site_Health::get_test_is_in_debug_mode() WordPress Method
The WP_Site_Health::get_test_is_in_debug_mode() method is used to check if the site is in debug mode. This is helpful for troubleshooting purposes.
WP_Site_Health::get_test_is_in_debug_mode() #
Test if debug information is enabled.
Description
When WP_DEBUG is enabled, errors and information may be disclosed to site visitors, or logged to a publicly accessible file.
Debugging is also frequently left enabled after looking for errors on a site, as site owners do not understand the implications of this.
Return
(array) The test results.
Source
File: wp-admin/includes/class-wp-site-health.php
public function get_test_is_in_debug_mode() { $result = array( 'label' => __( 'Your site is not set to output debug information' ), 'status' => 'good', 'badge' => array( 'label' => __( 'Security' ), 'color' => 'blue', ), 'description' => sprintf( '<p>%s</p>', __( '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.' ) ), 'actions' => sprintf( '<p><a href="%s" target="_blank" rel="noopener">%s <span class="screen-reader-text">%s</span><span aria-hidden="true" class="dashicons dashicons-external"></span></a></p>', /* translators: Documentation explaining debugging in WordPress. */ esc_url( __( 'https://wordpress.org/support/article/debugging-in-wordpress/' ) ), __( 'Learn more about debugging in WordPress.' ), /* translators: Accessibility text. */ __( '(opens in a new tab)' ) ), 'test' => 'is_in_debug_mode', ); if ( defined( 'WP_DEBUG' ) && WP_DEBUG ) { if ( defined( 'WP_DEBUG_LOG' ) && WP_DEBUG_LOG ) { $result['label'] = __( 'Your site is set to log errors to a potentially public file' ); $result['status'] = ( 0 === strpos( ini_get( 'error_log' ), ABSPATH ) ) ? 'critical' : 'recommended'; $result['description'] .= sprintf( '<p>%s</p>', sprintf( /* translators: %s: WP_DEBUG_LOG */ __( 'The value, %s, has been added to this website’s configuration file. This means any errors on the site will be written to a file which is potentially available to all users.' ), '<code>WP_DEBUG_LOG</code>' ) ); } if ( defined( 'WP_DEBUG_DISPLAY' ) && WP_DEBUG_DISPLAY ) { $result['label'] = __( 'Your site is set to display errors to site visitors' ); $result['status'] = 'critical'; // On development environments, set the status to recommended. if ( $this->is_development_environment() ) { $result['status'] = 'recommended'; } $result['description'] .= sprintf( '<p>%s</p>', sprintf( /* translators: 1: WP_DEBUG_DISPLAY, 2: WP_DEBUG */ __( '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.' ), '<code>WP_DEBUG_DISPLAY</code>', '<code>WP_DEBUG</code>' ) ); } } return $result; }
Expand full source codeCollapse full source codeView on TracView on GitHub
Changelog
Version | Description |
---|---|
5.2.0 | Introduced. |