Skip to content

Instantly share code, notes, and snippets.

@bradyvercher
Last active September 21, 2023 19:39
Show Gist options
  • Save bradyvercher/6556705 to your computer and use it in GitHub Desktop.
Save bradyvercher/6556705 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.
<?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 blazersix_error_handler( $errno, $errstr, $errfile, $errline ) {
if ( E_STRICT == $errno ) {
// Return true to disable all strict notices.
//return true;
}
$patterns = array(
'Facetious_Widget::',
'GFCampaignMonitor::',
'GFMailChimp::',
'GFSurvey::',
'GoogleSitemapGeneratorLoader::',
'MR_Social_Sharing_Toolkit::',
'PigLatin::',
'Plugin_Revision_Control_UI::',
'Post_Meta_Inspector::',
'SAR_Generator::',
'SAR_Settings::',
'plugins/admin-color-schemer',
'plugins/disqus',
'plugins/gravityformscampaignmonitor',
'plugins/gravityformsmailchimp',
'plugins/gravityformssurvey',
'plugins/instapress',
'plugins/members',
'plugins/nrelate-related-content',
'plugins/page-template-dashboard',
'plugins/redirection',
'plugins/revision-control',
'plugins/rewrite-rules-inspector',
'plugins/shopp',
'plugins/simple-link-list-widget',
'plugins/thirstyaffiliates',
'plugins/vip-scanner',
'plugins/woocommerce',
'plugins/woothemes-updater',
'plugins/wp-zen-coding',
);
foreach ( $patterns as $pattern ) {
$pattern = str_replace( array( '/', '\\' ), DIRECTORY_SEPARATOR, $pattern );
if ( false !== strpos( $errstr, $pattern ) ) {
return true;
}
if ( false !== strpos( $errfile, $pattern ) ) {
return true;
}
}
// The path was not found, so report the error.
return false;
}
set_error_handler( 'blazersix_error_handler' );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment