PluginProbe
Image Optimizer – Compress Images and Convert to WebP or AVIF / 1.7.7
Image Optimizer – Compress Images and Convert to WebP or AVIF v1.7.7
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_AdminView.php +70 -37 1.0.2 → 1.7.7 View file →
@@ -1,20 +1,37 @@
1 1 <?php
2 2
3 3 /**
4 4 * Class ActionScheduler_AdminView
5 + *
5 6 * @codeCoverageIgnore
6 7 */
7 8 class ActionScheduler_AdminView extends ActionScheduler_AdminView_Deprecated {
8 9
9 - private static $admin_view = NULL;
10 + /**
11 + * Instance.
12 + *
13 + * @var null|self
14 + */
15 + private static $admin_view = null;
10 16
17 + /**
18 + * Screen ID.
19 + *
20 + * @var string
21 + */
11 22 private static $screen_id = 'tools_page_action-scheduler';
12 23
13 - /** @var ActionScheduler_ListTable */
24 + /**
25 + * ActionScheduler_ListTable instance.
26 + *
27 + * @var ActionScheduler_ListTable
28 + */
14 29 protected $list_table;
15 30
16 31 /**
32 + * Get instance.
33 + *
17 34 * @return ActionScheduler_AdminView
18 35 * @codeCoverageIgnore
19 36 */
20 37 public static function instance() {
@@ -19,9 +36,9 @@
19 36 */
20 37 public static function instance() {
21 38
22 39 if ( empty( self::$admin_view ) ) {
23 - $class = apply_filters('action_scheduler_admin_view_class', 'ActionScheduler_AdminView');
40 + $class = apply_filters( 'action_scheduler_admin_view_class', 'ActionScheduler_AdminView' );
24 41 self::$admin_view = new $class();
25 42 }
26 43
27 44 return self::$admin_view;
@@ -27,12 +44,14 @@
27 44 return self::$admin_view;
28 45 }
29 46
30 47 /**
48 + * Initialize.
49 + *
31 50 * @codeCoverageIgnore
32 51 */
33 52 public function init() {
34 - if ( is_admin() && ( ! defined( 'DOING_AJAX' ) || false == DOING_AJAX ) ) {
53 + if ( is_admin() && ( ! defined( 'DOING_AJAX' ) || ! DOING_AJAX ) ) {
35 54
36 55 if ( class_exists( 'WooCommerce' ) ) {
37 56 add_action( 'woocommerce_admin_status_content_action-scheduler', array( $this, 'render_admin_ui' ) );
38 57 add_action( 'woocommerce_system_status_report', array( $this, 'system_status_report' ) );
@@ -44,8 +63,11 @@
44 63 add_action( 'current_screen', array( $this, 'add_help_tabs' ) );
45 64 }
46 65 }
47 66
67 + /**
68 + * Print system status report.
69 + */
48 70 public function system_status_report() {
49 71 $table = new ActionScheduler_wcSystemStatus( ActionScheduler::store() );
50 72 $table->render();
51 73 }
@@ -77,9 +99,9 @@
77 99 'manage_options',
78 100 'action-scheduler',
79 101 array( $this, 'render_admin_ui' )
80 102 );
81 - add_action( 'load-' . $hook_suffix , array( $this, 'process_admin_ui' ) );
103 + add_action( 'load-' . $hook_suffix, array( $this, 'process_admin_ui' ) );
82 104 }
83 105
84 106 /**
85 107 * Triggers processing of any pending actions.
@@ -118,35 +140,33 @@
118 140 * @uses $this->check_pastdue_actions()
119 141 */
120 142 public function maybe_check_pastdue_actions() {
121 143
122 - # Filter to prevent checking actions (ex: inappropriate user).
144 + // Filter to prevent checking actions (ex: inappropriate user).
123 145 if ( ! apply_filters( 'action_scheduler_check_pastdue_actions', current_user_can( 'manage_options' ) ) ) {
124 146 return;
125 147 }
126 148
127 - # Get last check transient.
149 + // Get last check transient.
128 150 $last_check = get_transient( 'action_scheduler_last_pastdue_actions_check' );
129 151
130 - # If transient exists, we're within interval, so bail.
152 + // If transient exists, we're within interval, so bail.
131 153 if ( ! empty( $last_check ) ) {
132 154 return;
133 155 }
134 156
135 - # Perform the check.
157 + // Perform the check.
136 158 $this->check_pastdue_actions();
137 159 }
138 160
139 161 /**
140 162 * Check past-due actions, and print notice.
141 - *
142 - * @todo update $link_url to "Past-due" filter when released (see issue #510, PR #511)
143 163 */
144 164 protected function check_pastdue_actions() {
145 165
146 - # Set thresholds.
147 - $threshold_seconds = ( int ) apply_filters( 'action_scheduler_pastdue_actions_seconds', DAY_IN_SECONDS );
148 - $threshhold_min = ( int ) apply_filters( 'action_scheduler_pastdue_actions_min', 1 );
166 + // Set thresholds.
167 + $threshold_seconds = (int) apply_filters( 'action_scheduler_pastdue_actions_seconds', DAY_IN_SECONDS );
168 + $threshold_min = (int) apply_filters( 'action_scheduler_pastdue_actions_min', 1 );
149 169
150 170 // Set fallback value for past-due actions count.
151 171 $num_pastdue_actions = 0;
152 172
@@ -157,26 +177,26 @@
157 177 if ( ! is_null( $check ) ) {
158 178 return;
159 179 }
160 180
161 - # Scheduled actions query arguments.
181 + // Scheduled actions query arguments.
162 182 $query_args = array(
163 183 'date' => as_get_datetime_object( time() - $threshold_seconds ),
164 184 'status' => ActionScheduler_Store::STATUS_PENDING,
165 - 'per_page' => $threshhold_min,
185 + 'per_page' => $threshold_min,
166 186 );
167 187
168 - # If no third-party preempted, run default check.
188 + // If no third-party preempted, run default check.
169 189 if ( is_null( $check ) ) {
170 - $store = ActionScheduler_Store::instance();
171 - $num_pastdue_actions = ( int ) $store->query_actions( $query_args, 'count' );
190 + $store = ActionScheduler_Store::instance();
191 + $num_pastdue_actions = (int) $store->query_actions( $query_args, 'count' );
172 192
173 - # Check if past-due actions count is greater than or equal to threshold.
174 - $check = ( $num_pastdue_actions >= $threshhold_min );
175 - $check = ( bool ) apply_filters( 'action_scheduler_pastdue_actions_check', $check, $num_pastdue_actions, $threshold_seconds, $threshhold_min );
193 + // Check if past-due actions count is greater than or equal to threshold.
194 + $check = ( $num_pastdue_actions >= $threshold_min );
195 + $check = (bool) apply_filters( 'action_scheduler_pastdue_actions_check', $check, $num_pastdue_actions, $threshold_seconds, $threshold_min );
176 196 }
177 197
178 - # If check failed, set transient and abort.
198 + // If check failed, set transient and abort.
179 199 if ( ! boolval( $check ) ) {
180 200 $interval = apply_filters( 'action_scheduler_pastdue_actions_check_interval', round( $threshold_seconds / 4 ), $threshold_seconds );
181 201 set_transient( 'action_scheduler_last_pastdue_actions_check', time(), $interval );
182 202
@@ -182,30 +202,42 @@
182 202
183 203 return;
184 204 }
185 205
186 - $actions_url = add_query_arg( array(
187 - 'page' => 'action-scheduler',
188 - 'status' => 'past-due',
189 - 'order' => 'asc',
190 - ), admin_url( 'tools.php' ) );
206 + $actions_url = add_query_arg(
207 + array(
208 + 'page' => 'action-scheduler',
209 + 'status' => 'past-due',
210 + 'order' => 'asc',
211 + ),
212 + admin_url( 'tools.php' )
213 + );
191 214
192 - # Print notice.
215 + // Print notice.
193 216 echo '<div class="notice notice-warning"><p>';
194 217 printf(
195 - _n(
218 + wp_kses(
196 219 // translators: 1) is the number of affected actions, 2) is a link to an admin screen.
197 - '<strong>Action Scheduler:</strong> %1$d <a href="%2$s">past-due action</a> found; something may be wrong. <a href="https://actionscheduler.org/faq/#my-site-has-past-due-actions-what-can-i-do" target="_blank">Read documentation &raquo;</a>',
198 - '<strong>Action Scheduler:</strong> %1$d <a href="%2$s">past-due actions</a> found; something may be wrong. <a href="https://actionscheduler.org/faq/#my-site-has-past-due-actions-what-can-i-do" target="_blank">Read documentation &raquo;</a>',
199 - $num_pastdue_actions,
200 - 'action-scheduler'
220 + _n(
221 + '<strong>Action Scheduler:</strong> %1$d <a href="%2$s">past-due action</a> found; something may be wrong. <a href="https://actionscheduler.org/faq/#my-site-has-past-due-actions-what-can-i-do" target="_blank">Read documentation &raquo;</a>',
222 + '<strong>Action Scheduler:</strong> %1$d <a href="%2$s">past-due actions</a> found; something may be wrong. <a href="https://actionscheduler.org/faq/#my-site-has-past-due-actions-what-can-i-do" target="_blank">Read documentation &raquo;</a>',
223 + $num_pastdue_actions,
224 + 'action-scheduler'
225 + ),
226 + array(
227 + 'strong' => array(),
228 + 'a' => array(
229 + 'href' => true,
230 + 'target' => true,
231 + ),
232 + )
201 233 ),
202 - $num_pastdue_actions,
234 + absint( $num_pastdue_actions ),
203 235 esc_attr( esc_url( $actions_url ) )
204 236 );
205 237 echo '</p></div>';
206 238
207 - # Facilitate third-parties to evaluate and print notices.
239 + // Facilitate third-parties to evaluate and print notices.
208 240 do_action( 'action_scheduler_pastdue_actions_extra_notices', $query_args );
209 241 }
210 242
211 243 /**
@@ -213,9 +245,9 @@
213 245 */
214 246 public function add_help_tabs() {
215 247 $screen = get_current_screen();
216 248
217 - if ( ! $screen || self::$screen_id != $screen->id ) {
249 + if ( ! $screen || self::$screen_id !== $screen->id ) {
218 250 return;
219 251 }
220 252
221 253 $as_version = ActionScheduler_Versions::instance()->latest_version();
@@ -223,8 +255,9 @@
223 255 array(
224 256 'id' => 'action_scheduler_about',
225 257 'title' => __( 'About', 'action-scheduler' ),
226 258 'content' =>
259 + // translators: %s is the Action Scheduler version.
227 260 '<h2>' . sprintf( __( 'About Action Scheduler %s', 'action-scheduler' ), $as_version ) . '</h2>' .
228 261 '<p>' .
229 262 __( 'Action Scheduler is a scalable, traceable job queue for background processing large sets of actions. Action Scheduler works by triggering an action hook to run at some time in the future. Scheduled actions can also be scheduled to run on a recurring schedule.', 'action-scheduler' ) .
230 263 '</p>',