Make WordPress Core

Opened 5 years ago

Closed 6 months ago

#21667 closed enhancement (wontfix)

Add some user agent to wp_is_mobile

Reported by: inpixelitrust Owned by: stevenkword
Milestone: Priority: normal
Severity: normal Version: 3.4.1
Component: General Keywords: dev-feedback has-patch needs-unit-tests
Focuses: Cc:



I've run some test with the help of the twitter/G+ community on wp_is_mobile and found some mobile browser that don't pass the test.

You can see the test here : http://www.inpixelitrust.fr/blog/wp_is_mobile/

I was able to get the user agent of 3 of those which don't work :

HTC sensation z710 4.0.3 native browser (UA: Mozilla/5.0 (X11;Linux x86_64; HTC/Sensation/; fr-de)
AplliWebkit/534.24(KHTML,like Gecko) Chrome/11.0.696.32 Safari/534.34 )

BlackBerry Playbook (Ua Mozilla/5.0 (PlayBook; U; RIM Tablet OS 2.0.1; en-US) AplleWebkit/535.8+ (KHTML, like Gecko) Version/ Safari/535.8+ )

Could be great to add those to the UA sniffing :)

Attachments (1)

21667.diff (2.9 KB) - added by Mte90 23 months ago.
regex based on detectmobilebrowsers.com

Download all attachments as: .zip

Change History (12)

#1 @inpixelitrust
5 years ago

  • Summary changed from Addd some user agent to wp_is_mobile to Add some user agent to wp_is_mobile

#2 @SergeyBiryukov
5 years ago

  • Component changed from Template to Administration
  • Type changed from feature request to enhancement

#4 @ocean90
4 years ago

  • Component changed from Administration to General

23 months ago

regex based on detectmobilebrowsers.com

#6 @Mte90
23 months ago

  • Keywords has-patch added

Now use the detectmobilebrowsers.com regex that is more powerful but is not updated from 2014 but surely is better that the actual solution.

This ticket was mentioned in Slack in #core by chriscct7. View the logs.

23 months ago

#8 @stevenkword
23 months ago

  • Keywords needs-unit-tests added
  • Owner set to stevenkword
  • Status changed from new to assigned

#9 @swissspidy
20 months ago

The patch looks reasonable, but a bit more complex.

In general I wouldn't recommend doing UA sniffing. Should we really further encourage a bad practice? Core uses wp_is_mobile() only in a few places, mostly for historical reasons where touch devices were not considered before.

#10 @Mte90
20 months ago

There are many themes that use this function and also plugin.
I know that the patch contain a complex regex but recognize the majority of mobile os.
Maybe we can choose to use a different regex more light.

#11 @johnbillion
6 months ago

  • Milestone Awaiting Review deleted
  • Resolution set to wontfix
  • Status changed from assigned to closed

I'm going to wontfix this based on #33704 (removing reliance on wp_is_mobile()) and [40907] (introduce a filter on the return value of the function).

Note: See TracTickets for help on using tickets.