PluginProbe
Image Optimizer – Compress Images and Convert to WebP or AVIF / 1.0.0
Image Optimizer – Compress Images and Convert to WebP or AVIF v1.0.0
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
image-optimization / modules / optimization / rest / get-bulk-optimization-operations.php

get-bulk-optimization-operations.php in Image Optimizer – Compress Images and Convert to WebP or AVIF 1.0.0, at modules/optimization/rest/get-bulk-optimization-operations.php

39 lines 859 B
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 namespace ImageOptimizer\Modules\Optimization\Rest;
4
5 use ImageOptimizer\Modules\Optimization\Classes\Bulk_Optimization;
6 use ImageOptimizer\Modules\Optimization\Classes\Route_Base;
7 use Throwable;
8
9 if ( ! defined( 'ABSPATH' ) ) {
10 exit; // Exit if accessed directly.
11 }
12
13 class Get_Bulk_Optimization_Operations extends Route_Base {
14 protected string $path = 'bulk/operations';
15
16 public function get_name(): string {
17 return 'bulk-optimization-operations';
18 }
19
20 public function get_methods(): array {
21 return [ 'GET' ];
22 }
23
24 public function GET() {
25 try {
26 $operations = Bulk_Optimization::get_processed_images();
27
28 return $this->respond_success_json([
29 'operations' => $operations,
30 ]);
31 } catch ( Throwable $t ) {
32 return $this->respond_error_json([
33 'message' => $t->getMessage(),
34 'code' => 'internal_server_error',
35 ]);
36 }
37 }
38 }
39