Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
43 changes: 39 additions & 4 deletions inc/admin.php
Original file line number Diff line number Diff line change
Expand Up @@ -651,7 +651,7 @@ public function add_notice_upgrade() {
?>
</p>
<p style="margin: 1.5% 0;">
<a href="<?php echo esc_url( tsdk_translate_link( 'https://optimole.com/pricing' ) ); ?>"
<a href="<?php echo esc_url( tsdk_translate_link( self::get_upgrade_base_link() ) ); ?>"
target="_blank"
style="border-radius: 4px;padding: 9px 10px;border: 2px solid #FFF;color: white;text-decoration: none;"><?php _e( 'Check upgrade plans', 'optimole-wp' ); ?>
</a>
Expand Down Expand Up @@ -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.
*/
Expand Down Expand Up @@ -1512,7 +1547,7 @@ public function get_bf_notices() {
'<span class="border-b border-0 border-white border-dashed text-promo-orange">BFCM2425</span>',
'<span class="text-promo-orange uppercase">' . __( '25% off', 'optimole-wp' ) . '</span>'
),
'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' ) ),
],
];

Expand All @@ -1532,7 +1567,7 @@ public function get_bf_notices() {
'<span class="text-promo-orange">' . __( '25% discount', 'optimole-wp' ) . '</span>'
),
'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,
];

Expand Down Expand Up @@ -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' ),
'<b><a href="' . esc_url( tsdk_translate_link( 'https://optimole.com/pricing' ) ) . '">',
'<b><a href="' . esc_url( tsdk_translate_link( self::get_upgrade_base_link() ) ) . '">',
'</a></b>',
'<b>',
'</b>',
Expand Down
2 changes: 1 addition & 1 deletion inc/rest.php
Original file line number Diff line number Diff line change
Expand Up @@ -788,7 +788,7 @@ public function check_redirects( WP_REST_Request $request ) {
$status_code = $response['response']['code'];
if ( $status_code === 301 ) {
$status = 'deactivated';
$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>';
$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>';
break;
}
if ( $status_code === 302 ) {
Expand Down
2 changes: 1 addition & 1 deletion inc/v2/Offload/Loader.php
Original file line number Diff line number Diff line change
Expand Up @@ -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' ] );
Expand Down
Loading