Is This A Correct Example Usage Of current_filter()?

Hi @Raj Sekharan:

Looks good to me, but is wanting to know the current usage really your question or do you want to understand where current_filter() gets it’s information from?

If the latter, here’s basically what happens in all the different hook processing functions, e.g. do_action(), apply_filters(), do_action_ref_array(), apply_filters_ref_array() (greatly simplified, of course):

<?php
function <process_hook>($hook, $value) {
  global $wp_filter, $wp_current_filter;
  $wp_current_filter[] = $hook;  // "Push" the hook onto the stack.
  $value = call_user_func($wp_filter[$hook]['function'],$value);
  array_pop($wp_current_filter);
  return $value;
}

Then all that current_filter() does is retrieve the last hook “pushed” onto the global wp_current_filter array, i.e.:

<?php
function current_filter() {
  global $wp_current_filter;
  return end( $wp_current_filter );
}