WordPress sites run on a wide range of hosting environments and with a variety of plugin combinations. As PHP evolves, it introduces new deprecation warnings to alert developers about outdated or soon-to-be-removed features. While these notices are helpful during development, they can become annoying and distracting on a production server — especially when you’re trying to troubleshoot an issue.
Deprecation notices aren’t errors, and your site continues to function correctly. The real issue is that these “PHP Deprecated” warnings can flood your log files, making them unnecessarily large and cluttered. As a result, it becomes difficult to find the actual errors that matter.
The best practice is to report all notices in your development or staging environments, but keep the production site clean and focused on critical issues. This simple MU-plugin helps you do exactly that.
MU‑Plugin to Suppress Deprecation Notices
Create a file called error-reporting.php
under wp-content/mu-plugins and add the following code:
<?php
add_action(
'muplugins_loaded',
function ( $a = false ) {
// Only allow critical errors
error_reporting( E_ALL & ~E_DEPRECATED & ~E_USER_DEPRECATED );
return $a;
},
PHP_INT_MAX, // Ensure our hook runs last
1
);
This snippet hooks into muplugins_loaded
, which runs right after all must-use plugins are loaded and before regular plugins or themes. It sets PHP’s error reporting to allow all errors except E_DEPRECATED
and E_USER_DEPRECATED
(deprecation notices). The use of PHP_INT_MAX
ensures this runs after any other MU-plugins and overrides earlier settings.
Placing this code in an mu-plugin ensures that deprecation warnings are suppressed early enough to prevent them from being logged by plugins or WordPress core.
This small mu-plugin is an effective way to keep your production logs clean and focused. It doesn’t ignore deprecation issues — it simply ensures they don’t get in the way while you’re monitoring for real problems. Bookmark this snippet; this mu-plugin works even when WordPress ignores your php.ini
and wp-config.php
settings!