Typecho 给评论用户添加UA标识(XMUserAgent插件)

Typecho插件 2020-09-01 125℃ 4 2

XMUserAgent插件简介

Typecho 插件,用于在评论区显示用户使用的操作系统、浏览器信息及对应图标。

使用说明

1.解压后修改文件夹名为 XMUserAgent,将插件上传至网站目录的 /usr/plugins 下
2.在 Typecho 后台「插件管理」处启用插件
3.在需要显示的地方插入以下代码(无需判断插件是否激活,不激活不输出):

<?php $comments->useragent($agentConfig = null); ?>

唯一的参数和 Typecho 内置的方法类似,是一个 Typecho_Config 或者数组,格式如下

array(
    'size' => '12',
    'type' => '1',
    'template' => array(
        '1' => '<img class="icon-ua" src="{{osImage}}" title="{{osTitle}}" alt="{{osTitle}}" height="{{size}}" style="vertical-align:-2px;" />&nbsp;/&nbsp;<img class="icon-ua" src="{{browserImage}}" title="{{browserTitle}}" alt="{{browserTitle}}" height="{{size}}" style="vertical-align:-2px;" />',
        '2' => '{{osTitle}}&nbsp;/&nbsp;{{browserTitle}}',
        'default' => '<img class="icon-ua" src="{{osImage}}" title="{{osTitle}}" alt="{{osTitle}}" height="{{size}}" style="vertical-align:-2px;" />{{osTitle}}&nbsp;/&nbsp;<img class="icon-ua" src="{{browserImage}}" title="{{browserTitle}}" alt="{{browserTitle}}" height="{{size}}" style="vertical-align:-2px;" />{{browserTitle}}',
    ),
)

效果预览

XMUserAgent.jpgXMUserAgent.jpg

更新日志

v0.3 (2020/09/01)修改 UA 调用方式,支持自定义输出格式
v0.2 (2019/01/28)将 UA 识别方式本地化,移植了 Wordpress 插件的识别方法。
v0.1 (2019/01/27)第一个版本,尚处于测试阶段,请勿用于生产环境。

致谢

本项目基于 hakula 的项目 UserAgent for Typecho 进行改进,在此感谢。

评论 (4)

    • 这个不错哦~~~:cry:

      回复
  • 咦,貌似我还没看到下载的链接?我难道是我眼花?
    谢谢分享,是时候换了老旧版本了。

    回复
友情链接
最近评论
  1. Thiết kế phòng hát karaoke : I got this website from my pal who told me on the topic of this site and now this time I am visiting this site and
    reading very informative articles or reviews here.
  2. Lil Durk : Hello I am so grateful I found your website, I really found you by accident, while
    I was researching on Google for something else, Regardless I am here now and would just like to say
    thanks for a marvelous post and a all round exciting
    blog (I also love the theme/design), I don’t have time to read it all at the moment but I have book-marked it and also
    added your RSS feeds, so when I have time I will be back to read more, Please do keep up the superb b.
  3. Sbobet99 : Howdy thiiѕ is kinda of off tօpic but Ι was wondering if blogs use
    WYSIWYG editors or if you have to manually code with HTML.I'm starting a blog so᧐n butt have no coding skills so I wantеd to get guidаnce
    from someone with experience. Any help would be enormously аpprecіated!
  4. choithethao.tips : Undeniably believe that which you said. Your favorite
    justification seemed to be on the net the easiest thing to be aware of.
    I say to you, I certainly get irked while people consider
    worries that they plainly don't know about. You managed to
    hit the nail upon the top and also defined out the whole thing without having side-effects ,
    people can take a signal. Will likely be back to get more.Thanks
  5. https://veviewwii.tumblr.com/post/662643202115944448/ml-18s21-t2-2 : Link exchange is nothing else however it is simply placing the other
    person's web site link on your page at suitable place and other person will also do similar in support of
    you.
Top