隐藏评论用户名称中间字段用*代替增强WordPress用户隐私信息

我们都知道wordpress评论列表默认显示全用户名,这就暴露了用户的隐私信息,随着这个强大的互联网搜索引擎,半隐藏注册用户,也是为了网站用户隐私安全。所以需要隐藏评论用户名称,但是又不能完全隐藏,所以我们可以在用户名前后随机增加数字和字母的或者直接把用户名中间字段用*代替。

隐藏评论用户名称中间字段用*代替增强WordPress用户隐私信息

隐藏评论用户名称中间字段用*代替增强WordPress用户隐私信息

具体代码如下,添加到主题的functions.php文件里面:

/* 隐藏评论用户名 */
function cut_str ($string, $sublen, $start = 0, $code = 'UTF-8') {
if ($code == 'UTF-8') {
$pa = "/[\x01-\x7f]|[\xc2-\xdf][\x80-\xbf]|\xe0[\xa0-\xbf][\x80-\xbf]|[\xe1-\xef][\x80-\xbf][\x80-\xbf]|\xf0[\x90-\xbf][\x80-\xbf][\x80-\xbf]|[\xf1-\xf7][\x80-\xbf][\x80-\xbf][\x80-\xbf]/";
preg_match_all($pa, $string, $t_string);
if (count($t_string[0]) - $start > $sublen) {
return join('', array_slice($t_string[0], $start, $sublen));
}
return join('', array_slice($t_string[0], $start, $sublen));
} else {
$start = $start*2;
$sublen = $sublen*2;
$strlen = strlen($string);
$tmpstr = '';
for ($i=0; $i< $strlen; $i++) {
if ($i>=$start && $i< ($start+$sublen)) {
if(ord(substr($string, $i, 1))>129) {
$tmpstr.= substr($string, $i, 2);
} else {
$tmpstr.= substr($string, $i, 1);
}
}
if (ord(substr($string, $i, 1))>129) {
$i++;
}
}
return $tmpstr;
}
}

function my_get_comment_author_link() {
$url = get_comment_author_url($comment_ID);
$author = cut_str(get_comment_author($comment_ID), 1, 0).'***'.cut_str(get_comment_author($comment_ID), 1, -1);
if (empty($url) || 'http://' == $url) {
return $author;
} else {
return "<a target='_blank' href='$url' rel='external nofollow' class='url'>$author</a>";
}
}
add_filter('get_comment_author_link', 'my_get_comment_author_link');

内页收录和排名还可以首页关键词排名却在100名外

上一篇

国务院废止《卖淫嫖娼人员收容教育办法》

下一篇

99%的人还看了

发表评论

插入图片

欢迎登陆本站

 | 注册

在线工具

VIP视频解析
注册

登录

忘记密码 ?