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;
}
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;
}
解决方案 »
- php执行cmd无反应,命令没有执行
- 遇到难题了,请高手帮忙
- 我又发现一个php关于正则表达式的一个严重错误, 我实在对php感到无奈了,什么烂东西。50分,第一个找到错误是我的原因的,分全送。
- 又见js变态的写法,看得我脑子痛
- 表单和session
- 有没有办法检测 收件人的系统支持HTML邮件还是只文本格式邮件?
- 我要做一个在线客服的系统,就是,用户访问网站时,会弹出一窗口,在这个窗口里面,
- 如何在linux下利用php使用microsoft SQL server数据库
- 文件被传到何处?
- destoon 新建模块
- 大家好!有谁有有最新的php官方中文手册?
- 相同代码在appache下能运行,IIS下就不行,为什么?
然后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' );