From 678980688436f76a141e48d736c525ea50e4a815 Mon Sep 17 00:00:00 2001 From: Luiz Kowalski Date: Tue, 31 Oct 2023 14:44:44 -0300 Subject: [PATCH 1/4] Refactor code to use an intermediary current tier value var --- .../jetpack/_inc/lib/class-jetpack-ai-helper.php | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/projects/plugins/jetpack/_inc/lib/class-jetpack-ai-helper.php b/projects/plugins/jetpack/_inc/lib/class-jetpack-ai-helper.php index fb8cdcf94e8bc..f875abc8bae46 100644 --- a/projects/plugins/jetpack/_inc/lib/class-jetpack-ai-helper.php +++ b/projects/plugins/jetpack/_inc/lib/class-jetpack-ai-helper.php @@ -396,6 +396,17 @@ public static function get_ai_assistance_feature() { $usage_period_requests_count = WPCOM\Jetpack_AI\Usage\Helper::get_current_period_requests_count( $blog_id ); + /* + * Get current tier value, a number representing + * the current tier of the site. + * + * - 0 represents a site with the free plan. + * - 1 represents a site with the current, unlimited plan. + * - 100, 200, 500 represents a site with the new plans, + * with the respective number of allowed requests. + */ + $current_tier_value = $has_ai_assistant_feature ? 1 : 0; + // Check if the site requires an upgrade. $require_upgrade = $is_over_limit && ! $has_ai_assistant_feature; @@ -415,7 +426,7 @@ public static function get_ai_assistance_feature() { 'site-require-upgrade' => $require_upgrade, 'upgrade-type' => $upgrade_type, 'current-tier' => array( - 'value' => $has_ai_assistant_feature ? 1 : 0, + 'value' => $current_tier_value, ), ); } From fc5dbce9d262d10e0f5d1813f51816c344eb080b Mon Sep 17 00:00:00 2001 From: Luiz Kowalski Date: Tue, 31 Oct 2023 14:49:54 -0300 Subject: [PATCH 2/4] Use Usage Helper to fetch the tier information --- projects/plugins/jetpack/_inc/lib/class-jetpack-ai-helper.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/projects/plugins/jetpack/_inc/lib/class-jetpack-ai-helper.php b/projects/plugins/jetpack/_inc/lib/class-jetpack-ai-helper.php index f875abc8bae46..68be7f6d8fed1 100644 --- a/projects/plugins/jetpack/_inc/lib/class-jetpack-ai-helper.php +++ b/projects/plugins/jetpack/_inc/lib/class-jetpack-ai-helper.php @@ -405,7 +405,7 @@ public static function get_ai_assistance_feature() { * - 100, 200, 500 represents a site with the new plans, * with the respective number of allowed requests. */ - $current_tier_value = $has_ai_assistant_feature ? 1 : 0; + $current_tier_value = $has_ai_assistant_feature ? WPCOM\Jetpack_AI\Usage\Helper::get_tier_usage_quantity( $blog_id ) : 0; // Check if the site requires an upgrade. $require_upgrade = $is_over_limit && ! $has_ai_assistant_feature; From 718ebde8ac2b85fcc531133c83337cda54fc3f9e Mon Sep 17 00:00:00 2001 From: Luiz Kowalski Date: Tue, 31 Oct 2023 14:56:51 -0300 Subject: [PATCH 3/4] Add changelog file --- ...date-jetpack-ai-use-usage-helper-to-set-current-tier-value | 4 ++++ 1 file changed, 4 insertions(+) create mode 100644 projects/plugins/jetpack/changelog/update-jetpack-ai-use-usage-helper-to-set-current-tier-value diff --git a/projects/plugins/jetpack/changelog/update-jetpack-ai-use-usage-helper-to-set-current-tier-value b/projects/plugins/jetpack/changelog/update-jetpack-ai-use-usage-helper-to-set-current-tier-value new file mode 100644 index 0000000000000..ff96ae47dfef0 --- /dev/null +++ b/projects/plugins/jetpack/changelog/update-jetpack-ai-use-usage-helper-to-set-current-tier-value @@ -0,0 +1,4 @@ +Significance: patch +Type: enhancement + +Jetpack AI: Use Jetpack AI Usage Helper to set current plan tier information on feature endpoint. From 55d2576cab5c7190d82acd85e8cea0b2eb15221b Mon Sep 17 00:00:00 2001 From: Luiz Kowalski Date: Tue, 31 Oct 2023 19:04:30 -0300 Subject: [PATCH 4/4] Version bump --- projects/plugins/jetpack/composer.json | 2 +- projects/plugins/jetpack/jetpack.php | 4 ++-- projects/plugins/jetpack/package.json | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/projects/plugins/jetpack/composer.json b/projects/plugins/jetpack/composer.json index 7fb629452f53f..71057a007630d 100644 --- a/projects/plugins/jetpack/composer.json +++ b/projects/plugins/jetpack/composer.json @@ -103,7 +103,7 @@ "platform": { "ext-intl": "0.0.0" }, - "autoloader-suffix": "f11009ded9fc4592b6a05b61ce272b3c_jetpackā“„12_8_a_11", + "autoloader-suffix": "f11009ded9fc4592b6a05b61ce272b3c_jetpackā“„12_8_a_12", "allow-plugins": { "automattic/jetpack-autoloader": true, "automattic/jetpack-composer-plugin": true diff --git a/projects/plugins/jetpack/jetpack.php b/projects/plugins/jetpack/jetpack.php index df65e83a2f269..ca938547d214f 100644 --- a/projects/plugins/jetpack/jetpack.php +++ b/projects/plugins/jetpack/jetpack.php @@ -4,7 +4,7 @@ * Plugin URI: https://jetpack.com * Description: Security, performance, and marketing tools made by WordPress experts. Jetpack keeps your site protected so you can focus on more important things. * Author: Automattic - * Version: 12.8-a.11 + * Version: 12.8-a.12 * Author URI: https://jetpack.com * License: GPL2+ * Text Domain: jetpack @@ -34,7 +34,7 @@ define( 'JETPACK__MINIMUM_WP_VERSION', '6.2' ); define( 'JETPACK__MINIMUM_PHP_VERSION', '5.6' ); -define( 'JETPACK__VERSION', '12.8-a.11' ); +define( 'JETPACK__VERSION', '12.8-a.12' ); /** * Constant used to fetch the connection owner token diff --git a/projects/plugins/jetpack/package.json b/projects/plugins/jetpack/package.json index a2bda536fbe01..b85a74875ddc0 100644 --- a/projects/plugins/jetpack/package.json +++ b/projects/plugins/jetpack/package.json @@ -1,6 +1,6 @@ { "name": "Jetpack", - "version": "12.8.0-a.11", + "version": "12.8.0-a.12", "private": true, "description": "[Jetpack](https://jetpack.com/) is a WordPress plugin that supercharges your self-hosted WordPress site with the awesome cloud power of [WordPress.com](https://wordpress.com).", "homepage": "https://jetpack.com",