PluginProbe
Robin Image Optimizer – Unlimited Image Optimization, WebP & AVIF / 2.0.7
Robin Image Optimizer – Unlimited Image Optimization, WebP & AVIF v2.0.7
2.0.7 2.0.6 2.0.5 trunk 1.3.7 1.4.0 1.4.1 1.4.2 1.4.6 1.5.0 1.5.3 1.5.6 1.5.8 1.6.5 1.6.6 1.6.9 1.7.0 1.7.4 1.8.1 1.8.2 1.9.0 2.0.0 2.0.1 2.0.2 2.0.3 All 26 releases
robin-image-optimizer / includes / classes / processing / class-rio-nextgen-processing.php
class-rio-nextgen-processing.php
56 lines 1.3 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 use WBCR\Factory_Processing_759\WP_Background_Process;
4
5 // Exit if accessed directly
6 if ( ! defined( 'ABSPATH' ) ) {
7 exit;
8 }
9
10 /**
11 * Класс для работы оптимизации в фоне
12 *
13 * @version 1.0
14 */
15 class WRIO_Nextgen_Processing extends WRIO_Processing {
16
17 /**
18 * @return int Count of pushed queue
19 */
20 public function push_items() {
21 $attachment_ids = [];
22 if ( $this->scope === 'nextgen' ) {
23 $nextgen_gallery = WRIO_Nextgen_Gallery::get_instance();
24 $attachment_ids = $nextgen_gallery->getUnoptimizedImages();
25 }
26
27 foreach ( $attachment_ids as $attachment_id ) {
28 $this->push_to_queue( $attachment_id );
29 }
30
31 return $this->count_queue();
32 }
33
34 /**
35 * Метод оптимизирует изображения при выполнении задачи
36 *
37 * @param int $image
38 *
39 * @return bool
40 */
41 protected function task( $image ) {
42 if ( $image ) {
43 WRIO_Plugin::app()->logger->info( sprintf( 'Start optimize attachment: %s', $image ) );
44
45 if ( $this->scope === 'nextgen' ) {
46 $nextgen_gallery = WRIO_Nextgen_Gallery::get_instance();
47 $result = $nextgen_gallery->optimizeNextgenImage( $image );
48 }
49
50 WRIO_Plugin::app()->logger->info( sprintf( 'End optimize attachment: %s', $image ) );
51 }
52
53 return false;
54 }
55 }
56