wordpress hook&过滤器调用

时间:2015-04-12 03:46:42

标签: php wordpress

Wordpress plugin.php有一个内部函数

function _wp_call_all_hook($args) {
 global $wp_filter;

 reset( $wp_filter['all'] );
 do {
    foreach( (array) current($wp_filter['all']) as $the_ )
        if ( !is_null($the_['function']) )
            call_user_func_array($the_['function'], $args);

 } while ( next($wp_filter['all']) !== false );
}

我不理解以上面写的方式编写代码的必要性。如果它更简单地写成

,可能会出现什么问题
function _wp_call_all_hook($args) {
 global $wp_filter;

 foreach($wp_filter['all'] as $the_ )
    if ( !is_null($the_['function']) )
        call_user_func_array($the_['function'], $args);
 }
}

0 个答案:

没有答案