WordPress替换评论者链接

//评论链接重写
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);

发表评论

此站点使用Akismet来减少垃圾评论。了解我们如何处理您的评论数据