#37835 closed feature request (wontfix)
Add new function to return the current browser
Reported by: | xavortm | Owned by: | |
---|---|---|---|
Milestone: | Priority: | normal | |
Severity: | normal | Version: | |
Component: | General | Keywords: | |
Focuses: | Cc: |
Description
I couldn't find a previous ticket for this. I've often had to write some quick patching in my themes to detect what browser is the user using. PHP or JS/CSS it comes in handy knowing what the user uses. Any thoughts if this is a good addition to the core or?
I was thinking of something along the lines of wp_get_browser(); (there's get_browser() function, but its output is raw). If this new function can return pretty output of the browser type, version, etc. It can be quite handy :)
What I read on the php site - they say the get_browser() is too slow and there are other simpler solutions. I would love to see some feedback on this idea :)
Change History (5)
#3
@
8 years ago
@pross
Uh, that seems pretty legit reasoning to me ;/ It's not about being responsive, but about targeting different browsers. Even PHP-wise, using such function was needed to decide if certain widget had to be loaded. If the problem with caching is really the case here, then I guess this idea really won't work out well..
#4
follow-up:
↓ 5
@
8 years ago
- Milestone Awaiting Review deleted
- Resolution set to wontfix
- Status changed from new to closed
As @pross mentioned, using server-side functionality to target different clients is far from ideal. You should, if possible, use feature detection instead of client detection, for example with Modernizr.
Related: #33704.
Im sure this has come up before.
Using a PHP function to sniff out the users browser to change something visual on your theme is not guaranteed to work all the time as a very large percentage of users install a static cache as their first plugin which renders your function useless.
If you want your theme to be responsive to different browsers then use media queries or jQuery.
Just my 2c.