Skip to content

Instantly share code, notes, and snippets.

@hgezim
Created September 3, 2018 19:50
Show Gist options
  • Save hgezim/b9f6390120ddc1b586edae941771ece0 to your computer and use it in GitHub Desktop.
Save hgezim/b9f6390120ddc1b586edae941771ece0 to your computer and use it in GitHub Desktop.
This function displays the hooks attached on a filter so you can see what's messing you up!
<?php
function viper_debug_filter( $filter ) {
add_filter( $filter, function( $value ) {
global $wp_filter;
$filters = array();
foreach ( (array) $wp_filter[ current_filter() ]->callbacks as $priority => $functions ) {
foreach ( (array) $functions as $function => $args ) {
$filters['Priority ' . $priority][] = $args;
}
}
var_dump( current_filter(), $filters );
return $value;
} );
}
// Pass the filter name here
viper_debug_filter( 'the_content' );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment