获取所有已注册动作的列表


Answers:


32

过滤器和操作都分配给了钩子。分配给钩子的函数存储在全局$wp_filter变量中。因此,您要做的就是做到print_r这一点。

print_r($GLOBALS['wp_filter']);

PS。add_action函数进行add_filter呼叫。而后者确实如此$wp_filter[$tag][$priority][$idx]




注意:您可以直接在functions.php中添加此代码,并且您会在站点上看到调试信息:

add_action('wp', function(){ echo '<pre>';print_r($GLOBALS['wp_filter']); echo '</pre>';exit; } );

很好,但是我可以在哪里调试呢?我试图添加if(WP_DEBUG == true){全局$ wp_filter; print_r($ wp_filter); 在index.php中,我没有NULL
Jacer Omri

我不好,不应该编写全局$ wp_filter;
Jacer Omri

好,所以你解决了吗?
KrzysiekDróżdż
By using our site, you acknowledge that you have read and understand our Cookie Policy and Privacy Policy.
Licensed under cc by-sa 3.0 with attribution required.