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 / classes / remove-all-backups.php

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

32 lines 737 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\Classes;
4
5 use ImageOptimizer\Classes\Async_Operation\{
6 Async_Operation,
7 Async_Operation_Hook,
8 Async_Operation_Queue,
9 };
10 use ImageOptimizer\Classes\Image\Image_Query_Builder;
11
12 class Remove_All_Backups {
13 private const CHUNK_SIZE = 100;
14
15 public static function find_and_schedule_removing(): void {
16 $query = ( new Image_Query_Builder() )
17 ->return_images_only_with_backups()
18 ->execute();
19
20 $attachment_ids = $query->posts;
21 $chunks = array_chunk( $attachment_ids, self::CHUNK_SIZE );
22
23 foreach ( $chunks as $chunk ) {
24 Async_Operation::create(
25 Async_Operation_Hook::REMOVE_MANY_BACKUPS,
26 [ 'attachment_ids' => $chunk ],
27 Async_Operation_Queue::BACKUP
28 );
29 }
30 }
31 }
32