Title: wp_debug_mode
Published: April 25, 2014
Last modified: February 24, 2026

---

# wp_debug_mode()

## In this article

 * [Description](https://developer.wordpress.org/reference/functions/wp_debug_mode/?output_format=md#description)
 * [Source](https://developer.wordpress.org/reference/functions/wp_debug_mode/?output_format=md#source)
 * [Hooks](https://developer.wordpress.org/reference/functions/wp_debug_mode/?output_format=md#hooks)
 * [Related](https://developer.wordpress.org/reference/functions/wp_debug_mode/?output_format=md#related)
 * [Changelog](https://developer.wordpress.org/reference/functions/wp_debug_mode/?output_format=md#changelog)
 * [User Contributed Notes](https://developer.wordpress.org/reference/functions/wp_debug_mode/?output_format=md#user-contributed-notes)

[ Back to top](https://developer.wordpress.org/reference/functions/wp_debug_mode/?output_format=md#wp--skip-link--target)

This function’s access is marked private. This means it is not intended for use 
by plugin or theme developers, only by core. It is listed here for completeness.

Sets PHP error reporting based on WordPress debug settings.

## 󠀁[Description](https://developer.wordpress.org/reference/functions/wp_debug_mode/?output_format=md#description)󠁿

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.

## 󠀁[Source](https://developer.wordpress.org/reference/functions/wp_debug_mode/?output_format=md#source)󠁿

    ```php
    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 );
    	}
    }
    ```

[View all references](https://developer.wordpress.org/reference/files/wp-includes/load.php/)
[View on Trac](https://core.trac.wordpress.org/browser/tags/6.9.4/src/wp-includes/load.php#L578)
[View on GitHub](https://github.com/WordPress/wordpress-develop/blob/6.9.4/src/wp-includes/load.php#L578-L648)

## 󠀁[Hooks](https://developer.wordpress.org/reference/functions/wp_debug_mode/?output_format=md#hooks)󠁿

 [apply_filters( ‘enable_wp_debug_mode_checks’, bool $enable_debug_mode )](https://developer.wordpress.org/reference/hooks/enable_wp_debug_mode_checks/)

Filters whether to allow the debug mode check to occur.

## 󠀁[Related](https://developer.wordpress.org/reference/functions/wp_debug_mode/?output_format=md#related)󠁿

| Uses | Description | 
| [wp_is_json_request()](https://developer.wordpress.org/reference/functions/wp_is_json_request/)`wp-includes/load.php` |

Checks whether current request is a JSON request, or is expecting a JSON response.

  | 
| [wp_doing_ajax()](https://developer.wordpress.org/reference/functions/wp_doing_ajax/)`wp-includes/load.php` |

Determines whether the current request is a WordPress Ajax request.

  | 
| [apply_filters()](https://developer.wordpress.org/reference/functions/apply_filters/)`wp-includes/plugin.php` |

Calls the callback functions that have been added to a filter hook.

  |

[Show 1 more](https://developer.wordpress.org/reference/functions/wp_debug_mode/?output_format=md#)
[Show less](https://developer.wordpress.org/reference/functions/wp_debug_mode/?output_format=md#)

## 󠀁[Changelog](https://developer.wordpress.org/reference/functions/wp_debug_mode/?output_format=md#changelog)󠁿

| Version | Description | 
| [5.1.0](https://developer.wordpress.org/reference/since/5.1.0/) | `WP_DEBUG_LOG` can be a file path. | 
| [3.0.0](https://developer.wordpress.org/reference/since/3.0.0/) | Introduced. |

## 󠀁[User Contributed Notes](https://developer.wordpress.org/reference/functions/wp_debug_mode/?output_format=md#user-contributed-notes)󠁿

 1.  [Skip to note 2 content](https://developer.wordpress.org/reference/functions/wp_debug_mode/?output_format=md#comment-content-1540)
 2.   [Codex](https://profiles.wordpress.org/codex/)  [  10 years ago  ](https://developer.wordpress.org/reference/functions/wp_debug_mode/#comment-1540)
 3. [You must log in to vote on the helpfulness of this note](https://login.wordpress.org?redirect_to=https%3A%2F%2Fdeveloper.wordpress.org%2Freference%2Ffunctions%2Fwp_debug_mode%2F%23comment-1540)
    Vote results for this note: 0[You must log in to vote on the helpfulness of this note](https://login.wordpress.org?redirect_to=https%3A%2F%2Fdeveloper.wordpress.org%2Freference%2Ffunctions%2Fwp_debug_mode%2F%23comment-1540)
 4. **Usage**
 5.     ```php
        <?php wp_debug_mode(); ?>
        ```
    
 6.  [Log in to add feedback](https://login.wordpress.org/?redirect_to=https%3A%2F%2Fdeveloper.wordpress.org%2Freference%2Ffunctions%2Fwp_debug_mode%2F%3Freplytocom%3D1540%23feedback-editor-1540)

You must [log in](https://login.wordpress.org/?redirect_to=https%3A%2F%2Fdeveloper.wordpress.org%2Freference%2Ffunctions%2Fwp_debug_mode%2F)
before being able to contribute a note or feedback.