PluginProbe
Image Optimization – Compress Images and Convert to WebP or AVIF / 1.6.6
Image Optimization – Compress Images and Convert to WebP or AVIF v1.6.6
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 1.6.6 All 32 releases
image-optimization / modules / backups / rest / remove-backups.php

remove-backups.php in Image Optimization – Compress Images and Convert to WebP or AVIF 1.6.6, at modules/backups/rest/remove-backups.php

47 lines 941 B
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 namespace ImageOptimization\Modules\Backups\Rest;
4
5 use ImageOptimization\Modules\Backups\Classes\{
6 Route_Base,
7 Remove_All_Backups,
8 };
9 use Throwable;
10 use WP_REST_Request;
11
12 if ( ! defined( 'ABSPATH' ) ) {
13 exit; // Exit if accessed directly.
14 }
15
16 class Remove_Backups extends Route_Base {
17 const NONCE_NAME = 'image-optimization-remove-backups';
18
19 protected string $path = '';
20
21 public function get_name(): string {
22 return 'remove-backups';
23 }
24
25 public function get_methods(): array {
26 return [ 'DELETE' ];
27 }
28
29 public function DELETE( WP_REST_Request $request ) {
30 $this->verify_nonce_and_capability(
31 $request->get_param( self::NONCE_NAME ),
32 self::NONCE_NAME
33 );
34
35 try {
36 Remove_All_Backups::find_and_schedule_removing();
37
38 return $this->respond_success_json();
39 } catch ( Throwable $t ) {
40 return $this->respond_error_json([
41 'message' => $t->getMessage(),
42 'code' => 'internal_server_error',
43 ]);
44 }
45 }
46 }
47