[WordPress] 外掛分享: Browser Sniff

前言介紹

  • 這款 WordPress 外掛「Browser Sniff」是 2010-05-18 上架。
  • 目前有 30 個安裝啟用數。
  • 上一次更新是 2012-02-03,距離現在已有 4839 天。超過一年沒更新,安裝要確認版本是否可用。以及後續維護問題!
  • 外掛最低要求 WordPress 1.5.0 以上版本才可以安裝。
  • 尚未有人給過這款外掛評分。
  • 還沒有人在論壇上發問,可能目前使用數不多,還沒有什麼大問題。

外掛協作開發者

bpedrassani |

外掛標籤

browser | browser sniff | operating system |

內容簡介

偵測及顯示評論者的網頁瀏覽器和操作系統(用於評論循環)
描述一個任意的使用者代理字串(供常規使用)
可以顯示網頁瀏覽器和操作系統圖示
如果使用者被設置了“cookie”,例如博客管理員正在訪問該博客,它還會顯示一個帶有完整使用者代理字串的星號(只需將鼠標懸停在星號上即可查看該字符串)。普通訪客無法看到此功能。
檢測所有主流瀏覽器和操作系統、博客軟體(引用迴響/回應迴響)、純文本瀏覽器、過時瀏覽器、手機和 PDA
如果不想/不喜歡編輯模板,可以“自動地”添加到您的主題中

用法

使用方法非常簡單。

如果選擇“自動地”選項,就不必擔心,但它可能會出現在您不想要它出現的地方。

如果您想將代碼放入您的主題中,只需在評論循環中的任何位置使用函數 pri_print_browser(“使用”、“”,true,“on”);。您也可以直接使用 pri_print_browser();,然後從數據庫加載選項。這裡的參數是:

描述之前要列印的字符串(在此情況下為“使用”)
描述之后要列印的字符串(没用)
顯示圖示或不顯示的 true 或 false。默認值為 true
要在網路瀏覽器和操作系統之間打印的字符串。默認值為“on”

插件的默認使用方式如下所示:

** 使用 Mozilla Firefox Mozilla Firefox 4.0 在 Windows Windows 7 上 **

如果沒有記錄的使用者代理字串(WP1.5-),則不會印刷前後的字符串。
如果您以 WP 站點的管理員身份登錄(“烤餅”),則會在打印後顯示帶有 WordPress 檢測到的完整使用者代理字串的星號。僅將鼠標懸停在星號上即可查看它。這對於檢查插件是否正常運作很有用。

您還可以使用函數 pri_browser_string(“Mozilla/1.0”,true,“on”)來從任意使用者代理字串中查找瀏覽器描述。它會返回帶有瀏覽器描述的字符串。這些參數是:

要檢測的使用者代理字串。(“Mozilla/1.0”等)
顯示圖示或不顯示的 true 或 false
要在網頁瀏覽器和操作系統之間打印的字符串。默認值為“on”

** 查找評論循環 **

如果您的模板是用於新版本的 WordPress(2.7+),通常評論循環位於文件 wp-content/themes/your-theme/comments.php中。只需尋找類似“評論循環”的線索,或顯示在每個評論上的文字,例如“評論來自”,或者只需使用函數 pri_print_browser(“使用”、“”,true,“on”)並查看它印刷的位置,然後嘗試定位您想要的位置即可。

儘管通常使用 wp-content/themes/your-theme/comments.php 文件,但有時也可能是 wp-content/themes/your-theme/comments-popup.php,甚至是 wp-content/themes/your-theme/functions.php。如果使用了最後一個文件,請查找自定義注釋函數或類似的東西。

我不會深入挖掘這個問題,但是只要有時間和意願,您就可以找到評論循環。一旦找到它,您就不會忘記它 🙂

原文外掛簡介

Detects and shows commenters web browser/operating system (used in the comment loop)
Describe an arbitrary user agent string (for general use)
Can show web browser/operating system icons
If the user is “cookied” – a.k.a blog admin visiting the blog – , it also displays an asterisk titled with the full user agent string(just mouse hover the asterisk to see the string). Regular visitors can’t see this feature.
All mainstream browsers and SOs are detected, blogging softwares(trackbacks/pingbacks), text based browsers, antiquated browsers, cell phones and pdas
It can be “automagically” added in your theme if you do not want/like to edit templates

Usage
Usage is pretty simple.
If you choose the “automagically” option, no need to worries, but it can be placed where you do not want it to be.
If you want to place the code into your theme, just use the function pri_print_browser(“Using “, “”, true, ‘on’); wherever you want in the comment loop. Also you can simply use pri_print_browser(); and the options will be loaded from database. The parameters here are:

String to be printed before description(“Using” in this case)
String to be printed after description(nothing i.t.c)
true or false to display icons or not. Default is true
String to be printed between web broser and operating system. Default is ‘on’.

The default use of the plugin show something like this:
** Using Mozilla Firefox Mozilla Firefox 4.0 on Windows Windows 7 **
If there’s no recorded user agent string(WP1.5-), strings before and after will no be printed.
If you are logged as administrator of the WP-based site(“cookied”), you’ll see an asterisk after the print, with the full user agent string detected by WordPress. Just hover the asterisk to see it. This is useful to see if the plugin is working correctly.
You can also find browser description from an arbitrary user agent string, using the function pri_browser_string(“Mozilla/1.0”, true, ‘on’); . It’ll return a string with the browser description. The parameters are:

The user agent string to be detected.(“Mozilla/1.0” i.t.c)
true of false to display icons or not
String to be printed between web broser and operating system. Default is ‘on’.

** FINDING THE COMMENT LOOP **
If your template is made to newer versions of WordPress(2.7+), normally the comment loop will be located in the file wp-content/themes/your-theme/comments.php . Just look for clues like “comment loop”, or text printed on every comment, like “commented by”, or you can just put the function pri_print_browser(“Using “, “”, true, ‘on’); and see where it prints, then try to locate where you want it to be.
Although normally the wp-content/themes/your-theme/comments.php file is used, sometimes it can be the wp-content/themes/your-theme/comments-popup.php, or even the wp-content/themes/your-theme/functions.php. If this last one is used, look for a function custom_comment() or something like this.
I’ll not dig deeper in this, but with some time and will, you can find the comment loop. Once you find it, you won’t forget it 🙂

各版本下載點

  • 方法一:點下方版本號的連結下載 ZIP 檔案後,登入網站後台左側選單「外掛」的「安裝外掛」,然後選擇上方的「上傳外掛」,把下載回去的 ZIP 外掛打包檔案上傳上去安裝與啟用。
  • 方法二:透過「安裝外掛」的畫面右方搜尋功能,搜尋外掛名稱「Browser Sniff」來進行安裝。

(建議使用方法二,確保安裝的版本符合當前運作的 WordPress 環境。


2.0 | 2.1 | 2.2 | 2.3 | 1.11 | 1.12 | 1.13 | trunk |

延伸相關外掛(你可能也想知道)

  • OS Adder 》這個外掛會在 body 標籤中添加操作系統(win、mac、linux、iPad、iPhone)的縮寫。, 如果有不同的操作系統需求,你可以使用 CSS 選擇器 (例如:「.mac」) 來...。
  • User Agent Displayer 》此外掛可以顯示在您部落格留言的用戶的瀏覽器和平台,並且能夠判斷瀏覽器的版本。。

文章
Filter
Mastodon