← All changes
|
modules/optimization/templates/list-view/error.php
+47
-16
1.1.0
→
1.7.7
View file →
| @@ -1,5 +1,11 @@ | ||
| 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 | } |
| 5 | 11 | ?> |
| @@ -5,14 +11,15 @@ | ||
| 5 | 11 | ?> |
| 6 | 12 | <div class="image-optimization-control image-optimization-control--list-view image-optimization-control--error" |
| 7 | 13 | data-image-optimization-context="list-view" |
| 8 | 14 | data-image-optimization-status="error" |
| 9 | - data-image-allow-retry="<?php echo esc_attr( $args['allow_retry'] ); ?>" | |
| 15 | + data-image-optimization-allow-retry="<?php echo esc_attr( $args['allow_retry'] ); ?>" | |
| 10 | 16 | data-image-optimization-action="<?php echo esc_attr( $args['action'] ); ?>" |
| 11 | 17 | data-image-optimization-image-id="<?php echo esc_attr( $args['image_id'] ); ?>" |
| 12 | 18 | data-image-optimization-can-be-restored="<?php echo esc_attr( $args['can_be_restored'] ); ?>"> |
| 13 | 19 | |
| 14 | 20 | <?php |
| 21 | + $error_type = isset( $args['optimization_error_type'] ) ? $args['optimization_error_type'] : ''; | |
| 15 | 22 | $message = esc_html( $args['message'] ); |
| 16 | 23 | |
| 17 | 24 | if ( false === $args['allow_retry'] ) { |
| 18 | 25 | $message_chunks = explode( '. ', $message, 2 ); |
| @@ -24,21 +31,45 @@ | ||
| 24 | 31 | } |
| 25 | 32 | } |
| 26 | 33 | ?> |
| 27 | 34 | |
| 28 | - <span class='image-optimization-control__error-message'><?php echo $message; ?></span> | |
| 35 | + <span class='image-optimization-control__error-message'> | |
| 36 | + <?php echo wp_kses_post( $message ); ?> | |
| 37 | + </span> | |
| 29 | 38 | |
| 30 | - <?php if ( $args['allow_retry'] ) { ?> | |
| 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 | - <?php } ?> | |
| 39 | + <?php | |
| 40 | + if ( Image_Optimization_Error_Type::AUTH_ERROR === $error_type ) { | |
| 41 | + ?> | |
| 42 | + <a class="button button-secondary button-large image-optimization-control__button" | |
| 43 | + href="<?php echo esc_url( admin_url( 'admin.php?page=' . Settings_Module::SETTING_BASE_SLUG . '&action=connect' ) ); ?>" | |
| 44 | + target="_blank" rel="noopener noreferrer"> | |
| 45 | + <?php esc_html_e( 'Connect', 'image-optimization' ); ?> | |
| 46 | + </a> | |
| 47 | + <?php | |
| 48 | + } if ( Image_Optimization_Error_Type::CONNECTION_ERROR === $error_type ) { | |
| 49 | + ?> | |
| 50 | + <button class="button button-secondary button-large button-link-delete image-optimization-control__button image-optimization-control__button--try-again" | |
| 51 | + type="button"> | |
| 52 | + <?php esc_html_e( 'Try again', 'image-optimization' ); ?> | |
| 53 | + </button> | |
| 54 | + <?php | |
| 55 | + } elseif ( isset( $args['images_left'] ) && 0 === $args['images_left'] ) { | |
| 56 | + if ( Core_Module::is_elementor_one() ) { | |
| 57 | + return; | |
| 58 | + } | |
| 59 | + ?> | |
| 60 | + <a class="button button-secondary button-large image-optimization-control__button" | |
| 61 | + href="<?php echo esc_url( Utils::get_upgrade_link( 'https://go.elementor.com/io-panel-upgrade/' ) ); ?>" | |
| 62 | + target="_blank" rel="noopener noreferrer"> | |
| 63 | + <?php esc_html_e( 'Upgrade', 'image-optimization' ); ?> | |
| 64 | + </a> | |
| 65 | + <?php | |
| 66 | + } elseif ( $args['allow_retry'] ) { | |
| 67 | + ?> | |
| 68 | + <button class="button button-secondary button-large button-link-delete image-optimization-control__button image-optimization-control__button--try-again" | |
| 69 | + type="button"> | |
| 70 | + <?php esc_html_e( 'Try again', 'image-optimization' ); ?> | |
| 71 | + </button> | |
| 72 | + <?php | |
| 73 | + } | |
| 74 | + ?> | |
| 44 | 75 | </div> |