Opened 12 years ago
Closed 9 years ago
#24541 closed defect (bug) (wontfix)
wp_is_mobile() includes tablets
Reported by: | 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)
#3
follow-up:
↓ 5
@
12 years ago
Yes, I think that MODERNIZR should become a part of WordPress instead :)
#4
@
12 years ago
- Component changed from General to Administration
- Version changed from trunk to 3.4
#5
in reply to:
↑ 3
@
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()
.
#7
@
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
@
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 withis_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.
#12
@
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.
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 withis_touch_device()
.