Debugging filters

This is something you can do when you suspect a filter is causing a problem, but you don’t know which one.

Plugins in mu-plugins are activated automatically. Adding an action on “all” will make your function run on every hook. Beware, you’ll get a lot of output. It goes to /tmp/php-errors.

<?php ///wp-content/mu-plugins
define( 'WP_DEBUG_LOG', true );

function shannon() {
        error_log( "Post variables or whatever else can go here" );
        error_log( current_filter() );
}

add_action('all', 'shannon');
Advertisements