最近垃圾链接越来越多 杜绝垃圾评论链接的滋生 开始 评论链接重新功能是必要的
//评论链接重写
function add_redirect_comment_link($text = ”){
$text=str_replace(‘href=”‘, ‘href=”‘.get_option(‘home’).’/?r=’, $text);
$text=str_replace(“href='”, “href='”.get_option(‘home’).”/?r=”, $text);
return $text;
}
function redirect_comment_link(){
$redirect = $_GET[‘r’];
if($redirect){
if(strpos($_SERVER[‘HTTP_REFERER’],get_option(‘home’)) !== false){
header(“Location: $redirect”);
exit;
}
else {
header(“Location: “.bloginfo(‘url’).”/”);
exit;
}
}
}
add_action(‘init’, ‘redirect_comment_link’);
add_filter(‘get_comment_author_link’, ‘add_redirect_comment_link’, 5);
add_filter(‘comment_text’, ‘add_redirect_comment_link’, 99);
出来的HTML链接地址为:
http://www.ake6688.com/?r=http://www.somexxx.com/