PHP Browser Detection

Описание

Version 3 adds support for is_tablet(), is_desktop(), and is_browser() as well as numerous bug fixes and code improvements. As of version 3.1.2 automatic updates of browscap.ini are disabeld until we can deal with memory usage issues.

PHP Browser Detection is a WordPress plugin used to detect a user’s browser. It can be used to send conditional CSS files for Internet Explorer, display different content or custom messages anywhere on the page, or to swap out Flash for an image for iPhones.

Template Tags:

Test for specific browsers:

$version is optional. Include a major version number, a single integer — 3,4,5, etc… Or leave it empty to test for any version.

Установка

Часто задаваемые вопросы

PHP Browser Detection is reporting the version of Chrome (or any pother browser) as «0.0»

This means the local cached copy of the browscap.ini user agent database is out of date. You can fix this by updating the file yourself manually, or wait for a new release of the plugin. To update the file, download the most recent version here: http://browscap.org/stream?q=PHP_BrowsCapINI and save it over the one bundled with the plugin php-browser-detection/cache/browscap.ini

I got a fatal error on activation. What gives?

This most likely means your web host is running a very old version of PHP. As of version 3.0, only PHP 5.3 and above are supported. You can ask your host to upgrade PHP for you.

Of course this can be used to provide different CSS for firefox, chrome, and ie/Edge browsers. But I'm also using it to distinguish between emulations of different generations of ie browsers. A super-useful plugin.