UserAgent-Spy Wordpress Plugin (English)
Description
UserAgent-Spy is a WordPress plugin which displays the user’s Operative System and Web Browser in the comments. It uses the comment->agent property to access the UserAgent string, and through a series of regular expresions, detects the O.S. and browser. Then it shows a message with an icon of the browser and O.S.
The plugin was re-written on version 1.0rc1. That’s release candidate 1. It’s arrived to a point where it does everything I wanted it to do, and the code was arranged so that adding new browsers, operative systems and devices is much easier now. Your feedback is very important, new features have been added by request, so if there’s something you would like to see in UA-Spy, leave a comment, and I’ll see what I can do.
UserAgent Spy was written with Emacs – http://www.gnu.org/software/emacs/
Images created with The Gimp – http://www.gimp.org/
Screenshot:

UserAgent Spy on WordPress 2.6 default theme
Installation:
- Upload useragent-spy folder to /wp-contents/plugins/
- Login to your WordPress Admin menu, go to Plugins, and activate it.
- In your WordPress Admin menu, you will find a new menu under Settings called UserAgent Spy. There you can choose the displayed icons size, and select where to display the plugin. There are three options for displaying the plugin:
- Before the comment text. User’s WebBrowser and OS will be displayed before comment text.
- After the comment text.User’s WebBrowser and OS will be displayed after comment text.
- Custom (Advanced). You can specify the location using the useragent_spy_custom() function inside the comments loop in your template (Generally in comments.php).
Example:
<?php foreach ($comments as $comment) : ?>
<cite><?php comment_author_link() ?></cite> <?php useragent_spy_custom(); ?> says:<br />
<?php comment_text() ?>
CAUTION: If you select “Custom” and don’t use <?php useragent_spy_custom(); ?> in your template, you won’t get the information displayed.
Features (Check Release Notes below to see new features being added)
- Detects most popular web browsers and Operative Systems (It’s a work in progress, many more browsers/o.s. ’s to come)
- Shows browser icon, name, and a link to the browser’s homepage (this will be customizable in future versions).
- Shows browser/os in the comments management page (unless using “custom” option).
- Customizable, has its own Options Page where you can change the size of the browser/o.s. icon, and where you want it to be displayed.
- Published under GPLv3
Some of you may compare this to another well-known plugin named browsersniff. UserAgent-Spy is written completelly from scratch, with several improvements over browsersniff:
- Easy standard installation, just upload to wp-plugins and activate it.
- Customizable options.
- No basic knowledge of PHP or editing WordPress templates required
- Published under GPLv3.
Release Notes
1.0
* Added BonEcho, fixed some minor stuff on code. Ready to release version 1.0!
1.0rc2
* Added web browsers: Fennec, Swiftfox, K-Meleon, Shiira, Midori, Sunrise, Wyzo, Songbird, Dillo, Omniweb.
1.0rc1
* Rewrote entire code. Now easier to manage and add new stuff. Focused on adding devices detection such as cellphones and other internet-able platforms. Code is way more efficient, I think…
* Fixed options page for WordPress 2.7 (register options and stuff)
* Added CentOs operative system.
* If all goes well, version 1.0 final will be released soon
.
0.7.2
* Added SymbianOS
0.7.1
* Fixed some path bugs
* Added null.png images for undetected OS
0.7
* Added trackback detection for WordPress, Pligg, Meneame, and some more. Some new options are included in the Admin page.
* Fixed bug with OpenId plugin, thanks to Gonzalo (http://gon.sociallinux.org/)
0.6
* Added browser version detection.
* Added Windows versions: Windows 7, Vista, XP, 2000, ME, NT 4, NT, 98, CE – Dedicated to www.elfrancotirador.cl
* Rewrote IE version detection (sorry Albertux
).
* Added browsers: Kazehakase, Sleipnir.
0.5.4
* Added Gran Paradiso.
* Added Zenwalk GNU/Linux.
* Fixed missing iPhone image on 24×24, added new cool one.
* Finally fixed (hopefully) Google Chrome’s detection bug. Unhappy word to use, “chrome”…
0.5.3.2
* Fixed even dumber bug, caused by the rush of getting last bug fixed…
0.5.3.1
* Fixed dumb bug which broke the whole plugin. Thanks to webmaster@illi.com.
0.5.3
* Fixed bug where Google Chrome was detected when ‘chrome’ was in the UserAgent string.
* Added IE version detection by Albertux (http://albertux.ayalasoft.com/)
0.5.2
* Fixed bug for automatic update installation where it deleted the images directory
* Renamed variables, they were pretty generic so they could conflict with others.
0.5.1
* Added Google Chrome (the day of its release!)
0.5
* Option to show complete useragent string.
* Went back to useragent_spy_custom() for custom display.
* Several code fixes (W3C valid XHTML, more order, etc).
* Saved settings are displayed correctly on the settings page.
* Added option to display icons only, with no text or link.
* Fixed bugs:
-Epiphany, when built against WebKit would display Safari.
-Major bug which would show ua-spy in your comment management page, instead of comment text when using custom.
0.4.2
* Browser added: Lynx, Links.
* Fixed bug where the comments would show without filters.
* Changed Konqueror icon for new 4.0 version.
0.4.1
* OS added: OLPC XO, SuSE
* Browser added: W3M, Lobo, Amaya, Maxthon, Camino, NetSurf, Minefield, IceApe, SeaMonkey
* Fixed some code (includes a bug where OLPC was detected for certain os’s)
0.4
* Made “browsing with” and “on” words in “Browsing with browser on OS” customizable in the Options page.
* Allow logged in user to see the full user-agent string (easier debugging).
* Fixed string for unidentified browser.
* OS’s added: FreeBSD, OpenBSD, Solaris.
0.3.1
* Added <p> tags for correct formatting
* Added “if” at the options page so that current values are selected on load.
0.3
* More web-browsers: Epiphany, Galeon, Opera, IE.
* O.S.’s: Xubuntu, Kubuntu, Ubuntu, Slackware.
* Added option to choose displaying useragent_spy before or after the comment text, or using useragent_spy() function in template.
0.2
* Detects Firefox, Epiphany.
* Detects Debian, Fedora, Gentoo,
* Options menu under Settings Panel, allows 16×16 or 24×24 pixel images for icon size.
* Integrates into Wordpress before comments text.
0.1
* Detects Mozilla, IceWeasel, IceCat, Arora, Safari, Konqueror.
* Detects Windows, GNU/Linux, iPhone and MacOS
TO-DO:
* Allow users to modify links for each browser/OS.
* New browsers/os’s are welcome.
* Browser versions.
* Links for Operative Systems.

Creative Commons Attribution-Share Alike 3.0 Unported License
Los contenidos de éste sitio se encuentran publicados bajo
Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.0.1) Gecko/2008071618 Iceweasel/3.0.1 (Debian-3.0.1-1)
You can see the plugin at work right here!
Mozilla/5.0 (X11; U; Linux i686; es-AR; rv:1.9.0.1) Gecko/2008072820 Firefox/3.0.1
Just trying it on Firefox / Ubuntu Linux
Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.0) Gecko/2008061600 SUSE/3.0-0.2 Firefox/3.0
mmmm, nice work
Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.8.1.16) Gecko/20080718 Kubuntu/8.04 (hardy) Firefox/2.0.0.16
I’m a Broswer Sniff user; just testing my Kubuntu/Firefox UA with UA-Spy. I think Browser Sniff uses a lot of memory, so I’m always open to something more lightweight!
Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.0.1) Gecko/2008071618 Iceweasel/3.0.1 (Debian-3.0.1-1)
Chip:
Hope you like UA-Spy. I’m really open for feature requests, ideas, and opinions.
Tell me if you made the switch!
Regards
Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.8.1.16) Gecko/20080718 Kubuntu/8.04 (hardy) Firefox/2.0.0.16
Hola Fernando!
One thing I would *really* like to see, is the ability to display *only* the icons (that is, no text, just icons).
That feature alone would get me to switch in a heartbeat!
I’ve installed the plugin, but haven’t had time to play around with it yet. I’ll try it out shortly, though.
Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.8.1.16) Gecko/20080718 Kubuntu/8.04 (hardy) Firefox/2.0.0.16
Hola Fernando,
I’m trying out the plugin, but have two issues:
1) The images are not displaying. I have the icon size set to 16, but the SRC string being printed by the function is 40 – that is, the function returns an image SRC like *siteurl*/plugins/useragent-spy/image/40/net/firefox.png – and of course, the /image/40/ directory doesn’t exist.
I can’t find anything in the plugin or options files that would be causing this behavior.
(Side note: reading through the code in the plugin’s PHP file, there is a comment that useragent_spy_custom() is deprecated, and that useragent_spy() should be used instead. Your instructions still indicate to use the former function. Both seem to work identically. Which is correct?)
2) Can you add an option *not* to display the full UA string in the comment when logged in as administrator? It breaks my comment layout. (Perhaps add it as hover text, instead?)
Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.8.1.16) Gecko/20080718 Kubuntu/8.04 (hardy) Firefox/2.0.0.16
Another update – I have it working, but with a couple of ugly-hack fixes:
1) I have copied the 16px icons into a “40″ directory, in order to make the SRC printed by the function to be valid.
(Please take a look at the source for one of my posts with comments, in order to see what I’m talking about on this one.)
2) I have commented out the line that prints the UA string if logged in as administrator.
Another thing (though I notice it is commented as “TO DO”) – saved settings are not displayed on the settings page.
Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.0.1) Gecko/2008071618 Iceweasel/3.0.1 (Debian-3.0.1-1)
Chip:
I’m rolling out 0.5 version of UserAgent-Spy today. It’s a major update, with several fixes, including the option to not display full UA string among others.
I’ll update this page as soon as it’s up.
Thanks for your feedback, the ability to display *only* the icons has been implemented!
Regards
Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.0.1) Gecko/2008071618 Iceweasel/3.0.1 (Debian-3.0.1-1)
Version 0.5 is out, with some major changes
Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.8.1.16) Gecko/20080718 Kubuntu/8.04 (hardy) Firefox/2.0.0.16
I just updated to Version 0.5; great stuff!
I still have the issue, though, of the plugin trying to set the icon IMG SRC as /plugins/useragent-spy/image/40/ directory, when it should be /plugins/useragent-spy/image/16/ (I have the icon size option set to 16.)
Any clue what might be causing that?
Otherwise, everything is great! It displays exactly the way I’ve been wanting it to!
Thanks!
Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.8.1.16) Gecko/20080718 Kubuntu/8.04 (hardy) Firefox/2.0.0.16
Fernando,
Still trying to figure out why UA Spy seems to think that I’m setting the icon size to “40″.
Could it be an issue with the global variable $size? Could something else (perhaps another plugin?) be using the same global variable?
I might try more ugly hacking, and change $size to $uasize, or something, and see if the correct icon size setting gets passed to the function.
Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.8.1.16) Gecko/20080718 Kubuntu/8.04 (hardy) Firefox/2.0.0.16
Fernando,
Changing $size to $uasize seems to have worked.
Now, when I have the setting at “16″, the function correctly links to the 16px icon directory (likewise with the “24″ setting).
(By the way, those 24px icons are gorgeous!)
Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.0.1) Gecko/2008071618 Iceweasel/3.0.1 (Debian-3.0.1-1)
Chip:
Thanks a lot.
I’ll change the name of the variable for future releases, as it’s pretty generic, and the same problem could happen again. That was my bad. I’ll commit 0.5.1 with that fix, and anyother bug that comes up these days.
Glad you liked the new stuff. Your idea of displaying icons only was great, I’m using it on my blog as well as you can see.
Mozilla/5.0 (Windows; U; Windows NT 6.0; en-US) AppleWebKit/525.13 (KHTML, like Gecko) Chrome/0.2.149.27 Safari/525.13
Google Chrome, Google’s browser, was just released – it would be nice to see this plugin dectecting it too.
Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.0.1) Gecko/2008071618 Iceweasel/3.0.1 (Debian-3.0.1-1)
giovanealex:
Check for an update tonight.
I’ll upload a new version with Chrome detection.
Regards
Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.0.1) Gecko/2008071618 Iceweasel/3.0.1 (Debian-3.0.1-1)
Done, the plugin now detects Google Chrome.
Your WordPress should ask you to update the plugin soon, since it was just uploaded.
Opera/9.52 (X11; Linux i686; U; en)
La version 0.5.1 no contiene imagenes ( el “upgrade automatic” borra la carpeta img/ )
solo basta copiar la carpeta img de la version anterior
Saludos
Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.0.1) Gecko/2008071618 Iceweasel/3.0.1 (Debian-3.0.1-1)
Gracias albertux, ya está arriba la versión 0.5.2, con ese bug y otro fix arreglados.
Saludos
Mozilla/5.0 (X11; U; Linux i686; it-IT; rv:1.9.0.1) Gecko/2008071611 Iceweasel/3.0.1
Thank you! It works as a charm!
Mozilla/5.0 (X11; U; Linux i686; it-IT; rv:1.9.0.1) Gecko/2008071611 Iceweasel/3.0.1
Tried to switch user-agent. Delete this comment if you wish.
Mozilla/5.0 (X11; U; Linux i686; it-IT; rv:1.9.0.1) Gecko/2008071611 Iceweasel/3.0.1 (Kubuntu/8.04.1 hardy)
Trying with Kubuntu.
Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9b5) Gecko/2008032620 Firefox/3.0b5
Nice work! So easy to install unlike the other plug in that I saw awhile ago. However, I hope you could make it more specific. Meaning what version of browser (eg: Mozilla Firefox 3.0, Internet Explorer 7.0, etc etc.) And what version of OS (eg: Windows XP, Windows Vista, etc etc.)
Just like in this plug in: http://priyadi.net/archives/2005/03/29/wordpress-browser-detection-plugin/
Too bad, the author of that plug in didn’t make easier installation as you did.
Also, please make the icons transparent. It looks awkward on my black background when using Internet Explorer.
Thank you so much.
Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.0.1) Gecko/2008071618 Iceweasel/3.0.1 (Debian-3.0.1-1)
kirksydney:
Version numbers will be included in a future release. As soon as I get the time to implement it.
The icons ARE transparent, they are transparent PNG. Internet Explorer doesn’t support transparency for PNGs on version 6, which pretty much sucks, so you just shouldn’t use Internet Explorer, for your own good. And for everyone else’s good. Update your browser.
Thanks!
Regards
Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9b5) Gecko/2008032620 Firefox/3.0b5
I hope that “future release” would be anytime soon. Thank you for replying and for this awesome plug in. Looking forward to that update. More power.
By the way, why am i getting this on my previous comments:
Using [Unidentified browser (yet)] Unidentified browser (yet) on [Unknown O.S.] Unknown O.S.
Example link: http://kirksydney.com/2008/09/ang-epektibong-suob/
Please take a look at it.
Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9b5) Gecko/2008032620 Firefox/3.0b5
Hi,
What I did instead was I assigned Firefox and Windows as the default browser and OS so I got my problem resolved.
I hope the version numbers coming out very soon, though. ;D
Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8) Gecko/20051111 Firefox/1.5
Just revisiting here to say that I appreciate the little update you did. Although the changes that I can only see is the Internet Explorer version numbers. Hope you could do the same with the rest of the browsers, and with the Operating Systems as well. Thank you so much.
Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.0.3) Gecko/2008092816 Iceweasel/3.0.3 (Debian-3.0.3-3)
kirksydney:
Great decision to make Firefox your default web browser.
Other browsers and O.S.’s versions will be included too. I just need some time to dedicate to my other WordPress Plugin which hasn’t been updated for a while.
Thanks for using UserAgent-Spy.
Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8) Gecko/20051111 Firefox/1.5
Great! I’ll look forward to that.
Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.8.1.18) Gecko/20081113 Kubuntu/8.04 (hardy) Firefox/2.0.0.18
Fernando,
I’m still loving this plugin; thanks again for your great work.
I just updated to WP 2.7, but haven’t yet implemented the new commenting features. One of the main reasons is that I’m unsure how to incorporate your plugin into the new wp_list_comments function.
Any thoughts/ideas? Do you have UA-spy working with wp_list_comments in WP 2.7?
Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.0.3) Gecko/2008092921 IceCat/3.0.3-g1 Debian GNU/Linux
Chip:
I haven’t yet updated the plugin to be compatible with the new version of comments. Apparently there’s some new work to do to support the new threaded comments.
That’s one of the reasons why I haven’t yet updated my blog to WP 2.7.
But I’ll get to it any time soon.
Regards
Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.0.5) Gecko/2008121810 Gentoo Firefox/3.0.5
nice plugin fernando, better if it support x/html & accessibility too
Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.0.3) Gecko/2008092921 IceCat/3.0.3-g1 Debian GNU/Linux
dani:
I’ve already fixed support for xhtml on version 0.6, I think it’s working fine now. What do you mean by accesibility?
Regards
Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.0.5) Gecko/2008122011 Iceweasel/3.0.5 (Debian-3.0.5-1)
Hello Fernando, I really like this plugin, and I really appreciate that you took the time to write it, but unfortunately it does not work with WP 2.7, so I am unable to use it. Are you planning on trying to fix it, or is this now a dead project?
Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.0.5) Gecko/2008122316 IceCat/3.0.5-g1 Debian GNU/Linux
Igneous:
This project is far from abandoned. I just haven’t had the time to make it work with WordPress 2.7. It’s really demotivating, since a lot was changed in 2.7, but I’ll get to it soon.
Glad you like the plugin, I’ll try to get it to work with new WordPress.
Regards
Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.0.5) Gecko/2008122011 Iceweasel/3.0.5 (Debian-3.0.5-1)
Fernando: Thank you! I would be greatly endebted to you if you were to get it working with WP 2.7. Also, if you ever need a beta tester before you take it public, be sure to send me an email, I’d be more than happy to help
Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.0.6) Gecko/2009011912 Firefox/3.0.6
Really nice plugin! I like it very much, thanks!
But I’m also curious about support for CentOS recognition, I found it not working on my site (using a CentOS from my university).
Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.0.6) Gecko/2009011912 Firefox/3.0.6
Back to previous comment:
The user-agent string for CentOS (that was not recognized) was like:
Mozilla/5.0 (compatible; Konqueror/3.5; Linux) KHTML/3.5.4 (like Gecko) CentOS/3.5.4-13.el5.centos
Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.0.5) Gecko/2008122316 IceCat/3.0.5-g1 Debian GNU/Linux
New version is out: 1.0rc1. That’s release candidate 1. If everything works fine, version 1.0 final won’t be too far away.
CentOS detection included.
Still needing to port it to WP 2.7 thought, that’s the next milestone on my book…
Regards!
Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.0.5) Gecko/2008122316 IceCat/3.0.5-g1 Debian GNU/Linux
Version 1.0rc2 is out. Working perfectly on WordPress 2.7.1 (this blog)…
Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.8.1.14) Gecko/20080611 BonEcho/2.0.0.14
Nice work, Fernando!
..now testing from Bon Echo.
Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.0.7) Gecko/2009031406 IceCat/3.0.7-g1 Debian
Thanks V-Teq, BonEcho being detected and shown with its logo…
By the way, you should update your browser!
Regards
Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.0.10) Gecko/2009050214 Gentoo Firefox/3.0.10
fernando,
it sounds ugly if screen reader/voice browser users must hear the inline UA string too.
Mozilla/5.0 (X11; U; Linux i686 (x86_64); en-US) AppleWebKit/531.0 (KHTML, like Gecko) Chrome/3.0.183.1 Safari/531.0
Just testing Google Chrome 3 (unstable) for Linux.