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

╭飛雪飄零╮ 站长2527,117字数 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
    • 123
      123 0
      Google Chrome 63.0.3239.132 Google Chrome 63.0.3239.132 Windows 7 x64 Edition Windows 7 x64 Edition

      谢谢分享

        • ╭飛雪飄零╮
          ╭飛雪飄零╮
          Google Chrome 63.0.3239.132 Google Chrome 63.0.3239.132 Windows 10 x64 Edition Windows 10 x64 Edition

          @ 123 谢谢支持。。。

          @ 123

        • 一叶知秋
          一叶知秋 0
          Google Chrome 63.0.3239.132 Google Chrome 63.0.3239.132 Windows 10 x64 Edition Windows 10 x64 Edition

          谢谢分享

          • 武胜
            武胜 1
            Firefox 61.0 Firefox 61.0 Windows 7 x64 Edition Windows 7 x64 Edition

            支持一下

              • ╭飛雪飄零╮
                ╭飛雪飄零╮
                Google Chrome 55.0.2883.87 Google Chrome 55.0.2883.87 Windows 10 x64 Edition Windows 10 x64 Edition

                @ 武胜 谢谢支持。。。

                @ 武胜

              • 广安养老院
                广安养老院 1
                Firefox 61.0 Firefox 61.0 Windows 7 x64 Edition Windows 7 x64 Edition

                文章很好值得一看

                • test
                  test 1
                  Google Chrome 55.0.2883.87 Google Chrome 55.0.2883.87 Windows 10 x64 Edition Windows 10 x64 Edition

                  测试隐藏密码

                发表评论