WordPress免插件仅修改代码去掉评论/留言里的链接

这篇文章名为技术技巧篇,但也算是一个通告吧:即日起,Jeff的阳台为了规范评论,将移除评论员里面的网站链接。同时,一切在评论里夹带链接的,将以垃圾评论处理。如有不便,请原谅。

为什么这样做?因为最近非垃圾评论的垃圾评论一下子多了起来,有些人来评论就是为了推广网站链接,但很多都是与我的网站毫无内容主题相关的。Jeff只能一不做二不休了。

固然,这会打消评论的积极性。但Jeff认为,你如果真的是用心想评论的,你就不会太在乎这些。当然,Jeff姑且算是测试一阵子,如果真的对用户体验不好,我也会考虑还原。

WordPress去掉评论/留言里的链接

打开wp-includes/comment-template.php,找到这一段代码:

  function get_comment_author_link( $comment_ID = 0 ) {
	/** @todo Only call these functions when they are needed. Include in if... else blocks */
	$url    = get_comment_author_url( $comment_ID );
	$author = get_comment_author( $comment_ID );
 
	if ( empty( $url ) || 'http://' == $url )
		$return = $author;
	else
		$return = "<a href='$url' rel='external nofollow' class='url'>$author</a>";
	return apply_filters('get_comment_author_link', $return);
}

将代码

  $return = "<a href='$url' rel='external nofollow' class='url'>$author</a>";

改为

$return = "$author";

就行了。

评分:
当前平均分 0.00 (0%) - 0 个投票
2 条 评论
  1. 3.91好像没用哦~

    10年前 回复
  2. 我来学习一下。谢谢分享

    10年前 回复
发表评论