wp_debug_mode

The timeline below displays how wordpress function wp_debug_mode has changed across different WordPress versions. If a version is not listed, refer to the next available version below.

WordPress Version: 6.5

/**
 * Sets PHP error reporting based on WordPress debug settings.
 *
 * Uses three constants: `WP_DEBUG`, `WP_DEBUG_DISPLAY`, and `WP_DEBUG_LOG`.
 * All three can be defined in wp-config.php. By default, `WP_DEBUG` and
 * `WP_DEBUG_LOG` are set to false, and `WP_DEBUG_DISPLAY` is set to true.
 *
 * When `WP_DEBUG` is true, all PHP notices are reported. WordPress will also
 * display internal notices: when a deprecated WordPress function, function
 * argument, or file is used. Deprecated code may be removed from a later
 * version.
 *
 * It is strongly recommended that plugin and theme developers use `WP_DEBUG`
 * in their development environments.
 *
 * `WP_DEBUG_DISPLAY` and `WP_DEBUG_LOG` perform no function unless `WP_DEBUG`
 * is true.
 *
 * When `WP_DEBUG_DISPLAY` is true, WordPress will force errors to be displayed.
 * `WP_DEBUG_DISPLAY` defaults to true. Defining it as null prevents WordPress
 * from changing the global configuration setting. Defining `WP_DEBUG_DISPLAY`
 * as false will force errors to be hidden.
 *
 * When `WP_DEBUG_LOG` is true, errors will be logged to `wp-content/debug.log`.
 * When `WP_DEBUG_LOG` is a valid path, errors will be logged to the specified file.
 *
 * Errors are never displayed for XML-RPC, REST, `ms-files.php`, and Ajax requests.
 *
 * @since 3.0.0
 * @since 5.1.0 `WP_DEBUG_LOG` can be a file path.
 * @access private
 */
function wp_debug_mode()
{
    /**
     * Filters whether to allow the debug mode check to occur.
     *
     * This filter runs before it can be used by plugins. It is designed for
     * non-web runtimes. Returning false causes the `WP_DEBUG` and related
     * constants to not be checked and the default PHP values for errors
     * will be used unless you take care to update them yourself.
     *
     * To use this filter you must define a `$wp_filter` global before
     * WordPress loads, usually in `wp-config.php`.
     *
     * Example:
     *
     *     $GLOBALS['wp_filter'] = array(
     *         'enable_wp_debug_mode_checks' => array(
     *             10 => array(
     *                 array(
     *                     'accepted_args' => 0,
     *                     'function'      => function() {
     *                         return false;
     *                     },
     *                 ),
     *             ),
     *         ),
     *     );
     *
     * @since 4.6.0
     *
     * @param bool $enable_debug_mode Whether to enable debug mode checks to occur. Default true.
     */
    if (!apply_filters('enable_wp_debug_mode_checks', true)) {
        return;
    }
    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), array('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 ($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);
    }
    /*
     * The 'REST_REQUEST' check here is optimistic as the constant is most
     * likely not set at this point even if it is in fact a REST request.
     */
    if (defined('XMLRPC_REQUEST') || defined('REST_REQUEST') || defined('MS_FILES_REQUEST') || defined('WP_INSTALLING') && WP_INSTALLING || wp_doing_ajax() || wp_is_json_request()) {
        ini_set('display_errors', 0);
    }
}

WordPress Version: 6.3

/**
 * Sets PHP error reporting based on WordPress debug settings.
 *
 * Uses three constants: `WP_DEBUG`, `WP_DEBUG_DISPLAY`, and `WP_DEBUG_LOG`.
 * All three can be defined in wp-config.php. By default, `WP_DEBUG` and
 * `WP_DEBUG_LOG` are set to false, and `WP_DEBUG_DISPLAY` is set to true.
 *
 * When `WP_DEBUG` is true, all PHP notices are reported. WordPress will also
 * display internal notices: when a deprecated WordPress function, function
 * argument, or file is used. Deprecated code may be removed from a later
 * version.
 *
 * It is strongly recommended that plugin and theme developers use `WP_DEBUG`
 * in their development environments.
 *
 * `WP_DEBUG_DISPLAY` and `WP_DEBUG_LOG` perform no function unless `WP_DEBUG`
 * is true.
 *
 * When `WP_DEBUG_DISPLAY` is true, WordPress will force errors to be displayed.
 * `WP_DEBUG_DISPLAY` defaults to true. Defining it as null prevents WordPress
 * from changing the global configuration setting. Defining `WP_DEBUG_DISPLAY`
 * as false will force errors to be hidden.
 *
 * When `WP_DEBUG_LOG` is true, errors will be logged to `wp-content/debug.log`.
 * When `WP_DEBUG_LOG` is a valid path, errors will be logged to the specified file.
 *
 * Errors are never displayed for XML-RPC, REST, `ms-files.php`, and Ajax requests.
 *
 * @since 3.0.0
 * @since 5.1.0 `WP_DEBUG_LOG` can be a file path.
 * @access private
 */
function wp_debug_mode()
{
    /**
     * Filters whether to allow the debug mode check to occur.
     *
     * This filter runs before it can be used by plugins. It is designed for
     * non-web runtimes. Returning false causes the `WP_DEBUG` and related
     * constants to not be checked and the default PHP values for errors
     * will be used unless you take care to update them yourself.
     *
     * To use this filter you must define a `$wp_filter` global before
     * WordPress loads, usually in `wp-config.php`.
     *
     * Example:
     *
     *     $GLOBALS['wp_filter'] = array(
     *         'enable_wp_debug_mode_checks' => array(
     *             10 => array(
     *                 array(
     *                     'accepted_args' => 0,
     *                     'function'      => function() {
     *                         return false;
     *                     },
     *                 ),
     *             ),
     *         ),
     *     );
     *
     * @since 4.6.0
     *
     * @param bool $enable_debug_mode Whether to enable debug mode checks to occur. Default true.
     */
    if (!apply_filters('enable_wp_debug_mode_checks', true)) {
        return;
    }
    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), array('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 ($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('MS_FILES_REQUEST') || defined('WP_INSTALLING') && WP_INSTALLING || wp_doing_ajax() || wp_is_json_request()) {
        ini_set('display_errors', 0);
    }
}

WordPress Version: 5.9

/**
 * Set PHP error reporting based on WordPress debug settings.
 *
 * Uses three constants: `WP_DEBUG`, `WP_DEBUG_DISPLAY`, and `WP_DEBUG_LOG`.
 * All three can be defined in wp-config.php. By default, `WP_DEBUG` and
 * `WP_DEBUG_LOG` are set to false, and `WP_DEBUG_DISPLAY` is set to true.
 *
 * When `WP_DEBUG` is true, all PHP notices are reported. WordPress will also
 * display internal notices: when a deprecated WordPress function, function
 * argument, or file is used. Deprecated code may be removed from a later
 * version.
 *
 * It is strongly recommended that plugin and theme developers use `WP_DEBUG`
 * in their development environments.
 *
 * `WP_DEBUG_DISPLAY` and `WP_DEBUG_LOG` perform no function unless `WP_DEBUG`
 * is true.
 *
 * When `WP_DEBUG_DISPLAY` is true, WordPress will force errors to be displayed.
 * `WP_DEBUG_DISPLAY` defaults to true. Defining it as null prevents WordPress
 * from changing the global configuration setting. Defining `WP_DEBUG_DISPLAY`
 * as false will force errors to be hidden.
 *
 * When `WP_DEBUG_LOG` is true, errors will be logged to `wp-content/debug.log`.
 * When `WP_DEBUG_LOG` is a valid path, errors will be logged to the specified file.
 *
 * Errors are never displayed for XML-RPC, REST, `ms-files.php`, and Ajax requests.
 *
 * @since 3.0.0
 * @since 5.1.0 `WP_DEBUG_LOG` can be a file path.
 * @access private
 */
function wp_debug_mode()
{
    /**
     * Filters whether to allow the debug mode check to occur.
     *
     * This filter runs before it can be used by plugins. It is designed for
     * non-web runtimes. Returning false causes the `WP_DEBUG` and related
     * constants to not be checked and the default PHP values for errors
     * will be used unless you take care to update them yourself.
     *
     * To use this filter you must define a `$wp_filter` global before
     * WordPress loads, usually in `wp-config.php`.
     *
     * Example:
     *
     *     $GLOBALS['wp_filter'] = array(
     *         'enable_wp_debug_mode_checks' => array(
     *             10 => array(
     *                 array(
     *                     'accepted_args' => 0,
     *                     'function'      => function() {
     *                         return false;
     *                     },
     *                 ),
     *             ),
     *         ),
     *     );
     *
     * @since 4.6.0
     *
     * @param bool $enable_debug_mode Whether to enable debug mode checks to occur. Default true.
     */
    if (!apply_filters('enable_wp_debug_mode_checks', true)) {
        return;
    }
    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), array('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 ($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('MS_FILES_REQUEST') || defined('WP_INSTALLING') && WP_INSTALLING || wp_doing_ajax() || wp_is_json_request()) {
        ini_set('display_errors', 0);
    }
}

WordPress Version: 5.7

/**
 * Set PHP error reporting based on WordPress debug settings.
 *
 * Uses three constants: `WP_DEBUG`, `WP_DEBUG_DISPLAY`, and `WP_DEBUG_LOG`.
 * All three can be defined in wp-config.php. By default, `WP_DEBUG` and
 * `WP_DEBUG_LOG` are set to false, and `WP_DEBUG_DISPLAY` is set to true.
 *
 * When `WP_DEBUG` is true, all PHP notices are reported. WordPress will also
 * display internal notices: when a deprecated WordPress function, function
 * argument, or file is used. Deprecated code may be removed from a later
 * version.
 *
 * It is strongly recommended that plugin and theme developers use `WP_DEBUG`
 * in their development environments.
 *
 * `WP_DEBUG_DISPLAY` and `WP_DEBUG_LOG` perform no function unless `WP_DEBUG`
 * is true.
 *
 * When `WP_DEBUG_DISPLAY` is true, WordPress will force errors to be displayed.
 * `WP_DEBUG_DISPLAY` defaults to true. Defining it as null prevents WordPress
 * from changing the global configuration setting. Defining `WP_DEBUG_DISPLAY`
 * as false will force errors to be hidden.
 *
 * When `WP_DEBUG_LOG` is true, errors will be logged to `wp-content/debug.log`.
 * When `WP_DEBUG_LOG` is a valid path, errors will be logged to the specified file.
 *
 * Errors are never displayed for XML-RPC, REST, and Ajax requests.
 *
 * @since 3.0.0
 * @since 5.1.0 `WP_DEBUG_LOG` can be a file path.
 * @access private
 */
function wp_debug_mode()
{
    /**
     * Filters whether to allow the debug mode check to occur.
     *
     * This filter runs before it can be used by plugins. It is designed for
     * non-web run-times. Returning false causes the `WP_DEBUG` and related
     * constants to not be checked and the default PHP values for errors
     * will be used unless you take care to update them yourself.
     *
     * To use this filter you must define a `$wp_filter` global before
     * WordPress loads, usually in `wp-config.php`.
     *
     * Example:
     *
     *     $GLOBALS['wp_filter'] = array(
     *         'enable_wp_debug_mode_checks' => array(
     *             10 => array(
     *                 array(
     *                     'accepted_args' => 0,
     *                     'function'      => function() {
     *                         return false;
     *                     },
     *                 ),
     *             ),
     *         ),
     *     );
     *
     * @since 4.6.0
     *
     * @param bool $enable_debug_mode Whether to enable debug mode checks to occur. Default true.
     */
    if (!apply_filters('enable_wp_debug_mode_checks', true)) {
        return;
    }
    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), array('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 ($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('WP_INSTALLING') && WP_INSTALLING || wp_doing_ajax() || wp_is_json_request()) {
        ini_set('display_errors', 0);
    }
}

WordPress Version: 5.4

/**
 * Set PHP error reporting based on WordPress debug settings.
 *
 * Uses three constants: `WP_DEBUG`, `WP_DEBUG_DISPLAY`, and `WP_DEBUG_LOG`.
 * All three can be defined in wp-config.php. By default, `WP_DEBUG` and
 * `WP_DEBUG_LOG` are set to false, and `WP_DEBUG_DISPLAY` is set to true.
 *
 * When `WP_DEBUG` is true, all PHP notices are reported. WordPress will also
 * display internal notices: when a deprecated WordPress function, function
 * argument, or file is used. Deprecated code may be removed from a later
 * version.
 *
 * It is strongly recommended that plugin and theme developers use `WP_DEBUG`
 * in their development environments.
 *
 * `WP_DEBUG_DISPLAY` and `WP_DEBUG_LOG` perform no function unless `WP_DEBUG`
 * is true.
 *
 * When `WP_DEBUG_DISPLAY` is true, WordPress will force errors to be displayed.
 * `WP_DEBUG_DISPLAY` defaults to true. Defining it as null prevents WordPress
 * from changing the global configuration setting. Defining `WP_DEBUG_DISPLAY`
 * as false will force errors to be hidden.
 *
 * When `WP_DEBUG_LOG` is true, errors will be logged to `wp-content/debug.log`.
 * When `WP_DEBUG_LOG` is a valid path, errors will be logged to the specified file.
 *
 * Errors are never displayed for XML-RPC, REST, and Ajax requests.
 *
 * @since 3.0.0
 * @since 5.1.0 `WP_DEBUG_LOG` can be a file path.
 * @access private
 */
function wp_debug_mode()
{
    /**
     * Filters whether to allow the debug mode check to occur.
     *
     * This filter runs before it can be used by plugins. It is designed for
     * non-web run-times. Returning false causes the `WP_DEBUG` and related
     * constants to not be checked and the default PHP values for errors
     * will be used unless you take care to update them yourself.
     *
     * @since 4.6.0
     *
     * @param bool $enable_debug_mode Whether to enable debug mode checks to occur. Default true.
     */
    if (!apply_filters('enable_wp_debug_mode_checks', true)) {
        return;
    }
    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), array('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 ($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('WP_INSTALLING') && WP_INSTALLING || wp_doing_ajax() || wp_is_json_request()) {
        ini_set('display_errors', 0);
    }
}

WordPress Version: 5.3

/**
 * Set PHP error reporting based on WordPress debug settings.
 *
 * Uses three constants: `WP_DEBUG`, `WP_DEBUG_DISPLAY`, and `WP_DEBUG_LOG`.
 * All three can be defined in wp-config.php. By default, `WP_DEBUG` and
 * `WP_DEBUG_LOG` are set to false, and `WP_DEBUG_DISPLAY` is set to true.
 *
 * When `WP_DEBUG` is true, all PHP notices are reported. WordPress will also
 * display internal notices: when a deprecated WordPress function, function
 * argument, or file is used. Deprecated code may be removed from a later
 * version.
 *
 * It is strongly recommended that plugin and theme developers use `WP_DEBUG`
 * in their development environments.
 *
 * `WP_DEBUG_DISPLAY` and `WP_DEBUG_LOG` perform no function unless `WP_DEBUG`
 * is true.
 *
 * When `WP_DEBUG_DISPLAY` is true, WordPress will force errors to be displayed.
 * `WP_DEBUG_DISPLAY` defaults to true. Defining it as null prevents WordPress
 * from changing the global configuration setting. Defining `WP_DEBUG_DISPLAY`
 * as false will force errors to be hidden.
 *
 * When `WP_DEBUG_LOG` is true, errors will be logged to `wp-content/debug.log`.
 * When `WP_DEBUG_LOG` is a valid path, errors will be logged to the specified file.
 *
 * Errors are never displayed for XML-RPC, REST, and Ajax requests.
 *
 * @since 3.0.0
 * @since 5.1.0 `WP_DEBUG_LOG` can be a file path.
 * @access private
 */
function wp_debug_mode()
{
    /**
     * Filters whether to allow the debug mode check to occur.
     *
     * This filter runs before it can be used by plugins. It is designed for
     * non-web run-times. Returning false causes the `WP_DEBUG` and related
     * constants to not be checked and the default php values for errors
     * will be used unless you take care to update them yourself.
     *
     * @since 4.6.0
     *
     * @param bool $enable_debug_mode Whether to enable debug mode checks to occur. Default true.
     */
    if (!apply_filters('enable_wp_debug_mode_checks', true)) {
        return;
    }
    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), array('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 ($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('WP_INSTALLING') && WP_INSTALLING || wp_doing_ajax() || wp_is_json_request()) {
        ini_set('display_errors', 0);
    }
}

WordPress Version: 5.1

/**
 * Set PHP error reporting based on WordPress debug settings.
 *
 * Uses three constants: `WP_DEBUG`, `WP_DEBUG_DISPLAY`, and `WP_DEBUG_LOG`.
 * All three can be defined in wp-config.php. By default, `WP_DEBUG` and
 * `WP_DEBUG_LOG` are set to false, and `WP_DEBUG_DISPLAY` is set to true.
 *
 * When `WP_DEBUG` is true, all PHP notices are reported. WordPress will also
 * display internal notices: when a deprecated WordPress function, function
 * argument, or file is used. Deprecated code may be removed from a later
 * version.
 *
 * It is strongly recommended that plugin and theme developers use `WP_DEBUG`
 * in their development environments.
 *
 * `WP_DEBUG_DISPLAY` and `WP_DEBUG_LOG` perform no function unless `WP_DEBUG`
 * is true.
 *
 * When `WP_DEBUG_DISPLAY` is true, WordPress will force errors to be displayed.
 * `WP_DEBUG_DISPLAY` defaults to true. Defining it as null prevents WordPress
 * from changing the global configuration setting. Defining `WP_DEBUG_DISPLAY`
 * as false will force errors to be hidden.
 *
 * When `WP_DEBUG_LOG` is true, errors will be logged to `wp-content/debug.log`.
 * When `WP_DEBUG_LOG` is a valid path, errors will be logged to the specified file.
 *
 * Errors are never displayed for XML-RPC, REST, and Ajax requests.
 *
 * @since 3.0.0
 * @since 5.1.0 `WP_DEBUG_LOG` can be a file path.
 * @access private
 */
function wp_debug_mode()
{
    /**
     * Filters whether to allow the debug mode check to occur.
     *
     * This filter runs before it can be used by plugins. It is designed for
     * non-web run-times. Returning false causes the `WP_DEBUG` and related
     * constants to not be checked and the default php values for errors
     * will be used unless you take care to update them yourself.
     *
     * @since 4.6.0
     *
     * @param bool $enable_debug_mode Whether to enable debug mode checks to occur. Default true.
     */
    if (!apply_filters('enable_wp_debug_mode_checks', true)) {
        return;
    }
    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), array('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 ($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('WP_INSTALLING') && WP_INSTALLING || wp_doing_ajax() || wp_is_json_request()) {
        @ini_set('display_errors', 0);
    }
}

WordPress Version: 5.0

/**
 * Set PHP error reporting based on WordPress debug settings.
 *
 * Uses three constants: `WP_DEBUG`, `WP_DEBUG_DISPLAY`, and `WP_DEBUG_LOG`.
 * All three can be defined in wp-config.php. By default, `WP_DEBUG` and
 * `WP_DEBUG_LOG` are set to false, and `WP_DEBUG_DISPLAY` is set to true.
 *
 * When `WP_DEBUG` is true, all PHP notices are reported. WordPress will also
 * display internal notices: when a deprecated WordPress function, function
 * argument, or file is used. Deprecated code may be removed from a later
 * version.
 *
 * It is strongly recommended that plugin and theme developers use `WP_DEBUG`
 * in their development environments.
 *
 * `WP_DEBUG_DISPLAY` and `WP_DEBUG_LOG` perform no function unless `WP_DEBUG`
 * is true.
 *
 * When `WP_DEBUG_DISPLAY` is true, WordPress will force errors to be displayed.
 * `WP_DEBUG_DISPLAY` defaults to true. Defining it as null prevents WordPress
 * from changing the global configuration setting. Defining `WP_DEBUG_DISPLAY`
 * as false will force errors to be hidden.
 *
 * When `WP_DEBUG_LOG` is true, errors will be logged to debug.log in the content
 * directory.
 *
 * Errors are never displayed for XML-RPC, REST, and Ajax requests.
 *
 * @since 3.0.0
 * @access private
 */
function wp_debug_mode()
{
    /**
     * Filters whether to allow the debug mode check to occur.
     *
     * This filter runs before it can be used by plugins. It is designed for
     * non-web run-times. Returning false causes the `WP_DEBUG` and related
     * constants to not be checked and the default php values for errors
     * will be used unless you take care to update them yourself.
     *
     * @since 4.6.0
     *
     * @param bool $enable_debug_mode Whether to enable debug mode checks to occur. Default true.
     */
    if (!apply_filters('enable_wp_debug_mode_checks', true)) {
        return;
    }
    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 (WP_DEBUG_LOG) {
            ini_set('log_errors', 1);
            ini_set('error_log', WP_CONTENT_DIR . '/debug.log');
        }
    } 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('WP_INSTALLING') && WP_INSTALLING || wp_doing_ajax() || wp_is_json_request()) {
        @ini_set('display_errors', 0);
    }
}

WordPress Version: 4.7

/**
 * Set PHP error reporting based on WordPress debug settings.
 *
 * Uses three constants: `WP_DEBUG`, `WP_DEBUG_DISPLAY`, and `WP_DEBUG_LOG`.
 * All three can be defined in wp-config.php. By default, `WP_DEBUG` and
 * `WP_DEBUG_LOG` are set to false, and `WP_DEBUG_DISPLAY` is set to true.
 *
 * When `WP_DEBUG` is true, all PHP notices are reported. WordPress will also
 * display internal notices: when a deprecated WordPress function, function
 * argument, or file is used. Deprecated code may be removed from a later
 * version.
 *
 * It is strongly recommended that plugin and theme developers use `WP_DEBUG`
 * in their development environments.
 *
 * `WP_DEBUG_DISPLAY` and `WP_DEBUG_LOG` perform no function unless `WP_DEBUG`
 * is true.
 *
 * When `WP_DEBUG_DISPLAY` is true, WordPress will force errors to be displayed.
 * `WP_DEBUG_DISPLAY` defaults to true. Defining it as null prevents WordPress
 * from changing the global configuration setting. Defining `WP_DEBUG_DISPLAY`
 * as false will force errors to be hidden.
 *
 * When `WP_DEBUG_LOG` is true, errors will be logged to debug.log in the content
 * directory.
 *
 * Errors are never displayed for XML-RPC, REST, and Ajax requests.
 *
 * @since 3.0.0
 * @access private
 */
function wp_debug_mode()
{
    /**
     * Filters whether to allow the debug mode check to occur.
     *
     * This filter runs before it can be used by plugins. It is designed for
     * non-web run-times. Returning false causes the `WP_DEBUG` and related
     * constants to not be checked and the default php values for errors
     * will be used unless you take care to update them yourself.
     *
     * @since 4.6.0
     *
     * @param bool $enable_debug_mode Whether to enable debug mode checks to occur. Default true.
     */
    if (!apply_filters('enable_wp_debug_mode_checks', true)) {
        return;
    }
    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 (WP_DEBUG_LOG) {
            ini_set('log_errors', 1);
            ini_set('error_log', WP_CONTENT_DIR . '/debug.log');
        }
    } 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('WP_INSTALLING') && WP_INSTALLING || wp_doing_ajax()) {
        @ini_set('display_errors', 0);
    }
}

WordPress Version: 4.6

/**
 * Set PHP error reporting based on WordPress debug settings.
 *
 * Uses three constants: `WP_DEBUG`, `WP_DEBUG_DISPLAY`, and `WP_DEBUG_LOG`.
 * All three can be defined in wp-config.php. By default, `WP_DEBUG` and
 * `WP_DEBUG_LOG` are set to false, and `WP_DEBUG_DISPLAY` is set to true.
 *
 * When `WP_DEBUG` is true, all PHP notices are reported. WordPress will also
 * display internal notices: when a deprecated WordPress function, function
 * argument, or file is used. Deprecated code may be removed from a later
 * version.
 *
 * It is strongly recommended that plugin and theme developers use `WP_DEBUG`
 * in their development environments.
 *
 * `WP_DEBUG_DISPLAY` and `WP_DEBUG_LOG` perform no function unless `WP_DEBUG`
 * is true.
 *
 * When `WP_DEBUG_DISPLAY` is true, WordPress will force errors to be displayed.
 * `WP_DEBUG_DISPLAY` defaults to true. Defining it as null prevents WordPress
 * from changing the global configuration setting. Defining `WP_DEBUG_DISPLAY`
 * as false will force errors to be hidden.
 *
 * When `WP_DEBUG_LOG` is true, errors will be logged to debug.log in the content
 * directory.
 *
 * Errors are never displayed for XML-RPC, REST, and Ajax requests.
 *
 * @since 3.0.0
 * @access private
 */
function wp_debug_mode()
{
    /**
     * Filters whether to allow the debug mode check to occur.
     *
     * This filter runs before it can be used by plugins. It is designed for
     * non-web run-times. Returning false causes the `WP_DEBUG` and related
     * constants to not be checked and the default php values for errors
     * will be used unless you take care to update them yourself.
     *
     * @since 4.6.0
     *
     * @param bool $enable_debug_mode Whether to enable debug mode checks to occur. Default true.
     */
    if (!apply_filters('enable_wp_debug_mode_checks', true)) {
        return;
    }
    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 (WP_DEBUG_LOG) {
            ini_set('log_errors', 1);
            ini_set('error_log', WP_CONTENT_DIR . '/debug.log');
        }
    } 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);
    }
}

WordPress Version: .20

/**
 * Set PHP error reporting based on WordPress debug settings.
 *
 * Uses three constants: `WP_DEBUG`, `WP_DEBUG_DISPLAY`, and `WP_DEBUG_LOG`.
 * All three can be defined in wp-config.php. By default, `WP_DEBUG` and
 * `WP_DEBUG_LOG` are set to false, and `WP_DEBUG_DISPLAY` is set to true.
 *
 * When `WP_DEBUG` is true, all PHP notices are reported. WordPress will also
 * display internal notices: when a deprecated WordPress function, function
 * argument, or file is used. Deprecated code may be removed from a later
 * version.
 *
 * It is strongly recommended that plugin and theme developers use `WP_DEBUG`
 * in their development environments.
 *
 * `WP_DEBUG_DISPLAY` and `WP_DEBUG_LOG` perform no function unless `WP_DEBUG`
 * is true.
 *
 * When `WP_DEBUG_DISPLAY` is true, WordPress will force errors to be displayed.
 * `WP_DEBUG_DISPLAY` defaults to true. Defining it as null prevents WordPress
 * from changing the global configuration setting. Defining `WP_DEBUG_DISPLAY`
 * as false will force errors to be hidden.
 *
 * When `WP_DEBUG_LOG` is true, errors will be logged to debug.log in the content
 * directory.
 *
 * Errors are never displayed for XML-RPC, REST, and Ajax requests.
 *
 * @since 3.0.0
 * @access private
 */
function wp_debug_mode()
{
    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 (WP_DEBUG_LOG) {
            ini_set('log_errors', 1);
            ini_set('error_log', WP_CONTENT_DIR . '/debug.log');
        }
    } 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);
    }
}

WordPress Version: 5.2

/**
 * Set PHP error reporting based on WordPress debug settings.
 *
 * Uses three constants: `WP_DEBUG`, `WP_DEBUG_DISPLAY`, and `WP_DEBUG_LOG`.
 * All three can be defined in wp-config.php. By default, `WP_DEBUG` and
 * `WP_DEBUG_LOG` are set to false, and `WP_DEBUG_DISPLAY` is set to true.
 *
 * When `WP_DEBUG` is true, all PHP notices are reported. WordPress will also
 * display internal notices: when a deprecated WordPress function, function
 * argument, or file is used. Deprecated code may be removed from a later
 * version.
 *
 * It is strongly recommended that plugin and theme developers use `WP_DEBUG`
 * in their development environments.
 *
 * `WP_DEBUG_DISPLAY` and `WP_DEBUG_LOG` perform no function unless `WP_DEBUG`
 * is true.
 *
 * When `WP_DEBUG_DISPLAY` is true, WordPress will force errors to be displayed.
 * `WP_DEBUG_DISPLAY` defaults to true. Defining it as null prevents WordPress
 * from changing the global configuration setting. Defining `WP_DEBUG_DISPLAY`
 * as false will force errors to be hidden.
 *
 * When `WP_DEBUG_LOG` is true, errors will be logged to debug.log in the content
 * directory.
 *
 * Errors are never displayed for XML-RPC, REST, and Ajax requests.
 *
 * @since 3.0.0
 * @access private
 */
function wp_debug_mode()
{
    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 (WP_DEBUG_LOG) {
            ini_set('log_errors', 1);
            ini_set('error_log', WP_CONTENT_DIR . '/debug.log');
        }
    } 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);
    }
}

WordPress Version: .10

/**
 * Set PHP error reporting based on WordPress debug settings.
 *
 * Uses three constants: `WP_DEBUG`, `WP_DEBUG_DISPLAY`, and `WP_DEBUG_LOG`.
 * All three can be defined in wp-config.php. By default, `WP_DEBUG` and
 * `WP_DEBUG_LOG` are set to false, and `WP_DEBUG_DISPLAY` is set to true.
 *
 * When `WP_DEBUG` is true, all PHP notices are reported. WordPress will also
 * display internal notices: when a deprecated WordPress function, function
 * argument, or file is used. Deprecated code may be removed from a later
 * version.
 *
 * It is strongly recommended that plugin and theme developers use `WP_DEBUG`
 * in their development environments.
 *
 * `WP_DEBUG_DISPLAY` and `WP_DEBUG_LOG` perform no function unless `WP_DEBUG`
 * is true.
 *
 * When `WP_DEBUG_DISPLAY` is true, WordPress will force errors to be displayed.
 * `WP_DEBUG_DISPLAY` defaults to true. Defining it as null prevents WordPress
 * from changing the global configuration setting. Defining `WP_DEBUG_DISPLAY`
 * as false will force errors to be hidden.
 *
 * When `WP_DEBUG_LOG` is true, errors will be logged to debug.log in the content
 * directory.
 *
 * Errors are never displayed for XML-RPC, REST, and Ajax requests.
 *
 * @since 3.0.0
 * @access private
 */
function wp_debug_mode()
{
    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 (WP_DEBUG_LOG) {
            ini_set('log_errors', 1);
            ini_set('error_log', WP_CONTENT_DIR . '/debug.log');
        }
    } 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);
    }
}

WordPress Version: 4.5

/**
 * Set PHP error reporting based on WordPress debug settings.
 *
 * Uses three constants: `WP_DEBUG`, `WP_DEBUG_DISPLAY`, and `WP_DEBUG_LOG`.
 * All three can be defined in wp-config.php. By default, `WP_DEBUG` and
 * `WP_DEBUG_LOG` are set to false, and `WP_DEBUG_DISPLAY` is set to true.
 *
 * When `WP_DEBUG` is true, all PHP notices are reported. WordPress will also
 * display internal notices: when a deprecated WordPress function, function
 * argument, or file is used. Deprecated code may be removed from a later
 * version.
 *
 * It is strongly recommended that plugin and theme developers use `WP_DEBUG`
 * in their development environments.
 *
 * `WP_DEBUG_DISPLAY` and `WP_DEBUG_LOG` perform no function unless `WP_DEBUG`
 * is true.
 *
 * When `WP_DEBUG_DISPLAY` is true, WordPress will force errors to be displayed.
 * `WP_DEBUG_DISPLAY` defaults to true. Defining it as null prevents WordPress
 * from changing the global configuration setting. Defining `WP_DEBUG_DISPLAY`
 * as false will force errors to be hidden.
 *
 * When `WP_DEBUG_LOG` is true, errors will be logged to debug.log in the content
 * directory.
 *
 * Errors are never displayed for XML-RPC, REST, and Ajax requests.
 *
 * @since 3.0.0
 * @access private
 */
function wp_debug_mode()
{
    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 (WP_DEBUG_LOG) {
            ini_set('log_errors', 1);
            ini_set('error_log', WP_CONTENT_DIR . '/debug.log');
        }
    } 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);
    }
}

WordPress Version: 4.0

/**
 * Set PHP error reporting based on WordPress debug settings.
 *
 * Uses three constants: `WP_DEBUG`, `WP_DEBUG_DISPLAY`, and `WP_DEBUG_LOG`.
 * All three can be defined in wp-config.php, and by default are set to false.
 *
 * When `WP_DEBUG` is true, all PHP notices are reported. WordPress will also
 * display internal notices: when a deprecated WordPress function, function
 * argument, or file is used. Deprecated code may be removed from a later
 * version.
 *
 * It is strongly recommended that plugin and theme developers use `WP_DEBUG`
 * in their development environments.
 *
 * `WP_DEBUG_DISPLAY` and `WP_DEBUG_LOG` perform no function unless `WP_DEBUG`
 * is true.
 *
 * When `WP_DEBUG_DISPLAY` is true, WordPress will force errors to be displayed.
 * `WP_DEBUG_DISPLAY` defaults to true. Defining it as null prevents WordPress
 * from changing the global configuration setting. Defining `WP_DEBUG_DISPLAY`
 * as false will force errors to be hidden.
 *
 * When `WP_DEBUG_LOG` is true, errors will be logged to debug.log in the content
 * directory.
 *
 * Errors are never displayed for XML-RPC requests.
 *
 * @since 3.0.0
 * @access private
 */
function wp_debug_mode()
{
    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 (WP_DEBUG_LOG) {
            ini_set('log_errors', 1);
            ini_set('error_log', WP_CONTENT_DIR . '/debug.log');
        }
    } 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')) {
        ini_set('display_errors', 0);
    }
}

WordPress Version: 3.7

/**
 * Sets PHP error handling and handles WordPress debug mode.
 *
 * Uses three constants: WP_DEBUG, WP_DEBUG_DISPLAY, and WP_DEBUG_LOG. All three can be
 * defined in wp-config.php. Example: <code> define( 'WP_DEBUG', true ); </code>
 *
 * WP_DEBUG_DISPLAY and WP_DEBUG_LOG perform no function unless WP_DEBUG is true.
 * WP_DEBUG defaults to false.
 *
 * When WP_DEBUG is true, all PHP notices are reported. WordPress will also display
 * notices, including one when a deprecated WordPress function, function argument,
 * or file is used. Deprecated code may be removed from a later version.
 *
 * It is strongly recommended that plugin and theme developers use WP_DEBUG in their
 * development environments.
 *
 * When WP_DEBUG_DISPLAY is true, WordPress will force errors to be displayed.
 * WP_DEBUG_DISPLAY defaults to true. Defining it as null prevents WordPress from
 * changing the global configuration setting. Defining WP_DEBUG_DISPLAY as false
 * will force errors to be hidden.
 *
 * When WP_DEBUG_LOG is true, errors will be logged to wp-content/debug.log.
 * WP_DEBUG_LOG defaults to false.
 *
 * Errors are never displayed for XML-RPC requests.
 *
 * @access private
 * @since 3.0.0
 */
function wp_debug_mode()
{
    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 (WP_DEBUG_LOG) {
            ini_set('log_errors', 1);
            ini_set('error_log', WP_CONTENT_DIR . '/debug.log');
        }
    } 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')) {
        ini_set('display_errors', 0);
    }
}