Forked from bradyvercher/local-error-handler.php
Last active
September 22, 2023 18:58
-
-
Save smchenrybc/f639063f8ae6222fe374c184ee7aefb2 to your computer and use it in GitHub Desktop.
Suppress errors generated by specified WordPress plugins to make developing with debug mode on less painful.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Suppress errors generated by specified WordPress plugins. | |
* | |
* Include in the auto_prepend_file php.ini directive to ignore globally. | |
* | |
* @see http://plugins.trac.wordpress.org/browser/ostrichcize/tags/0.1/ostrichcize.php#L146 | |
* | |
* @param string $errno The error number. | |
* @param string $errstr The error message. | |
* @param string $errfile Path to the file that caused the error. | |
* @param int $errline Line number of the error. | |
* @return bool True to success error reporting; false to use default error handler. | |
*/ | |
function bc_custom_error_handler( $errno, $errstr, $errfile, $errline ) { | |
$patterns = array( | |
'plugins/dflip', | |
'plugins/events-calendar-pro', | |
'plugins/google-analytics-premium', | |
'plugins/ninja-forms', | |
'plugins/pojo-accessibility', | |
'plugins/the-events-calendar', | |
'plugins/the-events-calendar-filterbar', | |
); | |
foreach ( $patterns as $pattern ) { | |
$pattern = str_replace( array( '/', '\\' ), DIRECTORY_SEPARATOR, $pattern ); | |
if ( false !== strpos( $errstr, $pattern ) || false !== strpos( $errfile, $pattern ) ) { | |
return true; | |
} | |
} | |
return false; | |
} | |
set_error_handler( 'bc_custom_error_handler' ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment