Skip to content

Instantly share code, notes, and snippets.

@jonbish
Created May 15, 2012 15:22
Show Gist options
  • Save jonbish/2702604 to your computer and use it in GitHub Desktop.
Save jonbish/2702604 to your computer and use it in GitHub Desktop.
Find All Functions Hooking Into A Filter/Action in WordPress
<?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