This library is a fork of Rarst/wps with changes to plugin architecture and additional functionalities.
wps adds whoops error handler to a WordPress installation.
It makes error messages from PHP, admin-ajax.php
, and WP REST API a great deal more clear and convenient to work with.
The plugin is meant strictly for development and will only work with WP_DEBUG
and WP_DEBUG_DISPLAY
configuration constants enabled.
whoops can definitely get noisy with a lot of low–grade errors.
Silence errors for irrelevant locations to keep it practical and productive.
Use ?wps_disable
query argument in the URL to temporarily disable whoops.
Use regular expressions to match source file paths and error constants to configure what should be silenced.
This can be called multiple times and/or array of paths can be provided.
Note that the direction of slashes needs to match operating system or write your regexes to match either.
add_action(
'wps/loaded',
function ( \Rarst\Wps\Plugin $wps ) {
// Silence notices and warnings for any path.
$wps->silence_errors( '~.*~', E_NOTICE | E_WARNING );
// Silence for specific directory.
$wps->silence_errors( '~/wp-admin/~', E_NOTICE | E_WARNING );
// Silence _except_ specific directory.
$wps->silence_errors( '~^((?!/my-plugin/).)*$~', E_NOTICE | E_WARNING );
// Silence for plugins _except_ specific plugin.
$wps->silence_errors( '~/wp-content/plugins/(?!my-plugin)~', E_NOTICE | E_WARNING );
}
);
- Add admin settings to silence errors, to allow dynamic changes in settings without code modification.
- Create minimal WP CLI command, which will allow to set silenced paths.
MIT