wordpress 评论用户名部分隐藏_WordPress教程

wordpress 评论用户名部分隐藏_WordPress教程

/* 评论作者和谐,使昵称部分隐藏,例如:ad**n 。*/ 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][...
/* 评论作者和谐,使昵称部分隐藏,例如:ad**n 。*/
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++;
 }
 //if(strlen($tmpstr)< $strlen ) $tmpstr.= "...";
 return $tmpstr;
 }
}
//替换评论作者
function my_get_comment_author_link() {
$url = get_comment_author_url( $comment_ID );
 $author = cut_str(get_comment_author( $comment_ID ), 2, 0).'***'.cut_str(get_comment_author( $comment_ID ), 1, -1);
 if ( empty( $url ) || 'http://' == $url )
 return $author;
 else
 return "<a target='_blank' href='https://www.mobantu.com/$url' rel='external nofollow' class='url'>$author</a>";
}
add_filter('get_comment_author_link', 'my_get_comment_author_link');

原文链接:https://www.dqzy.cn/2025/05/21/678.html,转载请注明出处。 1、本站所有源码资源(包括源代码、软件、学习资料等)仅供研究学习以及参考等合法使用,请勿用于商业用途以及违法使用。如本站不慎侵犯您的版权请联系我们,我们将及时处理,并撤下相关内容! 2、访问本站的用户必须明白,本站对所提供下载的软件和程序代码不拥有任何权利,其版权归该软件和程序代码的合法拥有者所有,请用户在下载使用前必须详细阅读并遵守软件作者的“使用许可协议”,本站仅仅是一个学习交流的平台。 3、如下载的压缩包需要解压密码,若无特殊说明,那么文件的解压密码则为:www.dqzy.cn。 4、点启资源网是一个免费且专业分享网站源码、图片素材、特效代码、教程文章、站长工具的平台。我们努力给站长提供好的资源!
0

评论0

请先
显示验证码
没有账号?注册  忘记密码?