# Keep Plugin Deprecation Notices Out of debug.log

> Stops PHP deprecation notices coming from plugins and themes from filling debug.log, so the real warnings and errors you are looking for stand out while debugging.

- Type: PHP
- Runs: Run everywhere
- Category: [Developer](https://wpide.com/library/category/developer/)
- Tags: debugging, debug-log, php
- Author: WPIDE Team
- Installs: 0
- Updated: 2026-10-28
- Page: https://wpide.com/library/dev-quiet-deprecation-log/

## Code

```php
// Folders whose deprecation notices are silenced.
$wpide_quiet_paths = array( WP_PLUGIN_DIR, get_theme_root() );

$wpide_previous_handler = set_error_handler( function ( $errno, $errstr, $errfile = '', $errline = 0 ) use ( $wpide_quiet_paths, &$wpide_previous_handler ) {
    if ( in_array( $errno, array( E_DEPRECATED, E_USER_DEPRECATED ), true ) ) {
        foreach ( $wpide_quiet_paths as $path ) {
            if ( 0 === strpos( (string) $errfile, $path ) ) {
                return true; // Handled: do not log.
            }
        }
    }
    // Hand everything else to the previous handler, or to PHP itself.
    return $wpide_previous_handler ? call_user_func( $wpide_previous_handler, $errno, $errstr, $errfile, $errline ) : false;
} );
```

## Notes

Only E_DEPRECATED and E_USER_DEPRECATED from wp-content are silenced; WordPress core notices and all other errors are logged as before.

## How to use it

Install the free WPIDE plugin (https://wordpress.org/plugins/wpide/), find "Keep Plugin Deprecation Notices Out of debug.log" 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/
