Created
May 15, 2012 15:22
-
-
Save jonbish/2702604 to your computer and use it in GitHub Desktop.
Find All Functions Hooking Into A Filter/Action in WordPress
This file contains 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 | |
/* | |
Plugin Name: Find Functions Hooking Into Filters/Actions | |
Description: Find All Functions Hooking Into A Filter/Action in WordPress | |
Author: Jon Bishop | |
Author URI: http://www.jonbishop.com/ | |
Version: 1.0 | |
*/ | |
function amp_find_filters($filter_name) { | |
global $wp_filter; | |
echo 'Filter: ' . $filter_name . '<br>'; | |
if (isset($wp_filter[$filter_name])) { | |
foreach ($wp_filter[$filter_name] as $priority => $functions) { | |
foreach ($functions as $function => $args) { | |
if (is_object($args['function'][0])) { | |
$refClass = new ReflectionClass($args['function'][0]); | |
$refFunc = $refClass->getMethod($args['function'][1]); | |
echo 'class name: ' . $refClass->getName() . '<br>'; | |
echo 'method name: ' . $args['function'][1] . '<br>'; | |
} else { | |
$refFunc = new ReflectionFunction($args['function']); | |
echo 'function name: ' . $args['function'] . '<br>'; | |
} | |
echo 'file name: ' . $refFunc->getFileName() . '<br>'; | |
echo 'start line: ' . $refFunc->getStartLine() . '<br>'; | |
echo '<hr>'; | |
$refFunc = null; | |
} | |
} | |
} | |
} | |
// Usage | |
amp_find_filters('wp_footer'); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment