Can my “add_action” function know the name of the hook calling it?

Lots of hooks:

add_action('thesis_hook_after_comment', 'pj_time');
add_action('thesis_hook_after_comments', 'pj_time');
add_action('thesis_hook_after_comment_box', 'pj_time');
add_action('thesis_hook_after_comment_meta', 'pj_time');
add_action('thesis_hook_after_content', 'pj_time');
add_action('thesis_hook_after_content_area', 'pj_time');
add_action('thesis_hook_after_content_box', 'pj_time');
add_action('thesis_hook_after_footer', 'pj_time');
add_action('thesis_hook_after_header', 'pj_time');
add_action('thesis_hook_after_headline', 'pj_time');
// etc.

How can function pj_time() know which hook called it? Is there a global variable or something that tells me which hook we’re on? So pj_time() could output something like: “The hook (name of hook here) rocks.”

Read More

I don’t know the order the hooks are called either, they’re just in alphabetical order here. Otherwise I could use a counter to figure how many hooks we’ve done so far and determine the name of the hook that way.

So I want to know if it’s possible to get the name of the hook. Thanks.

Related posts

1 comment

Comments are closed.