updated plugin Jetpack Protect version 4.0.0

This commit is contained in:
2025-04-29 21:19:56 +00:00
committed by Gitium
parent eb9181b250
commit ebd40ef928
265 changed files with 11864 additions and 3987 deletions

View File

@ -5,6 +5,54 @@ 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).
## [0.6.1] - 2025-03-21
### Changed
- Internal updates.
## [0.6.0] - 2025-03-18
### Changed
- Add `Plans::get_plan_short_name()` for WordPress.com environments. [#42485]
## [0.5.6] - 2025-03-17
### Changed
- Internal updates.
## [0.5.5] - 2025-03-12
### Changed
- Internal updates.
## [0.5.4] - 2025-03-05
### Changed
- Internal updates.
## [0.5.3] - 2025-02-24
### Changed
- Update dependencies.
## [0.5.2] - 2025-02-03
### Changed
- Internal updates.
## [0.5.1] - 2024-11-25
### Changed
- Updated dependencies. [#40286]
## [0.5.0] - 2024-11-14
### Removed
- General: Update minimum PHP version to 7.2. [#40147]
## [0.4.13] - 2024-11-04
### Added
- Enable test coverage. [#39961]
## [0.4.12] - 2024-10-21
### Fixed
- Fixed the site features for Simple sites. [#39817]
## [0.4.11] - 2024-09-23
### Changed
- Update dependencies.
## [0.4.10] - 2024-09-05
### Changed
- Update dependencies.
@ -150,6 +198,18 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
### Deprecated
- Moved the options class into Connection. [#24095]
[0.6.1]: https://github.com/Automattic/jetpack-plans/compare/v0.6.0...v0.6.1
[0.6.0]: https://github.com/Automattic/jetpack-plans/compare/v0.5.6...v0.6.0
[0.5.6]: https://github.com/Automattic/jetpack-plans/compare/v0.5.5...v0.5.6
[0.5.5]: https://github.com/Automattic/jetpack-plans/compare/v0.5.4...v0.5.5
[0.5.4]: https://github.com/Automattic/jetpack-plans/compare/v0.5.3...v0.5.4
[0.5.3]: https://github.com/Automattic/jetpack-plans/compare/v0.5.2...v0.5.3
[0.5.2]: https://github.com/Automattic/jetpack-plans/compare/v0.5.1...v0.5.2
[0.5.1]: https://github.com/Automattic/jetpack-plans/compare/v0.5.0...v0.5.1
[0.5.0]: https://github.com/Automattic/jetpack-plans/compare/v0.4.13...v0.5.0
[0.4.13]: https://github.com/Automattic/jetpack-plans/compare/v0.4.12...v0.4.13
[0.4.12]: https://github.com/Automattic/jetpack-plans/compare/v0.4.11...v0.4.12
[0.4.11]: https://github.com/Automattic/jetpack-plans/compare/v0.4.10...v0.4.11
[0.4.10]: https://github.com/Automattic/jetpack-plans/compare/v0.4.9...v0.4.10
[0.4.9]: https://github.com/Automattic/jetpack-plans/compare/v0.4.8...v0.4.9
[0.4.8]: https://github.com/Automattic/jetpack-plans/compare/v0.4.7...v0.4.8

View File

@ -4,14 +4,15 @@
"type": "library",
"license": "GPL-2.0-or-later",
"require": {
"php": ">=7.0",
"automattic/jetpack-connection": "^4.0.0"
"php": ">=7.2",
"automattic/jetpack-connection": "^6.7.7"
},
"require-dev": {
"yoast/phpunit-polyfills": "^1.1.1",
"automattic/jetpack-changelogger": "^4.2.6",
"automattic/jetpack-status": "^4.0.0",
"automattic/wordbless": "@dev"
"yoast/phpunit-polyfills": "^3.0.0",
"automattic/jetpack-changelogger": "^6.0.2",
"automattic/jetpack-status": "^5.0.10",
"automattic/jetpack-test-environment": "@dev",
"automattic/phpunit-select-config": "^1.0.1"
},
"suggest": {
"automattic/jetpack-autoloader": "Allow for better interoperability with other plugins that use this package."
@ -23,13 +24,14 @@
},
"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"
],
"post-install-cmd": "WorDBless\\Composer\\InstallDropin::copy",
"post-update-cmd": "WorDBless\\Composer\\InstallDropin::copy",
"build-production": "echo 'Add your build step to composer.json, please!'",
"build-development": "echo 'Add your build step to composer.json, please!'"
},
@ -42,7 +44,7 @@
"link-template": "https://github.com/Automattic/jetpack-plans/compare/v${old}...v${new}"
},
"branch-alias": {
"dev-trunk": "0.4.x-dev"
"dev-trunk": "0.6.x-dev"
}
},
"config": {

View File

@ -21,6 +21,14 @@ class Current_Plan {
*/
private static $active_plan_cache;
/**
* Simple Site-specific features available.
* Their calculation can be expensive and slow, so we're caching it for the request.
*
* @var array Site-specific features
*/
private static $simple_site_specific_features = array();
/**
* The name of the option that will store the site's plan.
*
@ -374,7 +382,7 @@ class Current_Plan {
return true;
}
// As of 05 2023 - all plans support Earn features (minus 'simple-payments')
// As of 05 2023 - all plans support Earn features (minus 'simple-payments').
if ( in_array( $feature, array( 'donations', 'recurring-payments', 'premium-content/container' ), true ) ) {
return true;
}
@ -390,4 +398,39 @@ class Current_Plan {
return false;
}
/**
* Retrieve site-specific features for Simple sites.
*
* See Jetpack_Gutenberg::get_site_specific_features()
*
* @return array
*/
public static function get_simple_site_specific_features() {
$is_simple_site = defined( 'IS_WPCOM' ) && constant( 'IS_WPCOM' );
if ( ! $is_simple_site ) {
return array(
'active' => array(),
'available' => array(),
);
}
$current_blog_id = get_current_blog_id();
// Return the cached value if it exists.
if ( isset( self::$simple_site_specific_features[ $current_blog_id ] ) ) {
return self::$simple_site_specific_features[ $current_blog_id ];
}
if ( ! class_exists( '\Store_Product_List' ) ) {
require WP_CONTENT_DIR . '/admin-plugins/wpcom-billing/store-product-list.php';
}
$simple_site_specific_features = \Store_Product_List::get_site_specific_features_data( $current_blog_id );
self::$simple_site_specific_features[ $current_blog_id ] = $simple_site_specific_features;
return $simple_site_specific_features;
}
}

View File

@ -79,4 +79,33 @@ class Plans {
}
}
}
/**
* Efficiently get the short name of a plan from a slug.
*
* @param string $plan_slug Plan slug.
* @return string|null Short product name or null if not round.
*/
public static function get_plan_short_name( $plan_slug ) {
if ( defined( 'IS_WPCOM' ) && IS_WPCOM ) {
if ( ! class_exists( 'Store_Product_List' ) ) {
require WP_CONTENT_DIR . '/admin-plugins/wpcom-billing/store-product-list.php';
}
// Skip additional work like processing of coupons, since we only need the plan's short name.
$products = Store_Product_List::get();
foreach ( $products as $product ) {
if ( isset( $product['product_slug'] ) && $product['product_slug'] === $plan_slug ) {
return $product['product_name_short'] ?? null;
}
}
return null;
}
// Fallback to less efficient method for Jetpack environments.
$plan = self::get_plan( $plan_slug );
return $plan->product_name_short ?? null;
}
}