wordpress留言如何显示UA信息及IP地址

╭飛雪飄零╮ 站长2527,084字数 1146阅读模式
很多站长朋友是不是有兴趣试试,给留言者显示UA信息及IP地址。增加UA信息的wordpress插件官方有,如show-useragent或WP-UserAgent等。

简介

很多站长朋友是不是有兴趣试试,给留言者显示UA信息及IP地址。增加UA信息的wordpress插件官方有,如show-useragent或WP-UserAgent等,这里使用show-useragent来实现UA信息显示,另外使用IP库来实现IP显示,显示效果如下:

wordpress留言如何显示UA信息及IP地址

一、下载附件

下载附件文件,解压后连文件夹一同上传到主题根目录下,如wp-content/themes/**/。

注**为主题文件夹。

二、添加模版代码

将附后代码添加到wordpress主题根目录/**/文件夹内的functions.php模板文件的最后一行,**为主题文件夹。

require get_template_directory() . '/show-useragent/show-useragent.php';

三、添加评论模版代码

打开wordpress主题下的\inc\function或者inc目录的comment-template.php文件,有的主题可能直接在inc文件夹内,找到如下代码:

<?php get_author_admin($comment->comment_author_email, $comment->user_id); ?>

并在该代码后添加如下代码:

<span class="flags"><?php CID_print_comment_flag();echo ' ';CID_print_comment_browser(); echo convertip(get_comment_author_ip()); ?></span>

四、添加控制样式

在主题样式文件style.css最后添加如下样式:

.WB-OS img {
    width: 14px;
    height: auto;
    vertical-align: -6%;
}
.flags {
    display: none;
}
@media screen and (min-width: 900px) {
    .comment-body:hover .flags {
        display: inline;
        animation: fade-in;
        animation-duration: 0.3s;
        -webkit-animation: fade-in 0.3s;
    }
}

至此,全部代码修改完成,清空缓存即可查看效果。

IP地址更新方法

详见《WordPress Show User Agent插件IP地址更新方法》。

下载信息 show-useragent集成IP WinXP/Vista/Win7/Win8/Win10 5.2M
最近更新2020-2-4
网盘密码:发表评论并刷新可见
下载地址 查看演示

继续阅读
 最后更新:2020-2-4
╭飛雪飄零╮
评论  25  访客  18  作者  7
    • 淇
      0
      Google Chrome 95.0.4638.69 Google Chrome 95.0.4638.69 Windows 10 x64 Edition Windows 10 x64 Edition

      下载试试,谢谢

      • 老高
        老高 1
        Google Chrome 86.0.4240.198 Google Chrome 86.0.4240.198 Windows 10 x64 Edition Windows 10 x64 Edition

        等着拿下载密码呢 结果还要等审核。。。。。。。

        • 老高
          老高 1
          Google Chrome 86.0.4240.198 Google Chrome 86.0.4240.198 Windows 10 x64 Edition Windows 10 x64 Edition

          学习一下吧

          • €heung¥van
            €heung¥van 1
            QQbrowser 10.6.4209.400 QQbrowser 10.6.4209.400 Windows 10 x64 Edition Windows 10 x64 Edition

            试试看~

            • €heung¥van
              €heung¥van 1
              QQbrowser 10.6.4209.400 QQbrowser 10.6.4209.400 Windows 10 x64 Edition Windows 10 x64 Edition

              666很棒这个资源

            发表评论