From f22f06016ea69c3f5fc222828e2153342d949610 Mon Sep 17 00:00:00 2001
From: Soare Robert-Daniel
-
@@ -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 = '