PluginProbe
Imagify Image Optimization: Optimize Images | Compress & Convert to WebP/AVIF / trunk
Imagify Image Optimization: Optimize Images | Compress & Convert to WebP/AVIF vtrunk
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
← All changes | inc/classes/class-imagify-abstract-cron.php +10 -39 1.10 → trunk View file →
@@ -1,6 +1,5 @@
1 1 <?php
2 -defined( 'ABSPATH' ) || die( 'Cheatin’ uh?' );
3 2
4 3 /**
5 4 * Basis class that handles events.
6 5 *
@@ -7,9 +6,8 @@
7 6 * @since 1.7
8 7 * @author Grégory Viguier
9 8 */
10 9 abstract class Imagify_Abstract_Cron {
11 -
12 10 /**
13 11 * Class version.
14 12 *
15 13 * @var string
@@ -43,35 +41,8 @@
43 41 * @access protected
44 42 */
45 43 protected $event_time = '';
46 44
47 - /**
48 - * The single instance of the class.
49 - *
50 - * @var object
51 - * @since 1.7
52 - * @access protected
53 - */
54 - protected static $_instance;
55 -
56 - /**
57 - * Get the main Instance.
58 - *
59 - * @since 1.7
60 - * @access public
61 - * @author Grégory Viguier
62 - *
63 - * @return object Main instance.
64 - */
65 - public static function get_instance() {
66 - if ( ! isset( self::$_instance ) ) {
67 - self::$_instance = new self();
68 - }
69 -
70 - return self::$_instance;
71 - }
72 -
73 -
74 45 /** ----------------------------------------------------------------------------------------- */
75 46 /** INIT ==================================================================================== */
76 47 /** ----------------------------------------------------------------------------------------- */
77 48
@@ -82,16 +53,16 @@
82 53 * @access public
83 54 * @author Grégory Viguier
84 55 */
85 56 public function init() {
86 - add_action( 'init', array( $this, 'schedule_event' ) );
87 - add_action( $this->get_event_name(), array( $this, 'do_event' ) );
88 - add_filter( 'cron_schedules', array( $this, 'maybe_add_recurrence' ) );
57 + add_action( 'init', [ $this, 'schedule_event' ] );
58 + add_action( $this->get_event_name(), [ $this, 'do_event' ] );
59 + add_filter( 'cron_schedules', [ $this, 'maybe_add_recurrence' ] );
89 60
90 61 if ( did_action( static::get_deactivation_hook_name() ) ) {
91 62 $this->unschedule_event();
92 63 } else {
93 - add_action( static::get_deactivation_hook_name(), array( $this, 'unschedule_event' ) );
64 + add_action( static::get_deactivation_hook_name(), [ $this, 'unschedule_event' ] );
94 65 }
95 66 }
96 67
97 68
@@ -144,13 +115,13 @@
144 115 *
145 116 * @return array
146 117 */
147 118 public function maybe_add_recurrence( $schedules ) {
148 - $default_schedules = array(
119 + $default_schedules = [
149 120 'hourly' => 1,
150 121 'twicedaily' => 1,
151 122 'daily' => 1,
152 - );
123 + ];
153 124
154 125 $event_recurrence = $this->get_event_recurrence();
155 126
156 127 if ( ! empty( $schedules[ $event_recurrence ] ) || ! empty( $default_schedules[ $event_recurrence ] ) ) {
@@ -156,14 +127,14 @@
156 127 if ( ! empty( $schedules[ $event_recurrence ] ) || ! empty( $default_schedules[ $event_recurrence ] ) ) {
157 128 return $schedules;
158 129 }
159 130
160 - $recurrences = array(
161 - 'weekly' => array(
131 + $recurrences = [
132 + 'weekly' => [
162 133 'interval' => WEEK_IN_SECONDS,
163 134 'display' => __( 'Once Weekly', 'imagify' ),
164 - ),
165 - );
135 + ],
136 + ];
166 137
167 138 if ( method_exists( $this, 'get_event_recurrence_attributes' ) ) {
168 139 $recurrences[ $event_recurrence ] = $this->get_event_recurrence_attributes();
169 140 }