Posted By

screamwork on 06/30/10


Tagged

wordpress


Versions (?)

Who likes this?

1 person have marked this snippet as a favorite

kaiser


List hooked functions in Wordpress


 / Published in: PHP
 

  1. function list_hooked_functions($tag=false){
  2. global $wp_filter;
  3. if ($tag) {
  4. $hook[$tag]=$wp_filter[$tag];
  5. if (!is_array($hook[$tag])) {
  6. trigger_error("Nothing found for '$tag' hook", E_USER_WARNING);
  7. return;
  8. }
  9. }
  10. else {
  11. $hook=$wp_filter;
  12. ksort($hook);
  13. }
  14. echo '<pre>';
  15. foreach($hook as $tag => $priority){
  16. echo "<br />&gt;&gt;&gt;&gt;&gt;\t<strong>$tag</strong><br />";
  17. ksort($priority);
  18. foreach($priority as $priority => $function){
  19. echo $priority;
  20. foreach($function as $name => $properties) echo "\t$name<br />";
  21. }
  22. }
  23. echo '</pre>';
  24. return;
  25. }

Report this snippet  

Comments

RSS Icon Subscribe to comments
Posted By: kaiser on July 1, 2010

Pretty kool! Thanks a lot!

Posted By: kaiser on July 1, 2010

Oh. And it works perfect. I just made a small addition in case you got a function hooked directly like wpenqueuescript:

line 20: foreach($function as $name => $properties) echo "\t$name";

becomes:

if( !empty($name) && !empty($properties) ) { echo "\t$name"; } else { echo "\tfunction hooked directly"; }

You need to login to post a comment.