I would be grateful if someone could point out a link. I understand this may have a very lengthy answer but I searched and couldn’t find any resource.
Alternatively, it would also be nice if someone can just state the order in which hooks are fired. I’m sure there wont be many since I am only concerned about the “published” posts.
Thanks in advance.
1 Answer
What exactly do you mean with “published”?
One thing you can try is this :
The script runs in your WordPress root (or in /wp-admin/ if you prefer) and enumerates filters that are loaded in your blog. Hooks are displayed alphabetically, and for each hook, active filters (or actions, they’re the same) are listed in their execution order, which is either defined by their priority or by their loading order. The purpose of such a list is to help hunt plugin bugs down, and let you wisely fine-tune plugin priorities if needed.
Edit : I just found one promising looking plugin for this task : http://wordpress.org/extend/plugins/wordpress-hook-sniffer/
Alternativly you can change the /wp-includes/plugin.php file and log all hooks fired into log files. You then just have to “publish” a post and look which hooks has fired.
Following changes you have to made:
// in apply_filters(..)
$log = array();
do {
foreach( (array) current($wp_filter[$tag]) as $the_ )
if ( !is_null($the_['function']) ){
$args[1] = $value;
$log[] = $the_;
$value = call_user_func_array($the_['function'], array_slice($args, 1, (int) $the_['accepted_args']));
}
} while ( next($wp_filter[$tag]) !== false );
$filename = ABSPATH."/hooks.$tag.log"
file_put_contents($filename,file_get_contents($filename) ."\n". print_r($log,true));
// in apply_filters_ref_array(..)
$log = array();
do {
foreach( (array) current($wp_filter[$tag]) as $the_ )
$log[] = $the_;
if ( !is_null($the_['function']) )
$args[0] = call_user_func_array($the_['function'], array_slice($args, 0, (int) $the_['accepted_args']));
} while ( next($wp_filter[$tag]) !== false );
$filename = ABSPATH."/hooks.$tag.log"
file_put_contents($filename,file_get_contents($filename) ."\n". print_r($log,true));
// in do_action(..)
$log = array();
do {
foreach ( (array) current($wp_filter[$tag]) as $the_ )
$log[] = $the_;
if ( !is_null($the_['function']) )
call_user_func_array($the_['function'], array_slice($args, 0, (int) $the_['accepted_args']));
} while ( next($wp_filter[$tag]) !== false );
$filename = ABSPATH."/hooks.$tag.log"
file_put_contents($filename,file_get_contents($filename) ."\n". print_r($log,true));
// in do_action_ref_array(..)
$log = array();
do {
foreach( (array) current($wp_filter[$tag]) as $the_ )
$log[] = $the_;
if ( !is_null($the_['function']) )
call_user_func_array($the_['function'], array_slice($args, 0, (int) $the_['accepted_args']));
} while ( next($wp_filter[$tag]) !== false );
$filename = ABSPATH."/hooks.$tag.log"
file_put_contents($filename,file_get_contents($filename) ."\n". print_r($log,true));