1

I've recently started using the Hikari Hooks plugin for Wordpress as it seems to allow you to get a good idea of what do_actions are being called on the page, so that you can easily find out where potential hooks for plugin code might lie.

Are there better tools/plugins for accomplishing the same thing?

In particular I was looking for one that might notify me of post status transition actions such as new_to_publish and draft_to_publish...It appears that Hikari Hooks does notify you of such changes but not that they are available, only if you're already added them as an action.

3 Answers 3

2

It is usually easy to find most hooks in documentation or source. It can be much more tricky for hooks that are dynamically generated, like post transitions. Essentially it doesn't exist in source as specific hook - it is hook that is getting generated dynamically at runtime, depending on variables.

do_action("${old_status}_to_$new_status", $post);
do_action("${new_status}_$post->post_type", $post->ID, $post);

At local test stack I often just add var_dump() on variables to source code to see what is going on. Dirty, but easy and fast. Obviously highly not recommended for production environment.

3
  • +1 - I tend to do exactly the same myself, i just use print_r in place of var_dump i find the data easier to read that way. Even wrapped it into a function so i can do this(it's quick to type) ... pre( $whatever );
    – t31os
    Commented Feb 2, 2011 at 12:12
  • @t31os Xdebug upgrades var_dump to very tricked out version
    – Rarst
    Commented Feb 2, 2011 at 14:25
  • Took a little figuring out(local server app uses some funky setup with the ini's), but i managed to get xDebug working on the local installation, awesome! Thanks for the pointing that out... :)
    – t31os
    Commented Feb 2, 2011 at 15:19
1

Note sure if this is a better way but I wrote a plugin to display the active hook on a page for this answer:

1

Less of a tool and more of a reference, the Plugin API/Filter Reference is a great list and it's sorted by type.

1
  • I came across this earlier, but it doesn't seem to cover the post state transition actions (such as new_to_publish) which appear to return a post object rather than a post_id (but I'm not sure this is the case all the time)
    – leeand00
    Commented Feb 2, 2011 at 5:00

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.