You’re not alone. Some less experienced developers and designers work with debugging disabled or errors hidden from their pages to avoid disturbing the content layout. Worse, some don’t even use debugging tools at all! This approach is like sweeping dirt under the carpet—it’s bound to cause issues that will come back to haunt you (or your users).
When something changes in PHP (like old functionality being deprecated), it starts throwing warnings and notices. These are meant to give developers time to update their code. But what happens when you ignore them? These notices can escalate into fatal errors that crash your site.
For example, a warning about an undefined constant used to be just a notice. In PHP 7.4 or 8.x, that same issue can become a fatal error. If you're managing websites, you must monitor the error logs regularly. Even a seemingly small warning can spiral out of control if it repeats on every request, leading to multi-gigabyte log files. We’ve seen it happen due to bugs like infinite loops in poorly coded plugins.
Solution: Suppress/ignore some errors
Installation: Add this code to the wp-config.php file right after the opening php tag: <?php
//////////////////////////////////////////////////////////////////////////////////////////////////////////////
// Orbisius.com/WPSandbox.net log suppressor. (c) All Rights Reserved.
// License: GPL v2
// This code supresses the errors/warnings/notices that are displayed by badly written plugins and themes.
// If you don't have control over their code then you can ignore those errors, so they don't create large log files.
// Add this to the wp-config.php file right after the opening php tag: <?php
// https://wpsandbox.net/1571
/*
* DISCLAIMER:
* This code is provided "AS IS" without any warranty of any kind, express or implied,
* including but not limited to the warranties of merchantability, fitness for a particular purpose,
* and non-infringement. In no event shall the authors or copyright holders be liable for any claim,
* damages, or other liability arising from, out of, or in connection with this code.
*
* Use at your own risk. The author is not responsible for any loss or damage
* resulting from its use, including but not limited to errors, incorrect logging behavior,
* or unintended filtering of critical logs.
*/
set_error_handler('orb_sys_error_handler');
/**
* Suppress the weird messages about the wrong/incorrect declaration.
* @param int $err_no
* @param string $err_str
* @param string $err_file
* @param int $err_line
* @return bool
* @see https://wpsandbox.net/1571
*/
function orb_sys_error_handler($err_no, $err_str, $err_file = '', $err_line = '') {
// ignore this warning
if (strpos($err_str, 'Declaration of') !== false) {
return true;
}
// ignore this warning too or the folders will be filling the disk
if (strpos($err_str, 'open_basedir restriction in effect') !== false) {
return true;
}
// ignore warnings in all themes
if (stripos($err_file, '/themes/') !== false) {
return true;
}
// ignore warnings in all plugins
if (stripos($err_file, '/plugins/') !== false) {
// if you have your own plugins and want to see their errors (recommended) uncomment the block below.
/*if (stripos($err_file, '/plugins/my-plugin-prefix') !== false) {
return true;
}*/
return true;
}
// ignore warnings in all plugins
if (stripos($err_file, '/mu-plugins/') !== false) {
// if you have your own plugins and want to see their errors (recommended) uncomment the block below.
/*if (stripos($err_file, '/plugins/my-plugin-prefix') !== false) {
return true;
}*/
return true;
}
// ignore any formatting warnings from WP core
if (stripos($err_file, '/wp-includes/') !== false) {
return true;
}
// If the function returns FALSE then the normal error handler continues.
return false;
}
//////////////////////////////////////////////////////////////////////////////////////////////////////////////
Next Steps After Hiding Errors:
- Contact the Developer: If you’ve hidden error messages, the next step is to reach out to the plugin or theme author with the details.
- Provide a Full Report: Include the full error message with paths and line numbers so the developer can quickly track down the issue.
- Check for Updates: Before contacting the developer, ensure you’re using the latest version of the plugin or theme. It’s possible the issue has already been fixed.