From f22f06016ea69c3f5fc222828e2153342d949610 Mon Sep 17 00:00:00 2001 From: Soare Robert-Daniel Date: Tue, 7 Oct 2025 19:26:04 +0300 Subject: [PATCH] feat: use the new upgrade links --- inc/admin.php | 43 +++++++++++++++++++++++++++++++++++---- inc/rest.php | 2 +- inc/v2/Offload/Loader.php | 2 +- 3 files changed, 41 insertions(+), 6 deletions(-) diff --git a/inc/admin.php b/inc/admin.php index 34332b0a..e58ba134 100755 --- a/inc/admin.php +++ b/inc/admin.php @@ -651,7 +651,7 @@ public function add_notice_upgrade() { ?>

- @@ -703,6 +703,41 @@ public function should_show_upgrade() { return true; } + /** + * Build upgrade URL with current user's encoded email. + * + * @return string Upgrade URL. + */ + public static function get_upgrade_base_link() { + $base_url = 'https://optimole.com/upgrade'; + $email = self::get_account_email(); + + if ( ! empty( $email ) ) { + $base_url = add_query_arg( 'email', base64_encode( $email ), $base_url ); + } + + return $base_url; + } + + /** + * Retrieve Optimole account email. + * + * @return string + */ + private static function get_account_email() { + $settings = new Optml_Settings(); + $service_data = $settings->get( 'service_data' ); + + if ( isset( $service_data['user_email'] ) && is_string( $service_data['user_email'] ) ) { + $email = sanitize_email( $service_data['user_email'] ); + if ( ! empty( $email ) ) { + return $email; + } + } + + return ''; + } + /** * CSS styles for Notice. */ @@ -1512,7 +1547,7 @@ public function get_bf_notices() { 'BFCM2425', '' . __( '25% off', 'optimole-wp' ) . '' ), - 'cta_link' => esc_url_raw( tsdk_utmify( tsdk_translate_link( 'https://optimole.com/pricing' ), 'bfcm24', 'sidebarnotice' ) ), + 'cta_link' => esc_url_raw( tsdk_utmify( tsdk_translate_link( self::get_upgrade_base_link() ), 'bfcm24', 'sidebarnotice' ) ), ], ]; @@ -1532,7 +1567,7 @@ public function get_bf_notices() { '' . __( '25% discount', 'optimole-wp' ) . '' ), 'cta_text' => __( 'Claim now', 'optimole-wp' ), - 'cta_link' => esc_url_raw( tsdk_utmify( tsdk_translate_link( 'https://optimole.com/pricing' ), 'bfcm24', 'dismissiblenotice' ) ), + 'cta_link' => esc_url_raw( tsdk_utmify( tsdk_translate_link( self::get_upgrade_base_link() ), 'bfcm24', 'dismissiblenotice' ) ), 'dismiss_key' => self::BF_PROMO_DISMISS_KEY, ]; @@ -1679,7 +1714,7 @@ private function get_dashboard_strings() { 'notice_disabled_account' => sprintf( /* translators: 1 anchor tag to pricing, 2 is the ending endin anchor tag, 3 is the bold tag start, 4 ending bold tag, 5 new line tag */ __( '%3$sYour account has been disabled due to exceeding quota.%4$s All images are being redirected to the original unoptimized URL. %5$sPlease %1$supgrade%2$s to re-activate the account.', 'optimole-wp' ), - '', + '', '', '', '', diff --git a/inc/rest.php b/inc/rest.php index 8606bacb..94fdd4e2 100644 --- a/inc/rest.php +++ b/inc/rest.php @@ -788,7 +788,7 @@ public function check_redirects( WP_REST_Request $request ) { $status_code = $response['response']['code']; if ( $status_code === 301 ) { $status = 'deactivated'; - $result = '

  • ❌ ' . sprintf( /* translators: 1 is starting anchor tag, 2 is the ending anchor tag. */ __( 'Your account is currently disabled due to exceeding quota and Optimole is no longer able to optimize the images. In order to fix this you will need to %1$supgrade%2$s.', 'optimole-wp' ), '', '' ) . '
  • '; + $result = '
  • ❌ ' . sprintf( /* translators: 1 is starting anchor tag, 2 is the ending anchor tag. */ __( 'Your account is currently disabled due to exceeding quota and Optimole is no longer able to optimize the images. In order to fix this you will need to %1$supgrade%2$s.', 'optimole-wp' ), '', '' ) . '
  • '; break; } if ( $status_code === 302 ) { diff --git a/inc/v2/Offload/Loader.php b/inc/v2/Offload/Loader.php index e3f9e8b4..ac75e722 100644 --- a/inc/v2/Offload/Loader.php +++ b/inc/v2/Offload/Loader.php @@ -25,7 +25,7 @@ public function __construct() { * Adds filters to integrate the custom image editor into WordPress. */ public function register_hooks() { - if( has_filter( 'wp_image_editors', 'photon_subsizes_override_image_editors' )){ + if ( has_filter( 'wp_image_editors', 'photon_subsizes_override_image_editors' ) ) { return; } add_filter( 'wp_image_editors', [ $this, 'register_image_editor' ] );