| @@ -29,8 +29,9 @@ | ||
| 29 | 29 | |
| 30 | 30 | use Throwable; |
| 31 | 31 | |
| 32 | 32 | use ImageOptimization\Plugin; |
| 33 | +use WP_Post; | |
| 33 | 34 | |
| 34 | 35 | if ( ! defined( 'ABSPATH' ) ) { |
| 35 | 36 | exit; // Exit if accessed directly. |
| 36 | 37 | } |
| @@ -94,13 +95,13 @@ | ||
| 94 | 95 | /** |
| 95 | 96 | * Adds optimization control to media modals. |
| 96 | 97 | * |
| 97 | 98 | * @param array $form_fields |
| 98 | - * @param \WP_Post $post | |
| 99 | + * @param WP_Post $post | |
| 99 | 100 | * |
| 100 | 101 | * @return array |
| 101 | 102 | */ |
| 102 | - public function add_media_modal_details( array $form_fields, \WP_Post $post ): array { | |
| 103 | + public function add_media_modal_details( array $form_fields, WP_Post $post ): array { | |
| 103 | 104 | $form_fields[ self::DETAILS_MODAL_FIELD_ID ] = [ |
| 104 | 105 | 'label' => '', |
| 105 | 106 | 'input' => 'hidden', |
| 106 | 107 | 'value' => $this->get_optimization_control_html( 'details-view', $post->ID ), |
| @@ -145,9 +146,9 @@ | ||
| 145 | 146 | $module = Plugin::instance()->modules_manager->get_modules( 'connect-manager' ); |
| 146 | 147 | |
| 147 | 148 | try { |
| 148 | 149 | if ( ! $module->connect_instance->is_connected() || ! $module->connect_instance->is_activated() ) { |
| 149 | - throw new Auth_Error( 'You have to activate your license to use Image Optimizer' ); | |
| 150 | + throw new Auth_Error( esc_html__( 'You need to connect an Elementor account', 'image-optimization' ) ); | |
| 150 | 151 | } |
| 151 | 152 | |
| 152 | 153 | Validate_Image::is_valid( $image_id ); |
| 153 | 154 | |
| @@ -208,8 +209,9 @@ | ||
| 208 | 209 | |
| 209 | 210 | Module::load_template( $context, 'optimized', array_merge( |
| 210 | 211 | $global_context, [ |
| 211 | 212 | 'sizes_optimized_count' => $stats['optimized_image_count'], |
| 213 | + 'sizes_total' => $stats['total_image_count'], | |
| 212 | 214 | 'saved' => $saved, |
| 213 | 215 | 'is_losseless_and_webp' => $is_losseless_and_webp, |
| 214 | 216 | ] |
| 215 | 217 | ) ); |
| @@ -275,9 +277,10 @@ | ||
| 275 | 277 | } catch ( Auth_Error $ae ) { |
| 276 | 278 | Module::load_template( $context, 'error', array_merge( |
| 277 | 279 | $global_context, [ |
| 278 | 280 | 'action' => 'error', |
| 279 | - 'message' => esc_html__( 'N/A', 'image-optimization' ), | |
| 281 | + 'optimization_error_type' => Image_Optimization_Error_Type::AUTH_ERROR, | |
| 282 | + 'message' => $ae->getMessage(), | |
| 280 | 283 | 'allow_retry' => false, |
| 281 | 284 | ] |
| 282 | 285 | ) ); |
| 283 | 286 | } catch ( Throwable $t ) { |
| @@ -283,8 +286,9 @@ | ||
| 283 | 286 | } catch ( Throwable $t ) { |
| 284 | 287 | Module::load_template( $context, 'error', array_merge( |
| 285 | 288 | $global_context, [ |
| 286 | 289 | 'action' => 'error', |
| 290 | + 'optimization_error_type' => Image_Optimization_Error_Type::GENERIC, | |
| 287 | 291 | 'message' => esc_html__( 'Internal server error', 'image-optimization' ), |
| 288 | 292 | 'allow_retry' => false, |
| 289 | 293 | ] |
| 290 | 294 | ) ); |