Controlling the PHP error reporting level of WordPress

One of the annoyances of working with WordPress I’ve had for ages is trying to use the error_reporting() function to do something like temporarily turn off deprecation warnings; WordPress ignores these settings entirely.

Turns out the cause of this is the wp_debug_mode() function, which gets called by wp-settings.php and sets error_reporting(E_ALL). As a result, putting your own call to the error_reporting() function in wp-config.php won’t have any effect; you need to place your call after wp_debug_mode() runs. One smart solution is to create a very simple mu-plugin for this purpose.

Of course, it goes without saying that ignoring errors and warnings is done at your own risk.

Leave a Reply

Your email address will not be published. Required fields are marked *