“出版”到底是什么意思?
您可以尝试的一件事是:
http://planetozh.com/blog/my-projects/wordpress-hooks-filter-flow/
该脚本在您的WordPress根目录中运行(或在/wp admin/中运行,如果您愿意),并枚举加载到日志中的过滤器。挂钩按字母顺序显示,对于每个挂钩,活动筛选器(或操作,它们是相同的)按其执行顺序列出,执行顺序由其优先级或加载顺序定义。这样一个列表的目的是帮助查找插件bug,并在需要时让您明智地微调插件优先级。
编辑:我刚刚找到了一个很有前途的插件:http://wordpress.org/extend/plugins/wordpress-hook-sniffer/
或者,您可以更改/wp-includes/plugin。php文件并将所有钩子都记录到日志文件中。然后,您只需“发布”一篇帖子,然后查看哪个钩子被激发了。
您必须进行以下更改:
// 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));