Skip to content

Commit f22f060

Browse files
feat: use the new upgrade links
1 parent 3d48b2b commit f22f060

File tree

3 files changed

+41
-6
lines changed

3 files changed

+41
-6
lines changed

inc/admin.php

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

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

@@ -1532,7 +1567,7 @@ public function get_bf_notices() {
15321567
'<span class="text-promo-orange">' . __( '25% discount', 'optimole-wp' ) . '</span>'
15331568
),
15341569
'cta_text' => __( 'Claim now', 'optimole-wp' ),
1535-
'cta_link' => esc_url_raw( tsdk_utmify( tsdk_translate_link( 'https://optimole.com/pricing' ), 'bfcm24', 'dismissiblenotice' ) ),
1570+
'cta_link' => esc_url_raw( tsdk_utmify( tsdk_translate_link( self::get_upgrade_base_link() ), 'bfcm24', 'dismissiblenotice' ) ),
15361571
'dismiss_key' => self::BF_PROMO_DISMISS_KEY,
15371572
];
15381573

@@ -1679,7 +1714,7 @@ private function get_dashboard_strings() {
16791714
'notice_disabled_account' => sprintf(
16801715
/* 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 */
16811716
__( '%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' ),
1682-
'<b><a href="' . esc_url( tsdk_translate_link( 'https://optimole.com/pricing' ) ) . '">',
1717+
'<b><a href="' . esc_url( tsdk_translate_link( self::get_upgrade_base_link() ) ) . '">',
16831718
'</a></b>',
16841719
'<b>',
16851720
'</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 ) {

inc/v2/Offload/Loader.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ public function __construct() {
2525
* Adds filters to integrate the custom image editor into WordPress.
2626
*/
2727
public function register_hooks() {
28-
if( has_filter( 'wp_image_editors', 'photon_subsizes_override_image_editors' )){
28+
if ( has_filter( 'wp_image_editors', 'photon_subsizes_override_image_editors' ) ) {
2929
return;
3030
}
3131
add_filter( 'wp_image_editors', [ $this, 'register_image_editor' ] );

0 commit comments

Comments
 (0)