WordPress Browser Detection Plugin
I’ve made another WordPress plugin (that makes four of them! go me!). This time it is the WordPress web browser detection plugin. It provides a function that takes user agent string as a parameter and then return a descriptive string. It also provides another function for easy insertion in comment template.
Features
- Detects and shows commenters web browser and operating system (for use in comment template)
- Describe an arbitrary user agent string (for general use)
- Optionally show web browser and operating system icon.
- If the user is ‘cookied’, it also displays an asterisk titled with the full user agent string (hover over them to see the full user agent string). Your regular visitors will not be shown this asterisk.
- Most browsers detected: major desktop browsers, antiquated browsers, blogging software (for trackbacks and pingbacks), text based browsers, various PDAs and cell phones.
- Humiliates those IE users
.
Requirement
WordPress 1.5. WordPress 1.2 doesn’t store commenters user agent, so comment entries migrated from 1.2 won’t have browser description. Some basic knowledge of PHP and editing WordPress template are also required.
Instructions
- Download the plugin: browsniff.txt
- Put it in your
wp-content/pluginsdirectory and rename it tobrowsniff.php. - Activate the plugin from your Wordpress Plugins administration menu.
- (optional) Download web browser and operating system icons: browsers.tar.gz. Extract it in your WordPress installation root directory. This should create a directory
browsersfilled with icons. - Follow the usage below.
- (optional) You can change how the icons look in your CSS by modifying style for selector
img.browsericon - Send me correction if an user agent gets incorrectly detected.
- Send me a better icon if you find out my icon’s quality is not satisfactory

Usage
To show commenters web browser description, use the function pri_print_browser("Using ", "", true, 'on'); inside the comment loop. The function has three parameters:
- String to be printed before description
- String to be printed after description
- Whether to display icons or not, set this to
trueorfalse. - String to be printed between web browser and operating system description, defaults to ‘on’.
String before and after the description will not be printed if there’s no recorded user agent string (as with comments migrated from WordPress 1.2). If the visitor is ‘cookied’ (blog administrator visiting the blog), the function will also print an asterisk titled with the full user agent string (hover to see it). This will ease you to see whether browser detection is functioning correctly. Please send me correction if an user agent string is incorrectly detected.
To find browser description from an arbitrary user agent string, use the function pri_browser_string("Mozilla/1.0", true, 'on'). The function takes two parameters:
- The user agent string to be detected.
- Whether to display icons or not, set this to
trueorfalse. - String to be printed between web browser and operating system description, defaults to ‘on’.
The function will return a string with the browser description.
Note: you can edit the plugin file browsniff.php and adjust the variable $pri_width_height to set the width and height of each displayed icon file. All of my icons are in standard size 16×16, but I decided to scale it down to 14×14 in this blog.
Demonstration
You are usingUnknown browser
Changelog
1.0:
- First release
1.1:
- Added $between parameter. Thanks to João Craveiro.
1.2:
- Fixes for eLinks
1.3:
- Detects Shiira. Thanks to CH Chan.
1.4:
- Now detects Windows Vista, Qtopia/QtEmbedded, Danger HipTop, Anonymouse, PHP, Drupal, TypePad, and several Samsung phones.
1.5:
- Detects Nokia E Series (as SymbianOS), W3M, Openwave UP.Browser, Mozilla Seamonkey, Minimo, Flock, MultiZilla, Sony PSP, AvantBrowser and Opera Mini. Also includes various icon updates. Thanks to Frank Aune and Siren.
1.6:
- Detects o2 XDA, Dopod, Xiino, LG Electronics phones, Motorola phones, and NTT DoCoMo phones.
1.7:
- Detects Kazehakase.
1.8:
- Detects Nintendo Wii.
1.10:
- Detects all Ubuntu derivatives: Kubuntu, Xubuntu and Edubuntu.
- Detects Debian Iceweasel and unbranded Firefox (BonEcho).
- Fixes for Nintendo Wii.
- Rearrange order for Debian derivatives.
done.
langsung pasang.
thanks.
wah keren.
coba test dulu ah
wah plugin baru
pasang ach
[…]
March 29th, 2005
Browser detection plugin up
I have just configured the browser detection plugin from Priyadi. It is working like a charm. Act […]
[…] March 28th, 2005 WordPress Plugin: Browser Detection This is a Browser Detection Plugin for WordPress. It provides a function that ta […]
Pasang ah..
Kalo buat smileys gimana ama comment preview gimana Pri 
sayang cuma WP 1.5
keren sekale…
coba di blog gw ah….
kewl!
ngetest dulu …. OK
keree…ennnnnn

ikutan ach
Mas, kenapa browser detectionnya harus begitu banyak else if else if? Kenapa ngga dipisah aja jadi 1 file yg berisi browser information (user agent, etc).
Jadi kalau nanti ada browser baru, cuma perlu update data filenya aja. Ngga perlu update seluruh pluginnya (ngga perlu ubah source code pluginnya, cuma ubah data).
Sip udah di pasang di blog gw.. hore….
loh kedeteknyan ako win 98 dan ie5.5? padahal gw pake win 2k and firefox 101??
gak tertarikkkk biasa aja lagi
Suggestion: a 4th parameter $between (defaulting to ‘ on ’ or something), to make it easy to display things in some language other than English.
Pernah nyoba paket PEAR Net_UserAgent_Detect ngga?
*penggemar PEAR*
Btw, data user-agent yg dipaket segitu banyak browser dapet dari mana?
Pernah nyoba paket PEAR Net_UserAgent_Detect ngga?
*Penggemar PEAR*
Btw, data user-agent yang dipake browser sgitu banyak dapet dari mana?
Already did it; tried to send you the corrected source to your mail, but was blocked by your ISP
You can see it here.
#13: kalau begitu lumayan sulit kalau mau capture versi browser berhubung lokasi string versi beda-beda untuk setiap browser. ujung-ujungnya nanti cuma ribet coding frameworknya
, sedangkan kalau pakai if elseif seperti sekarang gak sampai 2 jam udah beres
.
#15: string anda adalah Mozilla/4.0 (compatible; MSIE 5.5; Windows 98). looks like IE 5.5 on Win98 to me
. mungkin loe pakai extension firefox untuk mengubah string user agent? atau mungkin juga proxy servernya yang mengubah menjadi seperti itu 
#17, #20: I also already did it, but thanks anyway.
OK
Just one thing: does it display correctly to you, without any aditional spaces? I used a “[space]on[space]” default $between, so that there would always be one space at each side of the word ‘on’ (no problem with dup spaces, becuase HTML eliminates them); otherwise, it would be glued to the end of the browser name.
Nevermind; forgot to check out below that you put the space at another point of the algorithm — more efficient that way, indeed.
#18: baru lihat Net_UserAgent_Detect, gak terlalu suka, dan juga dukungan browsernya sedikit.
[…] perating system will be displayed. This is a very kewl plugin to have.. More on the plugin here.. Priyadi has some good plugin’s. do check them o […]
[…] upgrade this blog to WP1.5, mm.. agaknya sih males untuk upgrade tapi pas liat ada plugin Browser Sniff jadi pengen deh. Migrasi ke CSS base ternyata gampang2-s […]
gue udah masang juga
Question: Where do I add in the code:
pri_print_browser("Using ", "", true, 'on');Where do I add that into the comments template? Did not understand “use the function inside the comment loop”. Any specific location of code I should add this into?
Protes ah, logonya Mac OS X kok jelek amat sih
[…] . I love Wordpress, I enjoy using WordPress, I even created four WordPress plugins so far: Browser Detection, PHP Exec, IM Smileys and IP to Country. I find this […]
#30: inside the loop that prints each comments, you will find it in comments template.
#31: taken straight from apple.com’s favicon, blame apple!
This is great, thanks a lot!
egh soal OS, ada kedetek Fedora, Ubuntu, Suse apalagi windowsnya. Tapi, kalo aku pake Ubuntu, tetapi kedetek hanya Linux, apakah karena aku install binari dari mozilla, dan bukan dari distro?
#36: kalau di stringnya ada fedora, ubuntu, suse atau suse, maka akan ada merk distronya. tapi kalau gak ada, maka cuma ‘linux’ yang akan ditampilkan. jadi kalau install binary dari mozilla gak akan kelihatan merk distronya.
[…] gue berhasil kok masangnya,.. Pluggins itu antara lain Browser Detection Plugin dan IP to Country Plugin. Gue bangga karena […]
[…] on un excelente plugin para saber con qué navega cada uno de los comentadores. Se trata de Browser Sniff, desarrollado por Priyadi Iman Nurcahyo. Este plugin mue […]
Works great. Thanks a lot.
Genial
[…] #8221; alt=”” />” makasih buat semplon atas pencerahannya.Dah skg plugin Browser Detection Plugin sudah bisa jalan ah capek habis 15.000 dg /j […]
[…] rációs rendszere megjelenik a hozzászólásban (visszamenÅ‘legesen). WP-s érdeklÅ‘dÅ‘k errefelé nézegessenek. Figyelem! Csak az én kÃváncsiságom miatt, […]
” id=”comment-”>
” width=”40″ height=”40″ title=” Gravatar.Com” hspace=”5″ vspace=”5″ border=”0″ align=”right”>
Says:
comment_approved == ‘0′) : ?>
Your comment is awaiting moderation.
Aduh.. kok nggak nggak nongol setelah di pasang di comments.php. benar gitu caranya? plugin-nya udah di di aktifkan, lalu apa yang salah yah? emangnya di CSS theme file itu mau di tambah code apa sih??
[…] do you use on your blog and how do you rate them? Mine is below. Browser Sniff. Useful to humiliate Internet Explorer users out there . […]
Perfect
Works great.
[…] ful to catch spam. It checks for human input on comment submission. Captcha style. (8/10) BrowserSniff, pretty nice, but not that useful It detects web browser […]
Barusan Pasang
[…] what the f*ck you are doing. Code Shiira icon Update: (25-4-2005) My code is now official. Broswersniff 1.3
7 […]
Another great work man. Already using most of ur plugin for my blog. Keep up the good work.
What file in WP do I edit and ad the code:
pri_print_browser("Using ", "", true, 'on');to?Is it comments.php? Thanks in advance.
#52: yes, put it in comments.php if your theme has it
[…] … Lihat daftar plugins klik link masing2 lalu download… Yang pertama diaktifin Browser Sniff dari Priyadi, kedua plugin Yahoo/MSN Messenger Style Smi […]
cool stuff!
I’m a new wordpress and WordPress Browser Detection user!

and I don’t where to add EXACTLY ” pri_print_browser(”Using “, “”, true, ‘on’); ”
I am searching in the comments.php file but don’t know where to add it !
I’m using wordpress 1.5 with kubrick template.
Thank you very much for your help
#56: put it inside “foreach ($comments as $comment)” loop (it is the comment loop).
[…] uys, I always laughed LOL Which games did or do you play? I’ve finally installed browser detection plug-in by Priyadi. To answer this comment, it̵ […]
[…] s para permitir comentarios anidados (comentarios como respuesta a otros comentarios). […]
[…] s para permitir comentarios anidados (comentarios como respuesta a otros comentarios). […]
asik… akhirnya bisa juga mas scripts nya

thx yak
[…] upgrade this blog to WP1.5, mm.. agaknya sih males untuk upgrade tapi pas liat ada plugin Browser Sniff jadi pengen deh. Migrasi ke CSS base ternyata gampang2-s […]
Cool stuff