# Warn When Debug Display Is On in Production

> Alerts administrators when WP_DEBUG shows errors on screen on a production site, where visitors could see file paths and warnings.

- Type: PHP
- Runs: Admin only
- Category: [Admin](https://wpide.com/library/category/admin/)
- Tags: admin, debug, notices
- Author: WPIDE Team
- Installs: 0
- Updated: 2026-10-28
- Page: https://wpide.com/library/warn-debug-mode-production/

## Code

```php
add_action( 'admin_notices', function () {
    if ( ! current_user_can( 'manage_options' ) || 'production' !== wp_get_environment_type() ) {
        return;
    }

    $displaying = defined( 'WP_DEBUG' ) && WP_DEBUG && ( ! defined( 'WP_DEBUG_DISPLAY' ) || WP_DEBUG_DISPLAY );

    if ( $displaying ) {
        echo '<div class="notice notice-warning"><p><strong>Debug output is visible.</strong> WP_DEBUG is on and errors are displayed on this production site. Set WP_DEBUG_DISPLAY to false in wp-config.php.</p></div>';
    }
} );
```

## Notes

The environment type comes from WP_ENVIRONMENT_TYPE and defaults to production.

## How to use it

Install the free WPIDE plugin (https://wordpress.org/plugins/wpide/), find "Warn When Debug Display Is On in Production" in its snippet library and add it in one click; or create a new PHP snippet in WPIDE (or any code snippets plugin) and paste the code above. More snippets: https://wpide.com/library/
