Support » Plugin: PHP Browser Detection » is_mobile() not working after upgrade to 2.2

Viewing 8 replies - 1 through 8 (of 8 total)
  • Yep, got the same problem. Any solutions yet?

    to fix this, search within “/wp-content/plugins/php-browser-detection/php-browser-detection.php”:

    and replace line 278:
    if(isset($browserInfo['ismobiledevice']) && $browserInfo['ismobiledevice'] == (bool) 1) {
    if(isset($browserInfo['ismobiledevice']) && $browserInfo['ismobiledevice'] == 'true') {

    I had the same problem and luckily came across this forum post. This was posted 3 months ago and fixes a really important function, yet no update is available – Pretty shoddy.

    I used this workaround/fix. Tested OK with Firefox OSX and Default Browser on Android. Thanks:)

    However, and this maybe a browscap or plugin problem, Firefox Android shows as desktop with the below code.

    <?php if(is_mobile()) {echo "Mobile";} else {echo "Desktop";} ?>

    As does Chrome Android.

    Hey guys. @fuchsws‘ fix looks correct. if you do:

    <?php var_dump( php_browser_info); ?>

    you’ll notice that ‘ismobiledevice’ is a string, not a bool, so the is_mobile() function is broken, I think. Rather than change the plugin code, I use the following to detect for mobile:

    <?php $browser_info = php_browser_info(); ?>
    <?php if ( $browser_info['ismobiledevice'] == 'false' ) : ?>

    { desktop browser-specific code }

    <?php endif; ?>

    As for @square_eyes‘ noticing false positives on Android, I have not tested the above on Android, but it would be great if next version of this script had Android detect functions (like ipad, ipod, and iphone).

    Plugin Author Mindshare Labs, Inc.


    Thanks for the bug reports and sorry for the delay between updates. This will be fixed in the next version.

    Great thanks!

Viewing 8 replies - 1 through 8 (of 8 total)
  • The topic ‘is_mobile() not working after upgrade to 2.2’ is closed to new replies.