Original_Backups
Owns immutable backups independently of disposable conversion records.
Namespace: WebberZone\Image_Optimizer
Since: 1.2.0
Source: includes/class-original-backups.php line 21
Methods
get() static
Read the recovery manifest.
Line: 32
static public function get( int $id ): array;
| Type | Name | Description |
|---|---|---|
int |
$id |
Attachment ID. |
Returns: array — array<string, mixed>> Manifest.
save() static
Persist recovery data and verify the database accepted it.
Line: 44
static public function save( int $id, array $data ): bool;
| Type | Name | Description |
|---|---|---|
int |
$id |
Attachment ID. |
array |
$data |
Recovery manifest. |
Returns: bool — Whether persisted.
relative() static
Resolve a regular upload file without following links outside uploads.
Line: 60
static public function relative( string $path ): string;
| Type | Name | Description |
|---|---|---|
string |
$path |
File path. |
Returns: string — Relative path, or empty when unsafe.
root() static
Create the backup root and access-control files.
Line: 80
static public function root( ): string|\WP_Error;
Returns: string|\WP_Error — Root or error.
acquire() static
Acquire an OS lock which is also released on process exit.
Line: 113
static public function acquire( int $id ): resource|\WP_Error;
| Type | Name | Description |
|---|---|---|
int |
$id |
Attachment ID. |
Returns: resource|\WP_Error — Lock handle or error.
locked() static
Execute with automatic lock release.
Line: 154
static public function locked( int $id, callable $callback ): mixed;
| Type | Name | Description |
|---|---|---|
int |
$id |
Attachment ID. |
callable |
$callback |
Operation. |
Returns: mixed — Operation result.
release() static
Release an acquired lock.
Line: 172
static public function release( $handle ): void;
| Type | Name | Description |
|---|---|---|
resource |
$handle |
Lock handle. |
Returns: void
ensure() static
Make and persist the first backup before modifying a file.
Caller must hold the attachment lock.
Line: 191
static public function ensure( int $id, string $path ): array|\WP_Error;
| Type | Name | Description |
|---|---|---|
int |
$id |
Attachment ID. |
string |
$path |
Source file. |
Returns: array|\WP_Error — Backup entry or error.
verified_path() static
Verify a manifest entry before reading a backup.
Line: 270
static public function verified_path( string $relative, array $entry ): string|\WP_Error;
| Type | Name | Description |
|---|---|---|
string |
$relative |
Upload-relative source. |
array |
$entry |
Manifest entry. |
Returns: string|\WP_Error — Verified backup path.
totals() static
Calculate original savings separately from sidecar savings.
Line: 292
static public function totals( array $data ): array;
| Type | Name | Description |
|---|---|---|
array |
$data |
Manifest. |
Returns: array — int, bytes: int, resized: int, compressed: int} Totals.
library_totals() static
Aggregate recorded source savings and backup disk use.
Line: 317
static public function library_totals( ): array;
Returns: array — int> Totals.