PluginProbe
Image Optimizer – Compress Images and Convert to WebP or AVIF / 1.0.1
Image Optimizer – Compress Images and Convert to WebP or AVIF v1.0.1
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 / backups / rest / restore-all.php

restore-all.php in Image Optimizer – Compress Images and Convert to WebP or AVIF 1.0.1, at modules/backups/rest/restore-all.php

43 lines 847 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\Backups\Rest;
4
5 use ImageOptimizer\Modules\Backups\Classes\{
6 Restore_Images,
7 Route_Base,
8 };
9 use Throwable;
10 use WP_REST_Request;
11
12 class Restore_All extends Route_Base {
13 const NONCE_NAME = 'image-optimizer-restore-all';
14
15 protected string $path = 'restore';
16
17 public function get_name(): string {
18 return 'restore-all';
19 }
20
21 public function get_methods(): array {
22 return [ 'POST' ];
23 }
24
25 public function POST( WP_REST_Request $request ) {
26 $this->verify_nonce_and_capability(
27 $request->get_param( self::NONCE_NAME ),
28 self::NONCE_NAME
29 );
30
31 try {
32 Restore_Images::find_and_schedule_restoring();
33
34 return $this->respond_success_json();
35 } catch ( Throwable $t ) {
36 return $this->respond_error_json([
37 'message' => $t->getMessage(),
38 'code' => 'internal_server_error',
39 ]);
40 }
41 }
42 }
43