From 3d9b12c1cd088da324ec251547562fd4e80c2bb7 Mon Sep 17 00:00:00 2001 From: Soare Robert-Daniel Date: Thu, 25 Sep 2025 11:50:44 +0300 Subject: [PATCH 1/6] feat: revert offload on plans without offload --- inc/admin.php | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/inc/admin.php b/inc/admin.php index b5cabe68..a3465784 100755 --- a/inc/admin.php +++ b/inc/admin.php @@ -1070,8 +1070,16 @@ public function daily_sync() { if ( isset( $data['extra_visits'] ) ) { $this->settings->update_frontend_banner_from_remote( $data['extra_visits'] ); } + // Here the account got deactivated, in this case we check if the user is using offloaded images and we roll them back. - if ( isset( $data['status'] ) && $data['status'] === 'inactive' ) { + $should_revert_offloading = isset( $data['status'] ) && $data['status'] === 'inactive'; + + // The user is now on a plan without offloading and the grace period is over. + if ( isset( $data['should_revert_offload'] ) && $data['should_revert_offload'] === true ) { + $should_revert_offloading = true; + } + + if ( $should_revert_offloading ) { // We check if the user has images offloaded. if ( $this->settings->get( 'offload_media' ) === 'disabled' ) { return; From 8382325d942997d2ed8bd17ec7046e4eb7708b55 Mon Sep 17 00:00:00 2001 From: Soare Robert-Daniel Date: Thu, 25 Sep 2025 14:15:52 +0300 Subject: [PATCH 2/6] feat: add notices for offload restriction and upgrade --- .../src/dashboard/parts/components/Modal.js | 3 +- .../parts/connected/settings/OffloadMedia.js | 54 +++++++++++++++---- inc/admin.php | 3 ++ 3 files changed, 48 insertions(+), 12 deletions(-) diff --git a/assets/src/dashboard/parts/components/Modal.js b/assets/src/dashboard/parts/components/Modal.js index c3a5d1e0..33590757 100644 --- a/assets/src/dashboard/parts/components/Modal.js +++ b/assets/src/dashboard/parts/components/Modal.js @@ -4,7 +4,7 @@ import { close } from '@wordpress/icons'; import { useViewportMatch } from '@wordpress/compose'; import { Button, Icon, Modal as CoreModal } from '@wordpress/components'; -export default function Modal({ icon, labels = {}, onRequestClose = () => {}, onConfirm = () => {}, variant = 'default', onSecondaryAction = () => {} }) { +export default function Modal({ icon, labels = {}, onRequestClose = () => {}, onConfirm = () => {}, variant = 'default', onSecondaryAction = () => {}, afterContentChildren = null }) { const isMobileViewport = useViewportMatch( 'small', '<' ); @@ -53,6 +53,7 @@ export default function Modal({ icon, labels = {}, onRequestClose = () => {}, on className="text-center mx-0 my-4 text-gray-700" dangerouslySetInnerHTML={ { __html: labels.description } } /> + { afterContentChildren }
diff --git a/assets/src/dashboard/parts/connected/settings/OffloadMedia.js b/assets/src/dashboard/parts/connected/settings/OffloadMedia.js index cb4f5e2d..293aafea 100644 --- a/assets/src/dashboard/parts/connected/settings/OffloadMedia.js +++ b/assets/src/dashboard/parts/connected/settings/OffloadMedia.js @@ -205,7 +205,7 @@ const OffloadMedia = ({ settings, canSave, setSettings, setCanSave }) => { onOffloadMedia(); } else { - window.open( optimoleDashboardApp.optimoleHome + 'pricing', '_blank' ); + window.open( optimoleDashboardApp.optimoleHome + 'pricing', '_blank' ); } setModal( null ); }, diff --git a/inc/admin.php b/inc/admin.php index bb99fc6e..1e85830c 100755 --- a/inc/admin.php +++ b/inc/admin.php @@ -2393,7 +2393,7 @@ private function get_active_notices_count() { /** * Mark the users that are on free plan and have offload enabled. * - * User for displaying a notice after plugin update about offload restrictions. + * Used for displaying a notice after plugin update about offload restrictions. * * @return void */ From f142cf529c277bdaa6b349cae63782b1d976a1f7 Mon Sep 17 00:00:00 2001 From: Soare Robert-Daniel Date: Mon, 29 Sep 2025 14:36:48 +0300 Subject: [PATCH 5/6] chore: review --- .../dashboard/parts/connected/settings/OffloadMedia.js | 2 +- inc/admin.php | 8 ++------ 2 files changed, 3 insertions(+), 7 deletions(-) diff --git a/assets/src/dashboard/parts/connected/settings/OffloadMedia.js b/assets/src/dashboard/parts/connected/settings/OffloadMedia.js index 293aafea..896c9102 100644 --- a/assets/src/dashboard/parts/connected/settings/OffloadMedia.js +++ b/assets/src/dashboard/parts/connected/settings/OffloadMedia.js @@ -205,7 +205,7 @@ const OffloadMedia = ({ settings, canSave, setSettings, setCanSave }) => { onOffloadMedia(); } else { - window.open( optimoleDashboardApp.optimoleHome + 'pricing', '_blank' ); + window.open( optimoleDashboardApp?.offload_upgrade_url, '_blank' ); } setModal( null ); }, diff --git a/inc/admin.php b/inc/admin.php index 1e85830c..89f9a7f8 100755 --- a/inc/admin.php +++ b/inc/admin.php @@ -1076,7 +1076,7 @@ public function daily_sync() { $should_revert_offloading = isset( $data['status'] ) && $data['status'] === 'inactive'; // The user is now on a plan without offloading and the grace period is over. - if ( isset( $data['should_revert_offload'] ) && $data['should_revert_offload'] === true ) { + if ( isset( $data['should_revert_offload'] ) && (bool) $data['should_revert_offload'] ) { $should_revert_offloading = true; } @@ -1384,6 +1384,7 @@ private function localize_dashboard_app() { 'optimoleHome' => tsdk_translate_link( 'https://optimole.com/' ), 'optimoleDashHome' => tsdk_translate_link( 'https://dashboard.optimole.com/', 'query' ), 'optimoleDashBilling' => tsdk_translate_link( 'https://dashboard.optimole.com/settings/billing', 'query' ), + 'offload_upgrade_url' => tsdk_translate_link( tsdk_utmify( 'https://optimole.com/pricing/', 'offload' ) ), 'days_since_install' => round( ( time() - get_option( 'optimole_wp_install', 0 ) ) / DAY_IN_SECONDS ), 'is_offload_media_available' => $is_offload_media_available, 'auto_connect' => $auto_connect, @@ -2402,11 +2403,6 @@ public function mark_free_user_with_offload() { return; } - $service_data = $this->settings->get( 'service_data' ); - if ( isset( $service_data['plan'] ) && 'free' !== $service_data['plan'] ) { - return; - } - if ( false !== get_option( 'optml_free_user_with_offload', false ) ) { return; } From ec4956ec0f8f5f0b490337c876c2b083d1470f4c Mon Sep 17 00:00:00 2001 From: Soare Robert-Daniel Date: Wed, 1 Oct 2025 16:12:56 +0300 Subject: [PATCH 6/6] chore: review --- inc/admin.php | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/inc/admin.php b/inc/admin.php index 89f9a7f8..0121a076 100755 --- a/inc/admin.php +++ b/inc/admin.php @@ -113,7 +113,7 @@ public function __construct() { } add_filter( 'themeisle-sdk/survey/' . OPTML_PRODUCT_SLUG, [ $this, 'get_survey_metadata' ], 10, 2 ); - add_action( 'admin_init', [ $this, 'mark_free_user_with_offload' ] ); + add_action( 'admin_init', [ $this, 'mark_user_with_offload' ] ); } /** @@ -1399,7 +1399,7 @@ private function localize_dashboard_app() { 'bf_notices' => $this->get_bf_notices(), 'spc_banner' => $this->get_spc_banner(), 'show_exceed_plan_quota_notice' => $this->should_show_exceed_quota_warning(), - 'show_free_user_with_offload_notice' => get_option( 'optml_free_user_with_offload', 'no' ), + 'show_free_user_with_offload_notice' => get_option( 'optml_has_offloading_enabled_on_upgrade', 'no' ), 'report_issue_url' => add_query_arg( [ 'utm_source' => 'plugin', @@ -1637,7 +1637,7 @@ private function get_dashboard_strings() { ' optimole.com' ), 'account_needed_subtitle_1' => sprintf( - /* translators: 1 is starting bold tag, 2 is ending bold tag, 3 is the starting bold tag, 4 is the limit number, 5 is ending bold tag, 6 is the starting anchor tag for the docs link on how we count visits, 7 is the ending anchor tag. */ + /* translators: 1 is the starting bold tag, 2 is the ending bold tag, 3 is the starting bold tag, 4 is the limit number, 5 is ending bold tag, 6 is the starting anchor tag for the docs link on how we count visits, 7 is the ending anchor tag. */ __( '%1$sOptimize unlimited images%2$s for up to %3$s monthly %4$svisitors%5$s - completely FREE.', 'optimole-wp' ), '', '', @@ -2097,7 +2097,7 @@ private function get_dashboard_strings() { 'exceed_plan_quota_notice_start_action' => __( 'Yes, Transfer to Optimole Cloud', 'optimole-wp' ), 'exceed_plan_quota_notice_secondary_action' => __( 'No, keep images on my website', 'optimole-wp' ), 'plan_update_notice_title' => __( 'Plan Update', 'optimole-wp' ), - 'plan_update_notice_desc' => __( 'We\'ve changed how plans work. Users on Optimole Free plan can not offload new image. Existing images that are already offloaded will remain offloaded.', 'optimole-wp' ), + 'plan_update_notice_desc' => __( 'We\'ve changed how plans work. Users on the Optimole Free plan cannot offload new images. Existing images that are already offloaded will remain offloaded.', 'optimole-wp' ), 'upgrade_to_use_offloading_notice_desc' => __( 'Offloading images is a PRO feature. Please upgrade your plan to enable image transfer to Optimole Cloud.', 'optimole-wp' ), 'visual_settings' => __( 'Visual Settings', 'optimole-wp' ), 'extended_features' => __( 'Extended Features', 'optimole-wp' ), @@ -2392,21 +2392,21 @@ private function get_active_notices_count() { } /** - * Mark the users that are on free plan and have offload enabled. + * Mark if the user had offloading enabled on first run. * - * Used for displaying a notice after plugin update about offload restrictions. + * If it is an old free user that had offloading enabled, we will use the mark to show a notice about the plan changes. * * @return void */ - public function mark_free_user_with_offload() { + public function mark_user_with_offload() { if ( ! $this->settings->is_connected() ) { return; } - if ( false !== get_option( 'optml_free_user_with_offload', false ) ) { + if ( false !== get_option( 'optml_has_offloading_enabled_on_upgrade', false ) ) { return; } - update_option( 'optml_free_user_with_offload', $this->settings->is_offload_enabled() ? 'yes' : 'no' ); + update_option( 'optml_has_offloading_enabled_on_upgrade', $this->settings->is_offload_enabled() ? 'yes' : 'no' ); } }