Commit c3e182b
Update user agent info capabilities (#45632)
* Add user_agent optional param to static methods
* Pass useragent to static methods
Pass down the user agent in the methods get_browser, get_platform and
get_desktop_platform. Another step in the direction of being able to use
this class to parse user agent strings and not just the value set on
$_SERVER['HTTP_USER_AGENT']
* Use useragent in is_tablet method
* Add detection for 6 popular browsers
We can now detect 6 additional popular browsers that were previously
classified as "other":
- Samsung Internet (default on Samsung devices)
- UC Browser (popular in Asia)
- Yandex Browser (popular in Russia)
- Vivaldi (power users)
- MIUI Browser (Xiaomi devices)
- Amazon Silk (Kindle/Fire devices)
Updated the detection order to check for Chromium-based browsers BEFORE
checking for Chrome itself. This is critical because Samsung, Yandex,
Vivaldi, UC, MIUI, and Silk all include "Chrome" in their user agent
strings.
Updated is_edge_browser() to detect both:
- Legacy Edge: "Edge/"
- Modern Chromium-based Edge: "Edg/"
* Update tests for the new browsers detected
* changelog
* Explicitly test for bacwkard compatibility
Added tests to make sure we fall back to $_SERVER['HTTP_USER_AGENT']
when $user_agent is not passed.
* Add a new private maybe_get_user_agent_from_server method
This is done so that we don't repeat outself so much
---------
Co-authored-by: Enej Bajgoric <[email protected]>
Committed via a GitHub action: https://github.com/Automattic/jetpack/actions/runs/18877951594
Upstream-Ref: Automattic/jetpack@22da8fe1 parent 1d1f927 commit c3e182b
File tree
7 files changed
+527
-220
lines changed- vendor
- automattic/jetpack-device-detection
- src
- composer
7 files changed
+527
-220
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
4 | 4 | | |
5 | 5 | | |
6 | 6 | | |
7 | | - | |
| 7 | + | |
8 | 8 | | |
9 | 9 | | |
10 | 10 | | |
| |||
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
5 | 5 | | |
6 | 6 | | |
7 | 7 | | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
8 | 15 | | |
9 | 16 | | |
10 | 17 | | |
| |||
256 | 263 | | |
257 | 264 | | |
258 | 265 | | |
| 266 | + | |
259 | 267 | | |
260 | 268 | | |
261 | 269 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
39 | 39 | | |
40 | 40 | | |
41 | 41 | | |
42 | | - | |
| 42 | + | |
43 | 43 | | |
44 | 44 | | |
45 | 45 | | |
0 commit comments