updated plugin Jetpack Protect
version 4.0.0
This commit is contained in:
@ -5,6 +5,38 @@ All notable changes to this project will be documented in this file.
|
||||
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/)
|
||||
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
||||
|
||||
## [3.0.5] - 2025-03-21
|
||||
### Changed
|
||||
- Internal updates.
|
||||
|
||||
## [3.0.4] - 2025-03-17
|
||||
### Changed
|
||||
- Internal updates.
|
||||
|
||||
## [3.0.3] - 2025-03-12
|
||||
### Changed
|
||||
- Internal updates.
|
||||
|
||||
## [3.0.2] - 2025-03-05
|
||||
### Changed
|
||||
- Internal updates.
|
||||
|
||||
## [3.0.1] - 2025-02-24
|
||||
### Changed
|
||||
- Update dependencies.
|
||||
|
||||
## [3.0.0] - 2024-11-14
|
||||
### Removed
|
||||
- General: Update minimum PHP version to 7.2. [#40147]
|
||||
|
||||
## [2.1.6] - 2024-11-04
|
||||
### Added
|
||||
- Enable test coverage. [#39961]
|
||||
|
||||
## [2.1.5] - 2024-09-16
|
||||
### Changed
|
||||
- Device_Detection::get_info() will now memoize its result [#39338]
|
||||
|
||||
## [2.1.4] - 2024-08-23
|
||||
### Changed
|
||||
- Updated package dependencies. [#39004]
|
||||
@ -200,6 +232,14 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
||||
|
||||
- Moving jetpack_is_mobile into a package
|
||||
|
||||
[3.0.5]: https://github.com/Automattic/jetpack-device-detection/compare/v3.0.4...v3.0.5
|
||||
[3.0.4]: https://github.com/Automattic/jetpack-device-detection/compare/v3.0.3...v3.0.4
|
||||
[3.0.3]: https://github.com/Automattic/jetpack-device-detection/compare/v3.0.2...v3.0.3
|
||||
[3.0.2]: https://github.com/Automattic/jetpack-device-detection/compare/v3.0.1...v3.0.2
|
||||
[3.0.1]: https://github.com/Automattic/jetpack-device-detection/compare/v3.0.0...v3.0.1
|
||||
[3.0.0]: https://github.com/Automattic/jetpack-device-detection/compare/v2.1.6...v3.0.0
|
||||
[2.1.6]: https://github.com/Automattic/jetpack-device-detection/compare/v2.1.5...v2.1.6
|
||||
[2.1.5]: https://github.com/Automattic/jetpack-device-detection/compare/v2.1.4...v2.1.5
|
||||
[2.1.4]: https://github.com/Automattic/jetpack-device-detection/compare/v2.1.3...v2.1.4
|
||||
[2.1.3]: https://github.com/Automattic/jetpack-device-detection/compare/v2.1.2...v2.1.3
|
||||
[2.1.2]: https://github.com/Automattic/jetpack-device-detection/compare/v2.1.1...v2.1.2
|
||||
|
@ -4,11 +4,12 @@
|
||||
"type": "jetpack-library",
|
||||
"license": "GPL-2.0-or-later",
|
||||
"require": {
|
||||
"php": ">=7.0"
|
||||
"php": ">=7.2"
|
||||
},
|
||||
"require-dev": {
|
||||
"yoast/phpunit-polyfills": "^1.1.1",
|
||||
"automattic/jetpack-changelogger": "^4.2.6"
|
||||
"yoast/phpunit-polyfills": "^3.0.0",
|
||||
"automattic/jetpack-changelogger": "^6.0.2",
|
||||
"automattic/phpunit-select-config": "^1.0.1"
|
||||
},
|
||||
"suggest": {
|
||||
"automattic/jetpack-autoloader": "Allow for better interoperability with other plugins that use this package."
|
||||
@ -20,7 +21,10 @@
|
||||
},
|
||||
"scripts": {
|
||||
"phpunit": [
|
||||
"./vendor/phpunit/phpunit/phpunit --colors=always"
|
||||
"phpunit-select-config phpunit.#.xml.dist --colors=always"
|
||||
],
|
||||
"test-coverage": [
|
||||
"php -dpcov.directory=. ./vendor/bin/phpunit-select-config phpunit.#.xml.dist --coverage-php \"$COVERAGE_DIR/php.cov\""
|
||||
],
|
||||
"test-php": [
|
||||
"@composer phpunit"
|
||||
@ -35,7 +39,7 @@
|
||||
"link-template": "https://github.com/Automattic/jetpack-device-detection/compare/v${old}...v${new}"
|
||||
},
|
||||
"branch-alias": {
|
||||
"dev-trunk": "2.1.x-dev"
|
||||
"dev-trunk": "3.0.x-dev"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -23,6 +23,20 @@ use function Automattic\Jetpack\Device_Detection\wp_unslash;
|
||||
*/
|
||||
class Device_Detection {
|
||||
|
||||
/**
|
||||
* Memoization cache for get_info() results.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
private static $get_info_memo = array();
|
||||
|
||||
/**
|
||||
* Maximum size of the memoization cache.
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
private static $max_memo_size = 100;
|
||||
|
||||
/**
|
||||
* Returns information about the current device accessing the page.
|
||||
*
|
||||
@ -41,6 +55,16 @@ class Device_Detection {
|
||||
* );
|
||||
*/
|
||||
public static function get_info( $ua = '' ) {
|
||||
// Return memoized result if available.
|
||||
// phpcs:disable WordPress.Security.ValidatedSanitizedInput
|
||||
$memo_key = ! empty( $ua ) ? $ua : ( $_SERVER['HTTP_USER_AGENT'] ?? '' );
|
||||
// Note: UA string used raw for compatibility reasons.
|
||||
// No sanitization is needed as the value is never output or persisted, and is only used for memoization.
|
||||
// phpcs:enable WordPress.Security.ValidatedSanitizedInput
|
||||
if ( isset( self::$get_info_memo[ $memo_key ] ) ) {
|
||||
return self::$get_info_memo[ $memo_key ];
|
||||
}
|
||||
|
||||
$ua_info = new User_Agent_Info( $ua );
|
||||
|
||||
$info = array(
|
||||
@ -68,6 +92,13 @@ class Device_Detection {
|
||||
*/
|
||||
$info = apply_filters( 'jetpack_device_detection_get_info', $info, $ua, $ua_info );
|
||||
}
|
||||
|
||||
// Memoize the result.
|
||||
self::$get_info_memo[ $memo_key ] = $info;
|
||||
if ( count( self::$get_info_memo ) > self::$max_memo_size ) {
|
||||
array_shift( self::$get_info_memo );
|
||||
}
|
||||
|
||||
return $info;
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user