Skip to content

Commit c3e182b

Browse files
vianaswmatticbot
authored andcommitted
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@22da8fe
1 parent 1d1f927 commit c3e182b

File tree

7 files changed

+527
-220
lines changed

7 files changed

+527
-220
lines changed

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
"type": "wordpress-plugin",
55
"license": "GPL-2.0-or-later",
66
"require": {
7-
"automattic/jetpack-device-detection": "^3.1.1"
7+
"automattic/jetpack-device-detection": "^3.2.0-alpha"
88
},
99
"require-dev": {
1010
"yoast/phpunit-polyfills": "^4.0.0",

composer.lock

Lines changed: 6 additions & 6 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

vendor/automattic/jetpack-device-detection/CHANGELOG.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,13 @@ All notable changes to this project will be documented in this file.
55
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/)
66
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
77

8+
## [3.2.0-alpha] - unreleased
9+
10+
This is an alpha version! The changes listed here are not final.
11+
12+
### Changed
13+
- Improved user agent string parsing functionality and added browser detection for six more browsers (Samsung Internet, UC, Yandex, Vivaldi, MIUI, Amazon Silk)
14+
815
## [3.1.1] - 2025-10-27
916
### Changed
1017
- Add missing bot agents to bot detection. [#45552]
@@ -256,6 +263,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
256263

257264
- Moving jetpack_is_mobile into a package
258265

266+
[3.2.0-alpha]: https://github.com/Automattic/jetpack-device-detection/compare/v3.1.1...v3.2.0-alpha
259267
[3.1.1]: https://github.com/Automattic/jetpack-device-detection/compare/v3.1.0...v3.1.1
260268
[3.1.0]: https://github.com/Automattic/jetpack-device-detection/compare/v3.0.9...v3.1.0
261269
[3.0.9]: https://github.com/Automattic/jetpack-device-detection/compare/v3.0.8...v3.0.9

vendor/automattic/jetpack-device-detection/composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@
3939
"link-template": "https://github.com/Automattic/jetpack-device-detection/compare/v${old}...v${new}"
4040
},
4141
"branch-alias": {
42-
"dev-trunk": "3.1.x-dev"
42+
"dev-trunk": "3.2.x-dev"
4343
}
4444
}
4545
}

0 commit comments

Comments
 (0)