PluginProbe
Imagify Image Optimization: Optimize Images | Compress & Convert to WebP/AVIF / 2.3.3
Imagify Image Optimization: Optimize Images | Compress & Convert to WebP/AVIF v2.3.3
2.3.4 2.3.3 2.3.2 2.3.1 2.3.0 2.2.9 2.2.8 trunk 1.10 1.3.3 1.3.4 1.3.5 1.3.5.1 1.3.5.2 1.3.6 1.3.6.1 1.4 1.4.1 1.4.2 1.4.3 1.4.4 1.4.5 1.4.6 1.4.7 1.5 All 103 releases
imagify / classes / Tools / InternalStateList.php

InternalStateList.php in Imagify Image Optimization: Optimize Images | Compress & Convert to WebP/AVIF 2.3.3, at classes/Tools/InternalStateList.php

88 lines 3.2 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * AUTOLOADER-SAFE FILE — DO NOT ADD declare(strict_types=1) OR use IMPORTS.
4 *
5 * This file is require_once'd directly from uninstall.php, which runs BEFORE
6 * the PSR-4 autoloader is registered. Any top-level `use` statement or
7 * `declare(strict_types=1)` directive is safe on its own, but `use` imports
8 * referencing unavailable classes cause a fatal PHP error at that early stage.
9 *
10 * Rules for this file:
11 * - NO declare(strict_types=1) at the top level.
12 * - NO use import statements of any kind.
13 * - Only a namespace declaration and a class with public static methods.
14 * - No constructor, no instance state, no dependencies.
15 */
16
17 namespace Imagify\Tools;
18
19 /**
20 * Single source of truth for all internal state that the reset tool must clear.
21 *
22 * Both ResetInternalState (the live reset service) and uninstall.php iterate
23 * the arrays returned here. Add a new transient / hook / pattern in ONE place.
24 */
25 class InternalStateList {
26
27 /**
28 * Returns the list of bulk-optimization transient names to delete.
29 *
30 * This is a SUPERSET of Bulk::delete_transients_data():
31 * - imagify_bulk_optimization_result and imagify_bulk_optimization_infos
32 * are intentional additions not cleared by Bulk deactivation.
33 * - imagify_bulk_optimization_level is a stale artifact from the old
34 * WP_Background_Process implementation, retained here for hygiene on
35 * upgraded sites.
36 *
37 * @return array<string>
38 */
39 public static function get_bulk_transients(): array {
40 return [
41 'imagify_custom-folders_optimize_running',
42 'imagify_wp_optimize_running',
43 'imagify_bulk_optimization_complete',
44 'imagify_missing_next_gen_total',
45 'imagify_bulk_optimization_result',
46 'imagify_bulk_optimization_infos',
47 'imagify_bulk_optimization_level', // Stale artifact from old WP_Background_Process, retained for hygiene on upgraded sites.
48 ];
49 }
50
51 /**
52 * Returns raw LIKE pattern templates for process-lock and legacy RPC transients.
53 *
54 * These are plain strings where `%` is a wildcard placeholder and `_` is a
55 * literal underscore. Callers must pass each part through $wpdb->esc_like()
56 * before assembling the final LIKE expression — do NOT use these strings
57 * directly as SQL LIKE patterns.
58 *
59 * @return array<string>
60 */
61 public static function get_locked_transient_patterns(): array {
62 return [
63 '_transient_%imagify-auto-optimize-%', // Legacy/deprecated, retained for hygiene on older installs.
64 '_transient_%imagify_rpc_%', // Legacy/deprecated.
65 '_transient_imagify_%_process_locked',
66 '_site_transient_imagify_%_process_lock%',
67 // Flags an attachment whose scaled version came from the browser, on WP 7.1+.
68 '_transient_imagify_client_side_scaled_%',
69 '_transient_timeout_imagify_client_side_scaled_%',
70 // Flags an attachment whose sub sizes the browser is still to send, on WP 7.1+.
71 '_transient_imagify_awaiting_subsizes_%',
72 '_transient_timeout_imagify_awaiting_subsizes_%',
73 ];
74 }
75
76 /**
77 * Returns the ActionScheduler hook names to unschedule.
78 *
79 * @return array<string>
80 */
81 public static function get_scheduler_hooks(): array {
82 return [
83 'imagify_optimize_media',
84 'imagify_convert_next_gen',
85 ];
86 }
87 }
88