first commit

This commit is contained in:
User A0264400
2026-04-01 23:20:16 +03:00
commit a766acdc90
23071 changed files with 4933189 additions and 0 deletions

View File

@@ -0,0 +1,55 @@
<?php
use WBCR\Factory_Processing_759\WP_Background_Process;
// Exit if accessed directly
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
/**
* Класс для работы оптимизации в фоне
*
* @version 1.0
*/
class WRIO_Folder_Processing extends WRIO_Processing {
/**
* @return int Count of pushed queue
*/
public function push_items() {
$attachment_ids = [];
if ( $this->scope === 'custom-folders' ) {
$cf = WRIO_Custom_Folders::get_instance();
$attachment_ids = $cf->getUnoptimizedImages();
}
foreach ( $attachment_ids as $attachment_id ) {
$this->push_to_queue( $attachment_id );
}
return $this->count_queue();
}
/**
* Метод оптимизирует изображения при выполнении задачи
*
* @param int $image
*
* @return bool
*/
protected function task( $image ) {
if ( $image ) {
WRIO_Plugin::app()->logger->info( sprintf( 'Start optimize custom folder image: %s', $image ) );
if ( $this->scope === 'custom-folders' ) {
$cf = WRIO_Custom_Folders::get_instance();
$result = $cf->optimizeImage( $image );
}
WRIO_Plugin::app()->logger->info( sprintf( 'End optimize custom folder image: %s', $image ) );
}
return false;
}
}

View File

@@ -0,0 +1,94 @@
<?php
use WBCR\Factory_Processing_759\WP_Background_Process;
// Exit if accessed directly
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
/**
* Класс для работы AVIF конвертации в фоне
* Class for AVIF image format conversion background processing
*
* @version 1.6.0
* @since 1.6.0
*/
class WRIO_Media_Processing_Avif extends WRIO_Processing {
/**
* @var string
*/
protected $action = 'convert_process';
/**
* @var string Format type
*/
protected $format = 'avif';
/**
* Constructor
*
* @param string $scope Processing scope
*/
public function __construct( $scope ) {
parent::__construct( $scope );
}
/**
* Push items to queue
*
* @return int Number of items in queue
*/
public function push_items() {
$attachment_ids = [];
if ( $this->scope === 'media-library_avif' ) {
$media_library = WRIO_Media_Library::get_instance();
$attachment_ids = $media_library->getUnconvertedImages( 'avif' );
}
foreach ( $attachment_ids as $attachment_id ) {
$this->push_to_queue( $attachment_id );
}
return $this->count_queue();
}
/**
* Метод конвертирует изображения в AVIF при выполнении задачи
* Method converts images to AVIF when executing task
*
* @param int $image Attachment ID
*
* @return bool
*/
protected function task( $image ) {
if ( $image ) {
WRIO_Plugin::app()->logger->info( sprintf( 'Start convert attachment #%s to AVIF', $image ) );
if ( $this->scope === 'media-library_avif' ) {
$media_library = WRIO_Media_Library::get_instance();
$media_library->webpConvertAttachment( $image, 'avif' );
}
WRIO_Plugin::app()->logger->info( sprintf( 'End convert attachment #%s to AVIF', $image ) );
}
return false;
}
/**
* Fire after complete handle
* Вызывается после завершения обработки
*
* @return void
*/
protected function handle_after_complete() {
WRIO_Plugin::app()->updatePopulateOption( "{$this->scope}_process_running", false );
WRIO_Plugin::app()->logger->info(
sprintf( 'AVIF conversion background process completed for scope: %s', $this->scope )
);
}
}

View File

@@ -0,0 +1,96 @@
<?php
use WBCR\Factory_Processing_759\WP_Background_Process;
// Exit if accessed directly
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
/**
* Класс для работы оптимизации в фоне
*
* @version 1.0
*/
class WRIO_Media_Processing_Webp extends WRIO_Processing {
/**
* @var string
*/
protected $action = 'convert_process';
/**
* @var string Format type (webp or avif)
*/
protected $format = 'webp';
/**
* Constructor
*
* @param string $scope Processing scope
*/
public function __construct( $scope ) {
parent::__construct( $scope );
// Extract format from scope (e.g., 'media-library_webp' -> 'webp')
if ( $this->scope && strpos( $this->scope, '_' ) !== false ) {
$parts = explode( '_', $this->scope );
$extracted_format = end( $parts );
if ( in_array( $extracted_format, [ 'webp', 'avif' ], true ) ) {
$this->format = $extracted_format;
}
}
}
/**
* @return int Count of pushed queue
*/
public function push_items() {
$attachment_ids = [];
if ( strpos( $this->scope, 'media-library_' ) === 0 ) {
$media_library = WRIO_Media_Library::get_instance();
$attachment_ids = $media_library->getUnconvertedImages( $this->format );
}
foreach ( $attachment_ids as $attachment_id ) {
$this->push_to_queue( $attachment_id );
}
return $this->count_queue();
}
/**
* Метод оптимизирует изображения при выполнении задачи
*
* @param int $image
*
* @return bool
*/
protected function task( $image ) {
if ( $image ) {
WRIO_Plugin::app()->logger->info( sprintf( 'Start convert attachment #%s to %s', $image, $this->format ) );
if ( strpos( $this->scope, 'media-library_' ) === 0 ) {
$media_library = WRIO_Media_Library::get_instance();
$media_library->webpConvertAttachment( $image, $this->format );
}
WRIO_Plugin::app()->logger->info( sprintf( 'End convert attachment #%s to %s', $image, $this->format ) );
}
return false;
}
/**
* Fire after complete handle
*
* @return void
*/
protected function handle_after_complete() {
WRIO_Plugin::app()->updatePopulateOption( "{$this->scope}_process_running", false );
WRIO_Plugin::app()->logger->info(
sprintf( '%s conversion background process completed for scope: %s', strtoupper( $this->format ), $this->scope )
);
}
}

View File

@@ -0,0 +1,56 @@
<?php
use WBCR\Factory_Processing_759\WP_Background_Process;
// Exit if accessed directly
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
/**
* Класс для работы оптимизации в фоне
*
* @version 1.0
*/
class WRIO_Media_Processing extends WRIO_Processing {
/**
* @param array $attachment_ids
*
* @return int Count of pushed queue
*/
public function push_items( $attachment_ids = [] ) {
if ( empty( $attachment_ids ) && $this->scope === 'media-library' ) {
$media_library = WRIO_Media_Library::get_instance();
$attachment_ids = $media_library->getUnoptimizedImages();
}
foreach ( $attachment_ids as $attachment_id ) {
$this->push_to_queue( $attachment_id );
}
return $this->count_queue();
}
/**
* Метод оптимизирует изображения при выполнении задачи
*
* @param int $image
*
* @return bool
*/
protected function task( $image ) {
if ( $image ) {
WRIO_Plugin::app()->logger->info( sprintf( 'Start optimize attachment: %s', $image ) );
if ( $this->scope === 'media-library' ) {
$media_library = WRIO_Media_Library::get_instance();
$result = $media_library->optimizeAttachment( $image );
}
WRIO_Plugin::app()->logger->info( sprintf( 'End optimize attachment: %s', $image ) );
}
return false;
}
}

View File

@@ -0,0 +1,55 @@
<?php
use WBCR\Factory_Processing_759\WP_Background_Process;
// Exit if accessed directly
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
/**
* Класс для работы оптимизации в фоне
*
* @version 1.0
*/
class WRIO_Nextgen_Processing extends WRIO_Processing {
/**
* @return int Count of pushed queue
*/
public function push_items() {
$attachment_ids = [];
if ( $this->scope === 'nextgen' ) {
$nextgen_gallery = WRIO_Nextgen_Gallery::get_instance();
$attachment_ids = $nextgen_gallery->getUnoptimizedImages();
}
foreach ( $attachment_ids as $attachment_id ) {
$this->push_to_queue( $attachment_id );
}
return $this->count_queue();
}
/**
* Метод оптимизирует изображения при выполнении задачи
*
* @param int $image
*
* @return bool
*/
protected function task( $image ) {
if ( $image ) {
WRIO_Plugin::app()->logger->info( sprintf( 'Start optimize attachment: %s', $image ) );
if ( $this->scope === 'nextgen' ) {
$nextgen_gallery = WRIO_Nextgen_Gallery::get_instance();
$result = $nextgen_gallery->optimizeNextgenImage( $image );
}
WRIO_Plugin::app()->logger->info( sprintf( 'End optimize attachment: %s', $image ) );
}
return false;
}
}

View File

@@ -0,0 +1,67 @@
<?php
use WBCR\Factory_Processing_759\WP_Background_Process;
// Exit if accessed directly
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
/**
* Класс для работы оптимизации в фоне
*
* @version 1.0
*/
abstract class WRIO_Processing extends WP_Background_Process {
/**
* @var string
*/
protected $prefix = 'wrio';
/**
* @var string
*/
protected $action = 'optimize_process';
/**
* @var string
*/
public $scope;
/**
* Processing constructor.
*
* @param $scope
*/
public function __construct( $scope ) {
$this->scope = $scope;
$this->action = "{$this->action}_{$scope}";
parent::__construct();
}
abstract public function push_items();
/**
* Fire before start handle the tasks
*/
protected function handle_before() {
WRIO_Plugin::app()->logger->info( 'START auto optimize process.' );
}
/**
* Fire after end handle the tasks
*/
protected function handle_after() {
WRIO_Plugin::app()->logger->info( 'END auto optimize process.' );
}
/**
* Fire after complete handle
*
* @return void
*/
protected function handle_after_complete() {
WRIO_Plugin::app()->updatePopulateOption( 'process_running', false );
}
}