Make WordPress Core

Opened 12 years ago

Closed 9 years ago

#24541 closed defect (bug) (wontfix)

wp_is_mobile() includes tablets

Reported by: looimaster's profile Looimaster Owned by:
Milestone: Priority: normal
Severity: normal Version: 3.4
Component: General Keywords:
Focuses: Cc:

Description

Android tablets have "Android" in user agent and Android mobile phones have "Android" and "Mobile". I use this to distinguish what is tablet and what is a mobile phone.

http://core.trac.wordpress.org/browser/tags/3.5.1/wp-includes/vars.php

Change History (13)

#1 follow-up: @johnbillion
12 years ago

  • Keywords 2nd-opinion added

This is expected behaviour. Or rather, in core this is what it expects anyway.

In core, wp_is_mobile() is used as a synonym for "is a touch device". It's used to un-hide various links that are only shown on mouseover for non-touch devices, by adding a 'mobile' class to the body.

These days it would probably better to do this client-side with JavaScript (testing for the touch event) rather than applying the CSS class server-side.

The difference between a mobile device and a non-mobile device is much less clear than it was in the past. Maybe wp_is_mobile() needs to be deprecated and replaced with is_touch_device().

#3 follow-up: @Looimaster
12 years ago

Yes, I think that MODERNIZR should become a part of WordPress instead :)

#4 @SergeyBiryukov
12 years ago

  • Component changed from General to Administration
  • Version changed from trunk to 3.4

#5 in reply to: ↑ 3 @webord
11 years ago

Replying to Looimaster:

Yes, I think that MODERNIZR should become a part of WordPress instead :)

Question, I can't see Modernizr been used the way is_wp_mobile().

#6 @johnbillion
11 years ago

#26215 was marked as a duplicate.

#7 @johnbillion
11 years ago

#26215 was marked as a dupe but has a patch. Note my first comment on this ticket that talks about expected behaviour and client-side detection.

#8 in reply to: ↑ 1 @celloexpressions
11 years ago

Replying to johnbillion:

In core, wp_is_mobile() is used as a synonym for "is a touch device". It's used to un-hide various links that are only shown on mouseover for non-touch devices, by adding a 'mobile' class to the body.

The difference between a mobile device and a non-mobile device is much less clear than it was in the past. Maybe wp_is_mobile() needs to be deprecated and replaced with is_touch_device().

+1. Most Windows devices are now touch-enabled by default, so an increasingly large percentage of laptop and desktop users need touch-friendly components now.

#9 @Frank Klein
11 years ago

  • Cc contact@… added

#10 @dimadin
11 years ago

  • Cc forumi@… added

#11 @ocean90
11 years ago

  • Component changed from Administration to General

#12 @swissspidy
9 years ago

  • Keywords close added; 2nd-opinion removed

The function description of wp_is_mobile() is very clear:

Test if the current browser runs on a mobile device (smart phone, tablet, etc.)

Generally speaking, user-agent sniffing is considered bad practice and should be avoided whenever possible. On the client side, there are great libraries like Modernizr which you can use to test for availability of individual features, not browsers.

#13 @SergeyBiryukov
9 years ago

  • Keywords close removed
  • Milestone Awaiting Review deleted
  • Resolution set to wontfix
  • Status changed from new to closed
Note: See TracTickets for help on using tickets.