Skip to content

Commit bca649d

Browse files
authored
Merge pull request #985 from Codeinwp/feat/upgrade-links
feat: use the new upgrade links
2 parents 7e9bf78 + f22f060 commit bca649d

File tree

2 files changed

+40
-5
lines changed

2 files changed

+40
-5
lines changed

inc/admin.php

Lines changed: 39 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -652,7 +652,7 @@ public function add_notice_upgrade() {
652652
?>
653653
</p>
654654
<p style="margin: 1.5% 0;">
655-
<a href="<?php echo esc_url( tsdk_translate_link( 'https://optimole.com/pricing' ) ); ?>"
655+
<a href="<?php echo esc_url( tsdk_translate_link( self::get_upgrade_base_link() ) ); ?>"
656656
target="_blank"
657657
style="border-radius: 4px;padding: 9px 10px;border: 2px solid #FFF;color: white;text-decoration: none;"><?php _e( 'Check upgrade plans', 'optimole-wp' ); ?>
658658
</a>
@@ -704,6 +704,41 @@ public function should_show_upgrade() {
704704
return true;
705705
}
706706

707+
/**
708+
* Build upgrade URL with current user's encoded email.
709+
*
710+
* @return string Upgrade URL.
711+
*/
712+
public static function get_upgrade_base_link() {
713+
$base_url = 'https://optimole.com/upgrade';
714+
$email = self::get_account_email();
715+
716+
if ( ! empty( $email ) ) {
717+
$base_url = add_query_arg( 'email', base64_encode( $email ), $base_url );
718+
}
719+
720+
return $base_url;
721+
}
722+
723+
/**
724+
* Retrieve Optimole account email.
725+
*
726+
* @return string
727+
*/
728+
private static function get_account_email() {
729+
$settings = new Optml_Settings();
730+
$service_data = $settings->get( 'service_data' );
731+
732+
if ( isset( $service_data['user_email'] ) && is_string( $service_data['user_email'] ) ) {
733+
$email = sanitize_email( $service_data['user_email'] );
734+
if ( ! empty( $email ) ) {
735+
return $email;
736+
}
737+
}
738+
739+
return '';
740+
}
741+
707742
/**
708743
* CSS styles for Notice.
709744
*/
@@ -1520,7 +1555,7 @@ public function get_bf_notices() {
15201555
'<span class="border-b border-0 border-white border-dashed text-promo-orange">BFCM2425</span>',
15211556
'<span class="text-promo-orange uppercase">' . __( '25% off', 'optimole-wp' ) . '</span>'
15221557
),
1523-
'cta_link' => esc_url_raw( tsdk_utmify( tsdk_translate_link( 'https://optimole.com/pricing' ), 'bfcm24', 'sidebarnotice' ) ),
1558+
'cta_link' => esc_url_raw( tsdk_utmify( tsdk_translate_link( self::get_upgrade_base_link() ), 'bfcm24', 'sidebarnotice' ) ),
15241559
],
15251560
];
15261561

@@ -1540,7 +1575,7 @@ public function get_bf_notices() {
15401575
'<span class="text-promo-orange">' . __( '25% discount', 'optimole-wp' ) . '</span>'
15411576
),
15421577
'cta_text' => __( 'Claim now', 'optimole-wp' ),
1543-
'cta_link' => esc_url_raw( tsdk_utmify( tsdk_translate_link( 'https://optimole.com/pricing' ), 'bfcm24', 'dismissiblenotice' ) ),
1578+
'cta_link' => esc_url_raw( tsdk_utmify( tsdk_translate_link( self::get_upgrade_base_link() ), 'bfcm24', 'dismissiblenotice' ) ),
15441579
'dismiss_key' => self::BF_PROMO_DISMISS_KEY,
15451580
];
15461581

@@ -1687,7 +1722,7 @@ private function get_dashboard_strings() {
16871722
'notice_disabled_account' => sprintf(
16881723
/* 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 */
16891724
__( '%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' ),
1690-
'<b><a href="' . esc_url( tsdk_translate_link( 'https://optimole.com/pricing' ) ) . '">',
1725+
'<b><a href="' . esc_url( tsdk_translate_link( self::get_upgrade_base_link() ) ) . '">',
16911726
'</a></b>',
16921727
'<b>',
16931728
'</b>',

inc/rest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -788,7 +788,7 @@ public function check_redirects( WP_REST_Request $request ) {
788788
$status_code = $response['response']['code'];
789789
if ( $status_code === 301 ) {
790790
$status = 'deactivated';
791-
$result = '<li>❌ ' . 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' ), '<a target="_blank" href="' . esc_url( tsdk_translate_link( 'https://optimole.com/pricing' ) ) . '">', '</a>' ) . '</li>';
791+
$result = '<li>❌ ' . 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' ), '<a target="_blank" href="' . esc_url( tsdk_translate_link( Optml_Admin::get_upgrade_base_link() ) ) . '">', '</a>' ) . '</li>';
792792
break;
793793
}
794794
if ( $status_code === 302 ) {

0 commit comments

Comments
 (0)