| @@ -1,13 +1,21 @@ | ||
| 1 | 1 | <?php |
| 2 | + | |
| 3 | +use ImageOptimization\Classes\Image\Image_Optimization_Error_Type; | |
| 4 | +use ImageOptimization\Classes\Utils; | |
| 5 | +use ImageOptimization\Modules\Settings\Module as Settings_Module; | |
| 6 | +use ImageOptimization\Modules\Core\Module as Core_Module; | |
| 7 | + | |
| 2 | 8 | if ( ! defined( 'ABSPATH' ) ) { |
| 3 | 9 | exit; // Exit if accessed directly. |
| 4 | 10 | } |
| 11 | + | |
| 12 | +$error_type = isset( $args['optimization_error_type'] ) ? $args['optimization_error_type'] : ''; | |
| 5 | 13 | ?> |
| 6 | 14 | <div class="image-optimization-control image-optimization-control--meta-box image-optimization-control--error" |
| 7 | 15 | data-image-optimization-context="meta-box" |
| 8 | 16 | data-image-optimization-status="error" |
| 9 | - data-image-allow-retry="<?php echo esc_attr( $args['allow_retry'] ); ?>" | |
| 17 | + data-image-optimization-allow-retry="<?php echo esc_attr( $args['allow_retry'] ); ?>" | |
| 10 | 18 | data-image-optimization-action="<?php echo esc_attr( $args['action'] ); ?>" |
| 11 | 19 | data-image-optimization-image-id="<?php echo esc_attr( $args['image_id'] ); ?>" |
| 12 | 20 | data-image-optimization-can-be-restored="<?php echo esc_attr( $args['can_be_restored'] ); ?>"> |
| 13 | 21 | <p class="image-optimization-control__property"> |
| @@ -25,21 +33,40 @@ | ||
| 25 | 33 | <?php echo esc_html( $args['message'] ); ?> |
| 26 | 34 | </span> |
| 27 | 35 | </p> |
| 28 | 36 | |
| 29 | - <?php if ( $args['allow_retry'] ) { ?> | |
| 30 | - <div class="image-optimization-control__action-button-wrapper"> | |
| 31 | - <?php if ( isset( $args['images_left'] ) && 0 === $args['images_left'] ) { ?> | |
| 32 | - <a class="button button-secondary button-large image-optimization-control__button" | |
| 33 | - href="https://go.elementor.com/io-panel-upgrade/" | |
| 34 | - target="_blank" rel="noopener noreferrer"> | |
| 35 | - <?php esc_html_e( 'Upgrade', 'image-optimization' ); ?> | |
| 36 | - </a> | |
| 37 | - <?php } else { ?> | |
| 38 | - <button class="button button-secondary button-large button-link-delete image-optimization-control__button image-optimization-control__button--try-again" | |
| 39 | - type="button"> | |
| 40 | - <?php esc_html_e( 'Try again', 'image-optimization' ); ?> | |
| 41 | - </button> | |
| 42 | - <?php } ?> | |
| 43 | - </div> | |
| 44 | - <?php } ?> | |
| 37 | + <div class="image-optimization-control__action-button-wrapper"> | |
| 38 | + <?php | |
| 39 | + if ( Image_Optimization_Error_Type::AUTH_ERROR === $error_type ) { | |
| 40 | + ?> | |
| 41 | + <a class="button button-secondary button-large image-optimization-control__button" | |
| 42 | + href="<?php echo esc_url( admin_url( 'admin.php?page=' . Settings_Module::SETTING_BASE_SLUG . '&action=connect' ) ); ?>" | |
| 43 | + target="_blank" rel="noopener noreferrer"> | |
| 44 | + <?php esc_html_e( 'Connect', 'image-optimization' ); ?> | |
| 45 | + </a> | |
| 46 | + <?php | |
| 47 | + } if ( Image_Optimization_Error_Type::CONNECTION_ERROR === $error_type ) { | |
| 48 | + ?> | |
| 49 | + <button class="button button-secondary button-large button-link-delete image-optimization-control__button image-optimization-control__button--try-again" | |
| 50 | + type="button"> | |
| 51 | + <?php esc_html_e( 'Try again', 'image-optimization' ); ?> | |
| 52 | + </button> | |
| 53 | + <?php | |
| 54 | + } elseif ( isset( $args['images_left'] ) && 0 === $args['images_left'] && ! Core_Module::is_elementor_one() ) { | |
| 55 | + ?> | |
| 56 | + <a class="button button-secondary button-large image-optimization-control__button" | |
| 57 | + href="<?php echo esc_url( Utils::get_upgrade_link( 'https://go.elementor.com/io-panel-upgrade/' ) ); ?>" | |
| 58 | + target="_blank" rel="noopener noreferrer"> | |
| 59 | + <?php esc_html_e( 'Upgrade', 'image-optimization' ); ?> | |
| 60 | + </a> | |
| 61 | + <?php | |
| 62 | + } elseif ( $args['allow_retry'] ) { | |
| 63 | + ?> | |
| 64 | + <button class="button button-secondary button-large button-link-delete image-optimization-control__button image-optimization-control__button--try-again" | |
| 65 | + type="button"> | |
| 66 | + <?php esc_html_e( 'Try again', 'image-optimization' ); ?> | |
| 67 | + </button> | |
| 68 | + <?php | |
| 69 | + } | |
| 70 | + ?> | |
| 71 | + </div> | |
| 45 | 72 | </div> |