Skip to content

Instantly share code, notes, and snippets.

@krugazul
Created July 23, 2019 10:19
Show Gist options
  • Select an option

  • Save krugazul/b3ce1eaba6f78ea9c3c8f9530810e19b to your computer and use it in GitHub Desktop.

Select an option

Save krugazul/b3ce1eaba6f78ea9c3c8f9530810e19b to your computer and use it in GitHub Desktop.
Print out the functions added to a specified filter
<?php
if ( isset($_GET['debug']) ) {
$filter = 'the_title';
$hooks = array();
if ( ! empty($GLOBALS['wp_filter'][$filter]) ) {
foreach ( $GLOBALS['wp_filter'][$filter] as $priority => $tag_hooks ) {
foreach ( $tag_hooks as $hook ) {
if ( is_array($hook['function']) ) {
if ( is_object($hook['function'][0]) ) {
$func = get_class($hook['function'][0]) . '->' . $hook['function'][1];
} elseif ( is_string($hook['function'][0]) ) {
$func = $hook['function'][0] . '::' . $hook['function'][1];
}
} elseif( $hook['function'] instanceof Closure ) {
$func = 'a closure';
} elseif( is_string($hook['function']) ) {
$func = $hook['function'];
}
$hooks[] = 'On hook <b>"' . $filter . '"</b> run <b>'. $func . '</b> at priority ' . $priority;
}
}
print_r('<pre>');
print_r($hooks);
print_r('</pre>');
die();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment