知道哪一个文件调用过滤器或某个操作不可能运行代码,您必须搜索并阅读源代码或使用一些文档。
有不同的插件可以帮助您调试页面中触发的钩子,搜索codex和/或Google。
不过,要想快速了解情况,请在您的functions.php
class MyTracker {
static $hooks;
static function track_hooks( ) {
$filter = current_filter();
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\'];
}
self::$hooks[] = \'On hook <b>"\' . $filter . \'"</b> run <b>\'. $func . \'</b> at priority \' . $priority;
}
}
}
}
}
add_action( \'all\', array(\'MyTracker\', \'track_hooks\') );
add_action( \'shutdown\', function() {
echo implode( \'<br />\', MyTracker::$hooks );
}, 9999);
现在访问目标页面并向下滚动到底部。。。