Skip to content

Commit 7b035a1

Browse files
committed
Ready to release 4.2.0.
1 parent 58f62e3 commit 7b035a1

25 files changed

+4137
-1116
lines changed

CHANGELOG.md

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,25 @@ All notable changes to **Device Detector** are documented in this *changelog*.
33

44
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and **Device Detector** adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
55

6+
## [4.2.0] - 2024-11-22
7+
8+
### Added
9+
- Compatibility with WordPress 6.7.
10+
11+
### Changed
12+
- Upgraded UDD from version 6.3.2 to version 6.4.1: dozens of added and improved detections.
13+
- Ability to self-update from Github.
14+
- The plugin user agent is now more consistent and "standard".
15+
16+
### Fixed
17+
- There's a WordPress core "feature" which causes some PII to leak (to wp.org) during plugin and theme updates. This is no more the case for this plugin.
18+
- In some cases, a WordPress notice can be triggered concerning the loading sequence of translations.
19+
20+
### Removed
21+
- Test site launching from wordpress.org plugin page.
22+
- All Databeam hooks and libraries, as the Databeam project is abandoned.
23+
- Dependency on wp.org for updates.
24+
625
## [4.1.0] - 2024-09-10
726

827
### Added

device-detector.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
* Plugin Name: Device Detector
1111
* Plugin URI: https://perfops.one/device-detector
1212
* Description: Full featured analytics reporting and management tool that detects all devices accessing your WordPress site.
13-
* Version: 4.1.0
13+
* Version: 4.2.0
1414
* Requires at least: 6.2
1515
* Requires PHP: 8.1
1616
* Author: Pierre Lannoy / PerfOps One

includes/libraries/class-libraries.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ public static function init() {
6262
'name' => 'Universal Device Detection',
6363
'prefix' => 'UDD',
6464
'base' => PODD_VENDOR_DIR . 'udd/',
65-
'version' => '6.3.1',
65+
'version' => '6.4.1',
6666
// phpcs:ignore
6767
'author' => 'Matomo Analytics',
6868
'url' => 'https://github.com/matomo-org/device-detector',

includes/libraries/udd/ClientHints.php

Lines changed: 33 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,13 @@ class ClientHints
7676
*/
7777
protected $app = '';
7878

79+
/**
80+
* Represents `Sec-CH-UA-Form-Factors` header field: form factor device type name
81+
*
82+
* @var array
83+
*/
84+
protected $formFactors = [];
85+
7986
/**
8087
* Constructor
8188
*
@@ -88,8 +95,9 @@ class ClientHints
8895
* @param string $architecture `Sec-CH-UA-Arch` header field
8996
* @param string $bitness `Sec-CH-UA-Bitness`
9097
* @param string $app `HTTP_X-REQUESTED-WITH`
98+
* @param array $formFactors `Sec-CH-UA-Form-Factors` header field
9199
*/
92-
public function __construct(string $model = '', string $platform = '', string $platformVersion = '', string $uaFullVersion = '', array $fullVersionList = [], bool $mobile = false, string $architecture = '', string $bitness = '', string $app = '') // phpcs:ignore Generic.Files.LineLength
100+
public function __construct(string $model = '', string $platform = '', string $platformVersion = '', string $uaFullVersion = '', array $fullVersionList = [], bool $mobile = false, string $architecture = '', string $bitness = '', string $app = '', array $formFactors = []) // phpcs:ignore Generic.Files.LineLength
93101
{
94102
$this->model = $model;
95103
$this->platform = $platform;
@@ -100,6 +108,7 @@ public function __construct(string $model = '', string $platform = '', string $p
100108
$this->architecture = $architecture;
101109
$this->bitness = $bitness;
102110
$this->app = $app;
111+
$this->formFactors = $formFactors;
103112
}
104113

105114
/**
@@ -224,6 +233,16 @@ public function getApp(): string
224233
return $this->app;
225234
}
226235

236+
/**
237+
* Returns the formFactor device type name
238+
*
239+
* @return array
240+
*/
241+
public function getFormFactors(): array
242+
{
243+
return $this->formFactors;
244+
}
245+
227246
/**
228247
* Factory method to easily instantiate this class using an array containing all available (client hint) headers
229248
*
@@ -237,6 +256,7 @@ public static function factory(array $headers): ClientHints
237256
$app = '';
238257
$mobile = false;
239258
$fullVersionList = [];
259+
$formFactors = [];
240260

241261
foreach ($headers as $name => $value) {
242262
switch (\str_replace('_', '-', \strtolower((string) $name))) {
@@ -319,6 +339,16 @@ public static function factory(array $headers): ClientHints
319339
$app = $value;
320340
}
321341

342+
break;
343+
case 'formfactors':
344+
case 'http-sec-ch-ua-form-factors':
345+
case 'sec-ch-ua-form-factors':
346+
if (\is_array($value)) {
347+
$formFactors = \array_map('\strtolower', $value);
348+
} elseif (\preg_match_all('~"([a-z]+)"~i', \strtolower($value), $matches)) {
349+
$formFactors = $matches[1];
350+
}
351+
322352
break;
323353
}
324354
}
@@ -332,7 +362,8 @@ public static function factory(array $headers): ClientHints
332362
$mobile,
333363
$architecture,
334364
$bitness,
335-
$app
365+
$app,
366+
$formFactors
336367
);
337368
}
338369
}

includes/libraries/udd/DeviceDetector.php

Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ class DeviceDetector
6868
/**
6969
* Current version number of DeviceDetector
7070
*/
71-
public const VERSION = '6.3.2';
71+
public const VERSION = '6.4.1';
7272

7373
/**
7474
* Constant used as value for unknown browser / os
@@ -1039,6 +1039,27 @@ protected function parseDevice(): void
10391039
$this->device = AbstractDeviceParser::DEVICE_TYPE_TABLET;
10401040
}
10411041

1042+
/**
1043+
* All devices running Puffin Secure Browser that contain letter 'D' are assumed to be desktops
1044+
*/
1045+
if (null === $this->device && $this->matchUserAgent('Puffin/(?:\d+[.\d]+)[LMW]D')) {
1046+
$this->device = AbstractDeviceParser::DEVICE_TYPE_DESKTOP;
1047+
}
1048+
1049+
/**
1050+
* All devices running Puffin Web Browser that contain letter 'P' are assumed to be smartphones
1051+
*/
1052+
if (null === $this->device && $this->matchUserAgent('Puffin/(?:\d+[.\d]+)[AIFLW]P')) {
1053+
$this->device = AbstractDeviceParser::DEVICE_TYPE_SMARTPHONE;
1054+
}
1055+
1056+
/**
1057+
* All devices running Puffin Web Browser that contain letter 'T' are assumed to be tablets
1058+
*/
1059+
if (null === $this->device && $this->matchUserAgent('Puffin/(?:\d+[.\d]+)[AILW]T')) {
1060+
$this->device = AbstractDeviceParser::DEVICE_TYPE_TABLET;
1061+
}
1062+
10421063
/**
10431064
* All devices running Opera TV Store are assumed to be a tv
10441065
*/
@@ -1049,7 +1070,7 @@ protected function parseDevice(): void
10491070
/**
10501071
* All devices that contain Andr0id in string are assumed to be a tv
10511072
*/
1052-
if ($this->matchUserAgent('Andr0id|(?:Android(?: UHD)?|Google) TV|\(lite\) TV|BRAVIA')) {
1073+
if ($this->matchUserAgent('Andr0id|(?:Android(?: UHD)?|Google) TV|\(lite\) TV|BRAVIA| TV$')) {
10531074
$this->device = AbstractDeviceParser::DEVICE_TYPE_TV;
10541075
}
10551076

0 commit comments

Comments
 (0)