← All changes
|
modules/optimization/rest/get-bulk-optimization-images.php
+8
-12
1.6.0
→
trunk
View file →
| @@ -2,14 +2,13 @@ | ||
| 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 | 9 | |
| 10 | 10 | use Throwable; |
| 11 | -use WP_REST_Request; | |
| 12 | 11 | |
| 13 | 12 | if ( ! defined( 'ABSPATH' ) ) { |
| 14 | 13 | exit; // Exit if accessed directly. |
| 15 | 14 | } |
| @@ -24,20 +23,17 @@ | ||
| 24 | 23 | public function get_methods(): array { |
| 25 | 24 | return [ 'GET' ]; |
| 26 | 25 | } |
| 27 | 26 | |
| 28 | - public function GET( WP_REST_Request $request ) { | |
| 29 | - try { | |
| 30 | - $operation_id = $request->get_param( 'operation_id' ); | |
| 27 | + public function GET() { | |
| 28 | + $error = $this->verify_capability(); | |
| 31 | 29 | |
| 32 | - if ( empty( $operation_id ) ) { | |
| 33 | - return $this->respond_error_json([ | |
| 34 | - 'message' => esc_html__( 'Missed operation id', 'image-optimization' ), | |
| 35 | - 'code' => 'bad_request', | |
| 36 | - ]); | |
| 37 | - } | |
| 30 | + if ( $error ) { | |
| 31 | + return $error; | |
| 32 | + } | |
| 38 | 33 | |
| 39 | - $images = Bulk_Optimization_Controller::get_processed_images( $operation_id ); | |
| 34 | + try { | |
| 35 | + $images = Bulk_Optimization_Controller::get_processed_images(); | |
| 40 | 36 | |
| 41 | 37 | return $this->respond_success_json([ |
| 42 | 38 | 'images' => $images, |
| 43 | 39 | ]); |