class-rio-folder-processing.php
5 months ago
class-rio-media-processing-avif.php
3 months ago
class-rio-media-processing-webp.php
3 months ago
class-rio-media-processing.php
3 months ago
class-rio-nextgen-processing.php
5 months ago
class-rio-processing.php
5 months ago
class-rio-folder-processing.php
56 lines
| 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_Folder_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 === 'custom-folders' ) { |
| 23 | $cf = WRIO_Custom_Folders::get_instance(); |
| 24 | $attachment_ids = $cf->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 custom folder image: %s', $image ) ); |
| 44 | |
| 45 | if ( $this->scope === 'custom-folders' ) { |
| 46 | $cf = WRIO_Custom_Folders::get_instance(); |
| 47 | $result = $cf->optimizeImage( $image ); |
| 48 | } |
| 49 | |
| 50 | WRIO_Plugin::app()->logger->info( sprintf( 'End optimize custom folder image: %s', $image ) ); |
| 51 | } |
| 52 | |
| 53 | return false; |
| 54 | } |
| 55 | } |
| 56 |