PluginProbe
Image Optimizer – Compress Images and Convert to WebP or AVIF / trunk
Image Optimizer – Compress Images and Convert to WebP or AVIF vtrunk
1.7.7 1.7.6 1.7.5 1.7.4 trunk 1.0.0 1.0.1 1.0.2 1.1.0 1.2.0 1.2.1 1.3.0 1.4.0 1.4.1 1.5.0 1.5.1 1.5.2 1.5.3 1.5.4 1.6.0 1.6.1 1.6.2 1.6.3 1.6.4 1.6.5 All 33 releases
← All changes | vendor/woocommerce/action-scheduler/classes/ActionScheduler_Versions.php +40 -13 1.2.1 → trunk View file →
@@ -4,49 +4,75 @@
4 4 * Class ActionScheduler_Versions
5 5 */
6 6 class ActionScheduler_Versions {
7 7 /**
8 + * ActionScheduler_Versions instance.
9 + *
8 10 * @var ActionScheduler_Versions
9 11 */
10 - private static $instance = NULL;
12 + private static $instance = null;
11 13
14 + /**
15 + * Versions.
16 + *
17 + * @var array<string, callable>
18 + */
12 19 private $versions = array();
13 20
21 + /**
22 + * Register version's callback.
23 + *
24 + * @param string $version_string Action Scheduler version.
25 + * @param callable $initialization_callback Callback to initialize the version.
26 + */
14 27 public function register( $version_string, $initialization_callback ) {
15 - if ( isset($this->versions[$version_string]) ) {
16 - return FALSE;
28 + if ( isset( $this->versions[ $version_string ] ) ) {
29 + return false;
17 30 }
18 - $this->versions[$version_string] = $initialization_callback;
19 - return TRUE;
31 + $this->versions[ $version_string ] = $initialization_callback;
32 + return true;
20 33 }
21 34
35 + /**
36 + * Get all versions.
37 + */
22 38 public function get_versions() {
23 39 return $this->versions;
24 40 }
25 41
42 + /**
43 + * Get latest version registered.
44 + */
26 45 public function latest_version() {
27 - $keys = array_keys($this->versions);
28 - if ( empty($keys) ) {
46 + $keys = array_keys( $this->versions );
47 + if ( empty( $keys ) ) {
29 48 return false;
30 49 }
31 50 uasort( $keys, 'version_compare' );
32 - return end($keys);
51 + return end( $keys );
33 52 }
34 53
54 + /**
55 + * Get callback for latest registered version.
56 + */
35 57 public function latest_version_callback() {
36 58 $latest = $this->latest_version();
37 - if ( empty($latest) || !isset($this->versions[$latest]) ) {
59 +
60 + if ( empty( $latest ) || ! isset( $this->versions[ $latest ] ) ) {
38 61 return '__return_null';
39 62 }
40 - return $this->versions[$latest];
63 +
64 + return $this->versions[ $latest ];
41 65 }
42 66
43 67 /**
68 + * Get instance.
69 + *
44 70 * @return ActionScheduler_Versions
45 71 * @codeCoverageIgnore
46 72 */
47 73 public static function instance() {
48 - if ( empty(self::$instance) ) {
74 + if ( empty( self::$instance ) ) {
49 75 self::$instance = new self();
50 76 }
51 77 return self::$instance;
52 78 }
@@ -51,12 +77,13 @@
51 77 return self::$instance;
52 78 }
53 79
54 80 /**
81 + * Initialize.
82 + *
55 83 * @codeCoverageIgnore
56 84 */
57 85 public static function initialize_latest_version() {
58 86 $self = self::instance();
59 - call_user_func($self->latest_version_callback());
87 + call_user_func( $self->latest_version_callback() );
60 88 }
61 89 }
62 -