PluginProbe
Image Optimizer – Compress Images and Convert to WebP or AVIF / 1.7.7
Image Optimizer – Compress Images and Convert to WebP or AVIF v1.7.7
1.7.7 1.7.6 1.7.5 1.7.4 trunk 1.0.0 1.0.1 1.0.2 1.1.0 1.2.0 1.2.1 1.3.0 1.4.0 1.4.1 1.5.0 1.5.1 1.5.2 1.5.3 1.5.4 1.6.0 1.6.1 1.6.2 1.6.3 1.6.4 1.6.5 All 33 releases
← All changes | modules/optimization/rest/cancel-bulk-optimization.php +9 -5 1.1.01.7.7 View file →
@@ -2,14 +2,14 @@
2 2
3 3 namespace ImageOptimization\Modules\Optimization\Rest;
4 4
5 5 use ImageOptimization\Modules\Optimization\Classes\{
6 - Bulk_Optimization_Controller,
6 + Bulk_Optimization\Bulk_Optimization_Controller,
7 7 Route_Base,
8 8 };
9 -use ImageOptimization\Modules\Oauth\Components\Connect;
10 9 use Throwable;
11 10 use WP_REST_Request;
11 +use ImageOptimization\Plugin;
12 12
13 13 if ( ! defined( 'ABSPATH' ) ) {
14 14 exit; // Exit if accessed directly.
15 15 }
@@ -27,14 +27,18 @@
27 27 return [ 'POST' ];
28 28 }
29 29
30 30 public function POST( WP_REST_Request $request ) {
31 - $this->verify_nonce_and_capability(
31 + $error = $this->verify_nonce_and_capability(
32 32 $request->get_param( self::NONCE_NAME ),
33 33 self::NONCE_NAME
34 34 );
35 35
36 - if ( ! Connect::is_activated() ) {
36 + if ( $error ) {
37 + return $error;
38 + }
39 +
40 + if ( ! Plugin::instance()->modules_manager->get_modules( 'connect-manager' )->connect_instance->is_activated() ) {
37 41 return $this->respond_error_json([
38 42 'message' => esc_html__( 'Invalid activation', 'image-optimization' ),
39 43 'code' => 'unauthorized',
40 44 ]);
@@ -49,9 +53,9 @@
49 53 'code' => 'forbidden',
50 54 ]);
51 55 }
52 56
53 - Bulk_Optimization_Controller::cancel_bulk_optimization();
57 + Bulk_Optimization_Controller::delete_bulk_optimization();
54 58
55 59 return $this->respond_success_json();
56 60 } catch ( Throwable $t ) {
57 61 return $this->respond_error_json([