WordPress教程:给留言者增加UA信息和IP地址

站点建设19,882字数 301阅读1分0秒阅读模式

这个原先是有搞过,但是都因为某些原因失败了。显示效果不理想,所以也就搁置了一段时间,如今记录下修改的过程,方便下次查看。

 文章源自亦枫博客-https://yflad.cn/1258.html

显示效果如图:文章源自亦枫博客-https://yflad.cn/1258.html

文章源自亦枫博客-https://yflad.cn/1258.html

 文章源自亦枫博客-https://yflad.cn/1258.html

1、把下面的文件下载了,解压后放在主题的目录下。文章源自亦枫博客-https://yflad.cn/1258.html

在此感谢张戈提供的源码文章源自亦枫博客-https://yflad.cn/1258.html

百度网盘提取码:[code]vtjn[/code](为防和谐)文章源自亦枫博客-https://yflad.cn/1258.html

 文章源自亦枫博客-https://yflad.cn/1258.html

2、将下面代码添加到wordpress主题根目录functions.php模板文件的最后:文章源自亦枫博客-https://yflad.cn/1258.html

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

 文章源自亦枫博客-https://yflad.cn/1258.html

3、打开wordpress主题下的\inc\function目录的comment-template.php文件:

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

下面添加:

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

 

4、将下面配套样式文件添加到主题样式文件style.css最后:

  1. /* UA信息和IP地址 */
  2. .WB-OS img {
  3.     width: 14px;
  4.     height: auto;
  5.     vertical-align: -6%;
  6. }
  7. .flags {
  8.     display: none;
  9. }
  10. @media screen and (min-width: 900px) {
  11.     .comment-body:hover .flags {
  12.         display: inline;
  13.         animation: fade-in;
  14.         animation-duration: 0.3s;
  15.         -webkit-animation: fade-in 0.3s;
  16.     }
  17. }

 

至此修改完毕,刷新下即可看到效果。如果有CDN,清理下缓存。

 

继续阅读
扫扫关注公众号
weinxin
我的微信
微信号已复制
扫扫体验小程序
weinxin
我的公众号
公众号已复制
 最后更新:2019-5-11
亦枫
  • 本文由 亦枫 发表于2017年9月3日 01:42:39
评论  8  访客  4  作者  4