Make WordPress Core

Opened 7 years ago

Closed 7 years ago

#41023 closed feature request (fixed)

Allow people to change wp_is_mobile logic though a filter

Reported by: presslabs's profile PressLabs Owned by: johnbillion's profile johnbillion
Milestone: 4.9 Priority: normal
Severity: normal Version:
Component: General Keywords: has-patch
Focuses: Cc:


Attachments (2)

patch.diff (269 bytes) - added by PressLabs 7 years ago.
41023.patch (495 bytes) - added by PressLabs 7 years ago.

Download all attachments as: .zip

Change History (6)

7 years ago

#1 @swissspidy
7 years ago

  • Keywords needs-patch added

Hey there,

This filter would need to be documented according to our PHP Documentation Standards.

Personally, I think people should rather use feature detection and progressive enhancement instead of using / relying upon wp_is_mobile().

7 years ago

#2 @PressLabs
7 years ago

  • Keywords needs-patch removed

I understand the skepticism regarding the subject, one should strive for making websites responsive, but this might not be the only application for this.

For example we have an external caching layer that automatically detects whether a request is coming from a desktop device or a mobile one. All is fine and good until you get to a point when Google recommends that device X should be considered a desktop device while other plugins that alter content might see it as a mobile one and lack a proper mechanism to alter their behavior.
The issue arises when when a uncached resource is requested, the contents of that page will depend on whether the first visitor was by the plugins perspective a mobile device or not, and not necessarily what we think we should be serving. This gets murky fast as some people might want to serve ads or any other content based on the target device.

Let me know if there is anything I could change to make this as standard as possible.

#3 @johnbillion
7 years ago

  • Keywords has-patch added
  • Milestone changed from Awaiting Review to 4.9
  • Version trunk deleted

Related: #33704

I don't think that efforts to reduce or remove usage of the function should be a reason to avoid introducing a new filter, though. +1 from me.

#4 @johnbillion
7 years ago

  • Owner set to johnbillion
  • Resolution set to fixed
  • Status changed from new to closed

In 40907:

General: Introduce a wp_is_mobile filter for controlling whether a request should be treated as coming from a mobile device.

Props PressLabs

Fixes #41023

Note: See TracTickets for help on using tickets.