Recent

Processorclass

Processor

Processes the conversion queue in bounded batches for all entry points.

Namespace: WebberZone\Image_Optimizer
Since: 1.0.0
Source: includes/class-processor.php line 21

Methods

__construct()

Constructor.

Since: 1.0.0
Line: 52

public function __construct(  );

add_cron_schedule() static

Register the one minute schedule used by the background worker.

Since: 1.0.0
Line: 65

static public function add_cron_schedule( $schedules ): array<string,;
Type Name Description
mixed $schedules

Returns: array<string, — array<string, mixed>> Schedules.

run_batch() static

Process one batch, sized from the settings.

Since: 1.0.0
Line: 84

static public function run_batch( ?int $limit = ... ): array;
Type Name Description
int&#124;null $limit Batch size, or null to read it from the settings.

Returns: array — int, converted: int, failed: int, skipped: int, saved: int, remaining: int, locked: bool} Result.

process_attachment() static

Convert one attachment outside the batch cadence, for the “Optimize” action.

Since: 1.0.0
Line: 159

static public function process_attachment( int $attachment_id, bool $force = ... ): array;
Type Name Description
int $attachment_id Attachment ID.
bool $force Whether to re-encode files that already have a valid sidecar.

Returns: array — string, saved: int, error: string, locked: bool} Result.

run_cron() static

Cron callback.

Since: 1.0.0
Line: 267

static public function run_cron(  ): void;

Returns: void

get_remaining() static

Number of attachments still waiting.

Since: 1.0.0
Line: 283

static public function get_remaining(  ): int;

Returns: int — Remaining count.

maybe_schedule() static

Schedule the background worker when there is work and it is enabled.

Since: 1.0.0
Line: 296

static public function maybe_schedule(  ): void;

Returns: void

unschedule() static

Remove the background worker schedule.

Since: 1.0.0
Line: 313

static public function unschedule(  ): void;

Returns: void