Exciting News! Flipper Code is now WePlugins! Same commitment to excellence, brand new identity.

How to use enable_wp_debug_mode_checks filter in WordPress

Sandeep Kumar Mishra
Sandeep Kumar Mishra
November 12, 2022
5 minutes read

enable_wp_debug_mode_checks filter

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 the enable_wp_debug_mode_checks filter, first you have to register it using add_filter. You can write this code into the functions.php of your activated theme or in a custom WordPress Plugin.

We at WePlugins always prefer to create a custom WordPress Plugin while using hooks so nothing breaks when you update your WordPress Theme in the future.

In the below live example, we have defined a function weplugins_modify_enable_wp_debug_mode_checks_defaults which takes 1 parameter and we registered it using add_filter. The first parameter enable_wp_debug_mode_checks is the name of the hook. The second parameter weplugins_modify_enable_wp_debug_mode_checks_defaults is the name of the function which needs to be called. The third parameter is the priority of calling the hook if the same hook is used multiple times, and the last parameter is the number of arguments (if any) to be passed into the registered function.

Sometimes, you have to remove a registered hook so you can use remove_filter to remove the enable_wp_debug_mode_checks filter.

Parameters

    Below the 1 parameter is required to use this hook.

  • $enable_debug_mode: (bool) Whether to enable debug mode checks to occur. Default true.

Live Examples

Example 1: Basic Usage

Below is an example of how you can use this hook.

function weplugins_modify_enable_wp_debug_mode_checks_defaults($enable_debug_mode) { 
    // Update the $enable_debug_mode variable according to your website requirements and return this variable. You can modify the $enable_debug_mode variable conditionally too if you want.
    return $enable_debug_mode; 
}
// add the filter
add_filter( "enable_wp_debug_mode_checks", "weplugins_modify_enable_wp_debug_mode_checks_defaults", 10, 1 );

Example 2: Conditional Debug Mode

This example demonstrates how to enable debug mode only if a specific condition is met.

function weplugins_conditional_debug_mode($enable_debug_mode) { 
    if ( date('D') === 'Sun' ) { // Enable debug mode only on Sundays
        $enable_debug_mode = true;
    } else {
        $enable_debug_mode = false;
    }
    return $enable_debug_mode; 
}
// add the filter
add_filter( "enable_wp_debug_mode_checks", "weplugins_conditional_debug_mode", 10, 1 );

Example 3: Removing the Hook

To remove a hook callback, use the example below.

remove_filter( "enable_wp_debug_mode_checks", "weplugins_modify_enable_wp_debug_mode_checks_defaults", 10, 1 );

Please make sure to provide the same callback function name, priority, and number of arguments while removing the hook callback.

Access Premium WordPress Plugins

Contact Us

If you’re having any trouble using this hook, please contact our WordPress Development Team and we’d be happy to assist you.

Sandeep Kumar Mishra

Sandeep Kumar Mishra

Sandeep Kumar Mishra writes about WordPress and Artificial Intelligence, offering tips and guides to help you master your website and stay updated with the latest tech trends.

Explore the latest in WordPress

Trying to stay on top of it all? Get the best tools, resources and inspiration sent to your inbox every Wednesday.