wp_debug_mode() │ WP-CLI 1.0
Set PHP error reporting based on WordPress debug settings.
No Hooks.
Return
null
. Nothing.
Usage
wp_debug_mode();
Examples
#1 There are no examples.
This function is used by the kernel for error management and is not intended to be used in development.
wp_debug_mode() wp debug mode code
WP-CLI 2.8.0-alpha
function wp_debug_mode() {
if ( WP_CLI::get_config( 'debug' ) ) {
if ( ! defined( 'WP_DEBUG' ) ) {
define( 'WP_DEBUG', true );
}
error_reporting( E_ALL & ~E_DEPRECATED & ~E_STRICT );
} else {
if ( WP_DEBUG ) {
error_reporting( E_ALL );
if ( WP_DEBUG_DISPLAY ) {
ini_set( 'display_errors', 1 );
} elseif ( null !== WP_DEBUG_DISPLAY ) {
ini_set( 'display_errors', 0 );
}
if ( in_array( strtolower( (string) WP_DEBUG_LOG ), [ 'true', '1' ], true ) ) {
$log_path = WP_CONTENT_DIR . '/debug.log';
} elseif ( is_string( WP_DEBUG_LOG ) ) {
$log_path = WP_DEBUG_LOG;
} else {
$log_path = false;
}
if ( false !== $log_path ) {
ini_set( 'log_errors', 1 );
ini_set( 'error_log', $log_path );
}
} else {
error_reporting( E_CORE_ERROR | E_CORE_WARNING | E_COMPILE_ERROR | E_ERROR | E_WARNING | E_PARSE | E_USER_ERROR | E_USER_WARNING | E_RECOVERABLE_ERROR );
}
if ( defined( 'XMLRPC_REQUEST' ) || defined( 'REST_REQUEST' ) || ( defined( 'DOING_AJAX' ) && DOING_AJAX ) ) {
ini_set( 'display_errors', 0 );
}
}
// XDebug already sends errors to STDERR.
ini_set( 'display_errors', function_exists( 'xdebug_debug_zval' ) ? false : 'STDERR' );
}
Related Functions