| 1 |
<?php |
| 2 |
|
| 3 |
use Imagify\User\User; |
| 4 |
|
| 5 |
defined( 'ABSPATH' ) || die( 'Cheatin’ uh?' ); |
| 6 |
|
| 7 |
$imagify_user = new User(); |
| 8 |
$unconsumed_quota = $imagify_user ? $imagify_user->get_percent_unconsumed_quota() : 0; |
| 9 |
$infinite = $imagify_user->is_infinite(); |
| 10 |
$upgrade = ''; |
| 11 |
$price = ''; |
| 12 |
$upgrade_link = ''; |
| 13 |
$user_id = get_current_user_id(); |
| 14 |
$notices = get_user_meta( $user_id, '_imagify_ignore_notices', true ); |
| 15 |
$notices = $notices && is_array( $notices ) ? array_flip( $notices ) : []; |
| 16 |
$api_key_valid = Imagify_Requirements::is_api_key_valid(); |
| 17 |
|
| 18 |
if ( |
| 19 |
$imagify_user->is_free() |
| 20 |
&& |
| 21 |
$api_key_valid |
| 22 |
&& |
| 23 |
$unconsumed_quota > 20 |
| 24 |
) { |
| 25 |
?> |
| 26 |
<div class="imagify-col-content imagify-block-secondary imagify-mt2"> |
| 27 |
<div class="best-plan<?php echo $api_key_valid ? '' : ' hidden'; ?>"> |
| 28 |
<h3 class="imagify-user-best-plan-title"> |
| 29 |
<?php esc_html_e( 'You\'re new to Imagify?', 'imagify' ); ?> |
| 30 |
</h3> |
| 31 |
<p><?php esc_html_e( 'Let us help you by analyzing your existing images and determine the best plan for you.', 'imagify' ); ?></p> |
| 32 |
<button id="imagify-get-pricing-modal" data-nonce="<?php echo wp_create_nonce( 'imagify_get_pricing_' . get_current_user_id() ); ?>" data-target="#imagify-pricing-modal" type="button" class="imagify-modal-trigger imagify-button imagify-button-light imagify-full-width"> |
| 33 |
<i class="dashicons dashicons-dashboard" aria-hidden="true"></i> |
| 34 |
<span class="button-text"><?php esc_html_e( 'What plan do I need?', 'imagify' ); ?></span> |
| 35 |
</button> |
| 36 |
</div> |
| 37 |
</div><!-- .imagify-col-content --> |
| 38 |
<?php |
| 39 |
} |
| 40 |
|
| 41 |
if ( |
| 42 |
Imagify_Requirements::is_api_key_valid() |
| 43 |
&& |
| 44 |
! $infinite |
| 45 |
&& |
| 46 |
! isset( $notices['upsell-banner'] ) |
| 47 |
&& |
| 48 |
$unconsumed_quota <= 20 |
| 49 |
) { |
| 50 |
?> |
| 51 |
<div class="imagify-col-content imagify-upsell"> |
| 52 |
<div class="imagify-flex imagify-vcenter"> |
| 53 |
<span class="imagify-meteo-icon imagify-noshrink"><?php echo $this->get_quota_icon(); ?></span> |
| 54 |
<div class="imagify-space-left imagify-full-width"> |
| 55 |
<p> |
| 56 |
<?php |
| 57 |
printf( |
| 58 |
/* translators: %s is a data quota. */ |
| 59 |
__( 'You have %s space credit left', 'imagify' ), |
| 60 |
'<span class="imagify-unconsumed-percent">' . $this->get_quota_percent() . '%</span>' |
| 61 |
); |
| 62 |
?> |
| 63 |
</p> |
| 64 |
|
| 65 |
<div class="<?php echo $this->get_quota_class(); ?>"> |
| 66 |
<div class="imagify-unconsumed-bar imagify-progress" style="width: <?php echo $this->get_quota_percent() . '%'; ?>;"></div> |
| 67 |
</div> |
| 68 |
</div> |
| 69 |
</div> |
| 70 |
<?php |
| 71 |
if ( $imagify_user->is_free() ) { |
| 72 |
$upgrade = esc_html__( 'Upgrade your plan now for more!', 'imagify' ); |
| 73 |
$price = esc_html__( 'From $5.99/month only, keep going with image optimization!', 'imagify' ); |
| 74 |
$upgrade_link = IMAGIFY_APP_DOMAIN . '/subscription/?utm_source=plugin&utm_medium=upsell_banner'; |
| 75 |
} elseif ( $imagify_user->is_growth() ) { |
| 76 |
$upgrade = esc_html__( 'Upgrade your plan now to keep optimizing your images.', 'imagify' ); |
| 77 |
|
| 78 |
if ( $imagify_user->is_monthly ) { |
| 79 |
$price = esc_html__( 'For $9.99/month only, choose unlimited image optimization!', 'imagify' ); |
| 80 |
$upgrade_link = IMAGIFY_APP_DOMAIN . '/subscription/plan_switch/?label=infinite&payment_plan=1&utm_source=plugin&utm_medium=upsell_banner'; |
| 81 |
} else { |
| 82 |
$price = esc_html__( 'For $99.9/year only, choose unlimited image optimization!', 'imagify' ); |
| 83 |
$upgrade_link = IMAGIFY_APP_DOMAIN . '/subscription/plan_switch/?label=infinite&payment_plan=2&utm_source=plugin&utm_medium=upsell_banner'; |
| 84 |
} |
| 85 |
} |
| 86 |
?> |
| 87 |
<p><?php echo $upgrade; ?></p> |
| 88 |
<p><?php echo $price; ?></p> |
| 89 |
|
| 90 |
<a href="<?php echo esc_url( $upgrade_link ); ?>" target="_blank" rel="noopener noreferrer" class="imagify-upsell-button"><span class="imagify-upsell-arrow"><?php esc_html_e( 'Upgrade now', 'imagify' ); ?></span></a> |
| 91 |
<a href="<?php echo esc_url( get_imagify_admin_url( 'dismiss-notice', 'upsell-banner' ) ); ?>" class="imagify-notice-dismiss imagify-upsell-dismiss" title="<?php esc_attr_e( 'Dismiss this notice', 'imagify' ); ?>"><span class="screen-reader-text"><?php esc_html_e( 'Dismiss this notice', 'imagify' ); ?></span></a> |
| 92 |
</div><!-- .imagify-col-content --> |
| 93 |
<?php |
| 94 |
} |
| 95 |
?> |
| 96 |
|