[wp-hackers] Finding out number of functions hooked to a particular action

Jacob wordpress at santosj.name
Sun Dec 9 22:54:35 GMT 2007

James Davis wrote:
> Is there any way to determine how many functions have been hooked to a 
> particular function? In particular I'd like to be able to tell if
> do_action("foo",...);
> causes any function to be called at all.
> Thanks,
> James

There is a global variable, called $wp_filter that holds all of the hooks.

So basically, mockup code would be like.


function get_foo_hooks()
    global $wp_filter;

    if( isset($wp_filter['foo']) )
        $i = 0;
        foreach($wp_filter['foo'] as $priority)
          $i += count($priority);
       return $i;

Or something.


Jacob Santos

http://www.santosj.name - blog
http://wordpress.svn.dragonu.net/unittest/ - unofficial WP unit test suite.

Also known as darkdragon and santosj on WP trac.

More information about the wp-hackers mailing list