WordPress.org

Make WordPress Core

Opened 11 months ago

Last modified 3 months ago

#24541 new defect (bug)

wp_is_mobile() includes tablets

Reported by: Looimaster Owned by:
Milestone: Awaiting Review Priority: normal
Severity: normal Version: 3.4
Component: General Keywords: 2nd-opinion
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 (11)

comment:1 follow-up: johnbillion10 months 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().

comment:3 follow-up: Looimaster10 months ago

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

comment:4 SergeyBiryukov10 months ago

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

comment:5 in reply to: ↑ 3 webord6 months 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().

comment:6 johnbillion5 months ago

#26215 was marked as a duplicate.

comment:7 johnbillion5 months 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.

comment:8 in reply to: ↑ 1 celloexpressions5 months 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.

comment:9 Frank Klein5 months ago

  • Cc contact@… added

comment:10 dimadin5 months ago

  • Cc forumi@… added

comment:11 ocean903 months ago

  • Component changed from Administration to General
Note: See TracTickets for help on using tickets.