wordpress /wp-includes/plugin.php中的这个函数。看了下思路还不是特别清晰,哪位高手帮忙详细解释下,谢谢了。具体代码如下:
function apply_filters($tag, $value) {
global $wp_filter, $merged_filters, $wp_current_filter; $args = array();
$wp_current_filter[] = $tag; // Do 'all' actions first
if ( isset($wp_filter['all']) ) {
$args = func_get_args();
_wp_call_all_hook($args);
} if ( !isset($wp_filter[$tag]) ) {
array_pop($wp_current_filter);
return $value;
} // Sort
if ( !isset( $merged_filters[ $tag ] ) ) {
ksort($wp_filter[$tag]);
$merged_filters[ $tag ] = true;
} reset( $wp_filter[ $tag ] ); if ( empty($args) )
$args = func_get_args(); do {
foreach( (array) current($wp_filter[$tag]) as $the_ )
if ( !is_null($the_['function']) ){
$args[1] = $value;
$value = call_user_func_array($the_['function'], array_slice($args, 1, (int) $the_['accepted_args']));
} } while ( next($wp_filter[$tag]) !== false ); array_pop( $wp_current_filter ); return $value;
}

解决方案 »

  1.   

    自己写一个wp的插件,你就会明白了,而且baidu,google上好多相关的说明filter一般是对前台的模板函数进行操作的,比如the_title,the_content在apply_filter之前必须要先进行add_filter('tag','func_name');将需要执行的函数添加到tag标签的数组中,
    然后apply_filter就是执行tag相对应的这些函数~~以下随便写了一个修改内容the_content的插件,wp2.7中测试通通过/*
    Plugin Name: WP-changeContent
    Plugin URI: http://www.ccc.com
    Description: change the content
    Version: 0.1
    Author: jack
    Author URI: http://www.ccc.com
    */function changeContent( $content )
    {
    $content = $content . '111';
    return $content;
    }add_filter( 'the_content', 'changeContent' );