| 1 |
<?php |
| 2 |
defined( 'ABSPATH' ) || die( 'Cheatin\' uh?' ); |
| 3 |
|
| 4 |
if ( defined( 'IMAGIFY_HIDDEN_ACCOUNT' ) && IMAGIFY_HIDDEN_ACCOUNT ) { |
| 5 |
if ( ! defined( 'IMAGIFY_API_KEY' ) || ! IMAGIFY_API_KEY ) { |
| 6 |
$options = Imagify_Options::get_instance(); |
| 7 |
?> |
| 8 |
<input type="hidden" value="<?php echo esc_attr( $options->get( 'api_key' ) ); ?>" name="<?php echo $options->get_option_name(); ?>[api_key]"> |
| 9 |
<?php |
| 10 |
} |
| 11 |
return; |
| 12 |
} |
| 13 |
|
| 14 |
if ( imagify_valid_key() ) { |
| 15 |
$user = imagify_get_cached_user(); |
| 16 |
$unconsumed_quota = $user ? $user->get_percent_unconsumed_quota : false; |
| 17 |
$hidden_class = ''; |
| 18 |
|
| 19 |
if ( ! $user ) { |
| 20 |
// Lazyload user. |
| 21 |
Imagify_Assets::get_instance()->localize_script( 'options', 'imagifyUser', array( |
| 22 |
'action' => 'imagify_get_user_data', |
| 23 |
'_wpnonce' => wp_create_nonce( 'imagify_get_user_data' ), |
| 24 |
) ); |
| 25 |
} |
| 26 |
} else { |
| 27 |
$hidden_class = ' hidden'; |
| 28 |
} |
| 29 |
?> |
| 30 |
<div class="imagify-settings-section"> |
| 31 |
|
| 32 |
<?php |
| 33 |
if ( imagify_valid_key() ) { |
| 34 |
?> |
| 35 |
<div class="imagify-col-content imagify-block-secondary imagify-mt2"> |
| 36 |
<?php |
| 37 |
/** |
| 38 |
* Best plan. |
| 39 |
*/ |
| 40 |
?> |
| 41 |
<div class="best-plan<?php echo $hidden_class; ?>"> |
| 42 |
<h3 class="imagify-user-best-plan-title"> |
| 43 |
<?php |
| 44 |
if ( $user && ! $unconsumed_quota ) { |
| 45 |
esc_html_e( 'Oops, It\'s Over!', 'imagify' ); |
| 46 |
} elseif ( $user && $unconsumed_quota <= 20 ) { |
| 47 |
esc_html_e( 'Oops, It\'s almost over!', 'imagify' ); |
| 48 |
} else { |
| 49 |
esc_html_e( 'You\'re new to Imagify?', 'imagify' ); |
| 50 |
} |
| 51 |
?> |
| 52 |
</h3> |
| 53 |
|
| 54 |
<p><?php esc_html_e( 'Let us help you by analyzing your existing images and determine the best plan for you.', 'imagify' ); ?></p> |
| 55 |
|
| 56 |
<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"> |
| 57 |
<i class="dashicons dashicons-dashboard" aria-hidden="true"></i> |
| 58 |
<span class="button-text"><?php esc_html_e( 'What plan do I need?', 'imagify' ); ?></span> |
| 59 |
</button> |
| 60 |
</div> |
| 61 |
</div><!-- .imagify-col-content --> |
| 62 |
<?php |
| 63 |
} |
| 64 |
?> |
| 65 |
|
| 66 |
<?php |
| 67 |
if ( ! defined( 'IMAGIFY_API_KEY' ) || ! IMAGIFY_API_KEY ) { |
| 68 |
if ( imagify_valid_key() ) { |
| 69 |
?> |
| 70 |
<h2 class="imagify-options-title"> |
| 71 |
<?php esc_html_e( 'Account Type', 'imagify' ); ?> |
| 72 |
<strong class="imagify-user-plan-label"><?php echo $user ? esc_html( $user->plan_label ) : ''; ?></strong> |
| 73 |
</h2> |
| 74 |
<?php |
| 75 |
} else { |
| 76 |
?> |
| 77 |
<h2 class="imagify-options-title"><?php esc_html_e( 'Your Account', 'imagify' ); ?></h2> |
| 78 |
<p class="imagify-options-subtitle"><?php esc_html_e( 'Options page isn’t available until you enter your API Key', 'imagify' ); ?></p> |
| 79 |
<?php |
| 80 |
} |
| 81 |
?> |
| 82 |
|
| 83 |
<?php |
| 84 |
/** |
| 85 |
* API key field. |
| 86 |
*/ |
| 87 |
$options = Imagify_Options::get_instance(); |
| 88 |
|
| 89 |
if ( ! $options->get( 'api_key' ) ) { |
| 90 |
?> |
| 91 |
<p class="imagify-api-key-invite"><?php esc_html_e( 'Don\'t have an API Key yet?', 'imagify' ); ?></p> |
| 92 |
|
| 93 |
<p><a id="imagify-signup" class="button imagify-button-secondary" href="<?php echo esc_url( imagify_get_external_url( 'register' ) ); ?>" target="_blank"><?php esc_html_e( 'Create a Free API Key', 'imagify' ); ?></a></p> |
| 94 |
<?php |
| 95 |
} |
| 96 |
?> |
| 97 |
|
| 98 |
<div class="imagify-api-line"> |
| 99 |
<label for="api_key"><?php echo $options->get( 'api_key' ) ? esc_html__( 'API Key', 'imagify' ) : esc_html__( 'Enter Your API Key Below', 'imagify' ); ?></label> |
| 100 |
<input type="text" size="35" value="<?php echo esc_attr( $options->get( 'api_key' ) ); ?>" name="<?php echo $options->get_option_name(); ?>[api_key]" id="api_key"> |
| 101 |
<?php |
| 102 |
if ( imagify_valid_key() ) { |
| 103 |
?> |
| 104 |
|
| 105 |
<span id="imagify-check-api-container" class="imagify-valid"> |
| 106 |
<span class="imagify-icon">✓</span> <?php esc_html_e( 'Your API key is valid.', 'imagify' ); ?> |
| 107 |
</span> |
| 108 |
|
| 109 |
<?php |
| 110 |
} elseif ( ! imagify_valid_key() && $options->get( 'api_key' ) ) { |
| 111 |
?> |
| 112 |
|
| 113 |
<span id="imagify-check-api-container"> |
| 114 |
<span class="dashicons dashicons-no"></span> <?php esc_html_e( 'Your API key isn\'t valid!', 'imagify' ); ?> |
| 115 |
</span> |
| 116 |
|
| 117 |
<?php |
| 118 |
} |
| 119 |
?> |
| 120 |
<input id="check_api_key" type="hidden" value="<?php echo esc_attr( $options->get( 'api_key' ) ); ?>" name="check_api_key"> |
| 121 |
</div><!-- .imagify-api-line --> |
| 122 |
<?php |
| 123 |
} |
| 124 |
?> |
| 125 |
</div> |
| 126 |
<?php |
| 127 |
|