Is there any way to know what functions are added to actions on a certain page in WordPress?
Leave a Reply
You must be logged in to post a comment.
Is there any way to know what functions are added to actions on a certain page in WordPress?
You must be logged in to post a comment.
There is a magic action
all
which is called on every action or filter. You can hook into this action and log all associated functions. In$GLOBALS['wp_filter']
which you can inspect too you can find all active hooks, eg. hooks that are actually used.I have written a small plugin T5 Debug Hook to see all functions for one hook:
To get a list of all available actions on a page try this:
WordPress holds current state of hook information in global
$wp_filter
variable, which you can examine (for example byvar_dump()
). Note that this is built in runtime, so it doesn’t know what is added to hook until after the point in code when that something is added.There is some helper code floating around, mine is R_Debug::list_hooks().
As Rarst has pointed out, when callbacks are hooked onto actions/filters they are added to the
$wp_filter
global. Inspecting that allows you to see which functions have been added to that hook (which may be different each time the hook is fired).See my answer to this question. Or the GitHub gist that resulted from it.
Alternatively you might like to use this plug-in, which adds a search to the admin bar of admin users, that allows you to search for hooks that have been called on that page. Selecting a hook displays a dialog with functions that have were hooked onto that action/filter: