Created
July 23, 2019 10:19
-
-
Save krugazul/b3ce1eaba6f78ea9c3c8f9530810e19b to your computer and use it in GitHub Desktop.
Print out the functions added to a specified filter
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?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