一句话:对传进来的变量做过滤处理。
例子:
<?php
date_default_timezone_set("Asia/Shanghai");
function t_site($value) {
return $value.".html";
}
function t_date($value){
return date("Y-m-d H:i:s").$value;
}
add_filter("t_filter", "t_site");
add_filter("t_filter", "t_date");
/* process $value */
$value = "hello";
$my = apply_filters("t_filter",$value);
echo $my;
?>
用wordpress内置api例子:
<?php
date_default_timezone_set("Asia/Shanghai");
function content_date($value){
return date('Y-m-d H:i:s').$value;
}
function content_author($value){
return $value.'——By SharkDeng'.'<div>如果你喜欢我的文章,欢迎红包赞赏</div>';
}
add_filter('the_content', 'content_date');
add_filter('the_content', 'content_author');
?>