步骤一:
找到 /wp-includes/formatting.php
搜索 function _make_url_clickable_cb
会看到以下代码
function _make_url_clickable_cb($matches) {
$ret = '';
$url = $matches[2];
$url = clean_url($url);
if ( empty($url) )
return $matches[0];
// removed trailing [.,;:] from URL
if ( in_array(substr($url, -1), array('.', ',', ';', ':')) === true ) {
$ret = substr($url, -1);
$url = substr($url, 0, strlen($url)-1);
}
return $matches[1] . "<a href="$url" rel="nofollow">$url</a>" . $ret;
}
那么问题就解决了,只要把
<a href=\"$url\" rel=\"nofollow\">$url</a>
改为
<a href=\"$url\" rel=\"nofollow\" target=\"_blank\">$url</a>
就可以使评论中的链接在新窗口打开了。
步骤二:
/wp-includes/comment-template.php文件中修改。
找到下面这段:
$return = "<a href='$url' rel='external nofollow' class='url'>$author</a>";
改成
$return = "<a href='$url' rel='external nofollow' class='url' target='_blank'>$author</a>";
然后保存上传即可。


