PluginProbe ʕ •ᴥ•ʔ
MailPoet – Newsletters, Email Marketing, and Automation / 5.36.0
MailPoet – Newsletters, Email Marketing, and Automation v5.36.0
5.36.0 5.35.1 5.35.0 5.34.3 5.34.2 5.34.1 5.34.0 5.33.1 5.33.0 5.32.0 5.31.0 5.30.0 5.29.0 5.28.1 5.28.0 5.27.0 5.26.0 5.26.1 5.25.0 5.24.0 4.43.0 4.43.1 4.44.0 4.44.1 4.45.0 4.46.0 4.47.0 4.48.0 4.48.1 4.48.2 4.49.0 4.49.1 4.5.0 4.5.1 4.5.2 4.50.0 4.50.1 4.51.0 4.51.1 4.51.2 4.52.0 4.53.0 4.54.0 4.55.0 4.56.0 4.57.0 4.58.0 4.58.1 4.58.2 4.6.0 4.6.1 4.6.2 4.7.0 4.7.1 4.8.0 4.8.1 4.9.0 5.0.0 5.0.1 5.0.2 5.1.0 5.1.1 5.10.0 5.10.1 5.11.0 5.12.0 5.12.1 5.12.10 5.12.11 5.12.12 5.12.13 5.12.2 5.12.3 5.12.4 5.12.5 5.12.6 5.12.7 5.12.8 5.12.9 5.13.0 5.13.1 5.13.2 5.14.0 5.14.1 5.14.2 5.14.3 5.15.0 5.15.1 5.16.0 5.16.1 5.16.2 5.16.3 5.16.4 5.17.0 5.17.1 5.17.2 5.17.3 5.17.4 5.17.5 5.17.6 5.18.0 5.19.0 5.2.0 5.2.1 5.2.2 5.2.3 5.20.0 5.21.0 5.21.1 5.21.2 5.21.3 5.22.0 5.22.1 5.22.2 5.22.3 5.22.4 5.23.0 5.23.1 5.23.2 5.3.0 5.3.1 5.3.2 5.3.3 5.3.4 5.3.5 5.3.6 5.3.7 5.4.0 5.4.1 5.4.2 5.5.0 5.5.1 5.5.2 5.6.0 5.6.1 5.6.2 5.6.3 5.6.4 5.7.0 5.7.1 5.8.0 5.8.1 5.9.0 3.0.0-beta.15 3.7.1 3.0.0-beta.16 3.7.2 3.0.0-beta.17 3.7.3 3.0.0-beta.18 3.7.4 3.0.0-beta.19 3.7.5 3.0.0-beta.2 3.7.6 3.0.0-beta.20 3.7.8 3.0.0-beta.21 3.70.0 3.0.0-beta.22 3.71.0 3.0.0-beta.23 3.71.1 3.0.0-beta.23.1 3.71.2 3.0.0-beta.23.2 3.71.3 3.0.0-beta.24 3.72.0 3.0.0-beta.25 3.73.0 3.0.0-beta.26 3.73.1 3.0.0-beta.27 3.73.2 3.0.0-beta.28 3.74.0 3.0.0-beta.29 3.74.1 3.0.0-beta.3 3.74.2 3.0.0-beta.30 3.74.3 3.0.0-beta.31 3.75.0 3.0.0-beta.32 3.75.1 3.0.0-beta.33 3.76.0 3.0.0-beta.33.1 3.77.0 3.0.0-beta.34.0.0 3.77.1 3.0.0-beta.36.0.0 3.78.0 3.0.0-beta.36.0.1 3.79.0 3.0.0-beta.36.2.0 3.8 3.0.0-beta.36.3.0 3.8.1 3.0.0-beta.36.3.1 3.8.2 3.0.0-beta.37.0.0 3.8.3 3.0.0-beta.4 3.8.4 3.0.0-beta.5 3.8.5 3.0.0-beta.6 3.8.6 3.0.0-beta.7 3.80.0 3.0.0-beta.7.1 3.81.0 3.0.0-beta.8 3.82.0 3.0.0-beta.9 3.83.0 3.0.0-rc.1.0.0 3.84.0 3.0.0-rc.1.0.1 3.84.1 3.0.0-rc.1.0.2 3.85.0 3.0.0-rc.1.0.3 3.85.1 3.0.0-rc.1.0.4 3.86.0 3.0.0-rc.2.0.0 3.87.0 3.0.0-rc.2.0.1 3.87.1 3.0.0-rc.2.0.2 3.87.2 3.0.0-rc.2.0.3 3.88.0 3.0.1 3.88.1 3.0.2 3.88.2 3.0.3 3.89.0 3.0.4 3.89.1 3.0.5 3.89.2 3.0.6 3.89.3 3.0.7 3.89.4 3.0.8 3.9.0 3.0.9 3.9.1 3.1.0 3.90.0 3.10 3.90.1 3.10.1 3.90.2 3.100.0 3.91.0 3.100.1 3.91.1 3.100.2 3.92.0 3.101.0 3.92.1 3.101.1 3.93.0 3.102.0 3.93.1 3.102.1 3.94.0 3.103.0 3.95.0 3.103.1 3.95.1 3.11.0 3.96.0 3.11.1 3.96.1 3.11.2 3.97.0 3.11.3 3.98.0 3.11.4 3.98.1 3.11.5 3.99.0 3.12.0 3.99.1 3.12.1 4.0.0 3.13.0 4.0.1 3.14.0 4.1.0 3.14.1 4.1.1 3.15.0 4.10.0 3.16.0 4.11.0 3.16.1 4.11.1 3.16.2 4.12.0 3.16.3 4.12.1 3.17.0 4.12.2 3.17.1 4.13.0 3.17.2 4.14.0 3.18.0 4.15.0 3.18.1 4.16.0 3.18.2 4.17.0 3.19.0 4.17.1 3.19.1 4.18.0 3.19.2 4.18.1 3.19.3 4.19.0 3.2.0 4.2.0 3.2.1 4.20.0 3.2.2 4.20.1 3.2.3 4.20.2 3.2.4 4.21.0 3.2.5 4.22.0 3.20.0 4.22.1 3.21.0 4.22.2 3.21.1 4.23.0 3.22.0 4.24.0 3.23.0 4.25.0 3.23.1 4.26.0 3.23.2 4.26.1 3.24.0 4.27.0 3.25.0 4.28.0 3.25.1 4.29.0 3.26.0 4.3.0 3.26.1 4.3.1 3.27.0 4.30.0 3.28.0 4.31.0 3.29.0 4.31.1 3.3.0 4.32.0 3.3.1 4.33.0 3.3.2 4.34.0 3.3.3 4.35.0 3.3.4 4.35.1 3.3.5 4.36.0 3.3.6 4.37.0 3.30.0 4.38.0 3.31.0 4.39.0 3.31.1 4.4.0 3.32.0 4.40.0 3.32.1 4.41.0 3.32.2 4.41.1 3.33.0 4.41.2 3.34.0 4.41.3 3.34.1 4.42.0 3.34.2 4.42.1 3.34.3 3.34.4 3.35.0 3.35.1 3.35.3 3.35.4 3.36.0 3.37.0 3.37.1 3.37.2 3.37.3 3.38.0 3.38.1 3.39.0 3.39.1 3.39.2 3.4.0 3.4.1 3.4.2 3.4.3 3.4.4 3.40.0 3.40.1 3.41.0 3.41.1 3.41.2 3.42.0 3.42.1 3.42.2 3.42.3 3.43.0 3.43.1 3.44.0 3.45.0 3.45.1 3.46.0 3.46.1 3.46.10 3.46.11 3.46.12 3.46.13 3.46.14 3.46.2 3.46.3 3.46.4 3.46.5 3.46.6 3.46.7 3.46.8 3.46.9 3.47.0 3.47.1 3.47.10 3.47.11 3.47.2 3.47.3 3.47.5 3.47.6 3.47.7 3.47.9 3.48.0 3.48.1 3.49.0 3.49.1 3.5.0 3.5.1 3.50.0 3.51.0 3.51.1 3.51.2 3.52.0 3.53.0 3.54.0 3.54.1 3.54.2 3.54.3 3.55.0 3.55.1 3.56.0 3.56.1 3.56.2 3.57.0 3.57.1 3.58.0 3.59.0 3.59.1 3.59.2 3.6.0 3.6.1 3.6.2 3.6.3 3.6.4 3.6.5 3.6.6 3.6.7 3.60.0 3.60.1 3.60.10 3.60.11 3.60.12 3.60.2 3.60.3 3.60.4 3.60.6 3.60.7 3.60.8 3.60.9 3.61.0 3.62.0 3.62.1 3.63.0 3.64.0 3.64.1 3.64.2 3.64.3 3.65.0 trunk 3.65.1 3.0.0 3.66.0 3.0.0-beta.1 3.67.0 3.0.0-beta.10 3.67.1 3.0.0-beta.11 3.68.0 3.0.0-beta.12 3.69.0 3.0.0-beta.13 3.69.1 3.0.0-beta.14 3.7.0
mailpoet / vendor / woocommerce / action-scheduler / classes / ActionScheduler_ListTable.php
mailpoet / vendor / woocommerce / action-scheduler / classes Last commit date
WP_CLI 1 year ago abstracts 1 year ago actions 1 year ago data-stores 1 year ago migration 1 year ago schedules 1 year ago schema 1 year ago ActionScheduler_ActionClaim.php 1 year ago ActionScheduler_ActionFactory.php 1 year ago ActionScheduler_AdminView.php 1 year ago ActionScheduler_AsyncRequest_QueueRunner.php 1 year ago ActionScheduler_Compatibility.php 1 year ago ActionScheduler_DataController.php 1 year ago ActionScheduler_DateTime.php 1 year ago ActionScheduler_Exception.php 4 years ago ActionScheduler_FatalErrorMonitor.php 1 year ago ActionScheduler_InvalidActionException.php 1 year ago ActionScheduler_ListTable.php 1 year ago ActionScheduler_LogEntry.php 1 year ago ActionScheduler_NullLogEntry.php 1 year ago ActionScheduler_OptionLock.php 2 years ago ActionScheduler_QueueCleaner.php 1 year ago ActionScheduler_QueueRunner.php 1 year ago ActionScheduler_SystemInformation.php 1 year ago ActionScheduler_Versions.php 1 year ago ActionScheduler_WPCommentCleaner.php 1 year ago ActionScheduler_wcSystemStatus.php 4 years ago index.php 3 years ago
ActionScheduler_ListTable.php
386 lines
1 <?php
2 if (!defined('ABSPATH')) exit;
3 class ActionScheduler_ListTable extends ActionScheduler_Abstract_ListTable {
4 protected $package = 'action-scheduler';
5 protected $columns = array();
6 protected $row_actions = array();
7 protected $store;
8 protected $logger;
9 protected $runner;
10 protected $bulk_actions = array();
11 protected static $did_notification = false;
12 private static $time_periods;
13 public function __construct( ActionScheduler_Store $store, ActionScheduler_Logger $logger, ActionScheduler_QueueRunner $runner ) {
14 $this->store = $store;
15 $this->logger = $logger;
16 $this->runner = $runner;
17 $this->table_header = __( 'Scheduled Actions', 'action-scheduler' );
18 $this->bulk_actions = array(
19 'delete' => __( 'Delete', 'action-scheduler' ),
20 );
21 $this->columns = array(
22 'hook' => __( 'Hook', 'action-scheduler' ),
23 'status' => __( 'Status', 'action-scheduler' ),
24 'args' => __( 'Arguments', 'action-scheduler' ),
25 'group' => __( 'Group', 'action-scheduler' ),
26 'recurrence' => __( 'Recurrence', 'action-scheduler' ),
27 'schedule' => __( 'Scheduled Date', 'action-scheduler' ),
28 'log_entries' => __( 'Log', 'action-scheduler' ),
29 );
30 $this->sort_by = array(
31 'schedule',
32 'hook',
33 'group',
34 );
35 $this->search_by = array(
36 'hook',
37 'args',
38 'claim_id',
39 );
40 $request_status = $this->get_request_status();
41 if ( empty( $request_status ) ) {
42 $this->sort_by[] = 'status';
43 } elseif ( in_array( $request_status, array( 'in-progress', 'failed' ), true ) ) {
44 $this->columns += array( 'claim_id' => __( 'Claim ID', 'action-scheduler' ) );
45 $this->sort_by[] = 'claim_id';
46 }
47 $this->row_actions = array(
48 'hook' => array(
49 'run' => array(
50 'name' => __( 'Run', 'action-scheduler' ),
51 'desc' => __( 'Process the action now as if it were run as part of a queue', 'action-scheduler' ),
52 ),
53 'cancel' => array(
54 'name' => __( 'Cancel', 'action-scheduler' ),
55 'desc' => __( 'Cancel the action now to avoid it being run in future', 'action-scheduler' ),
56 'class' => 'cancel trash',
57 ),
58 ),
59 );
60 self::$time_periods = array(
61 array(
62 'seconds' => YEAR_IN_SECONDS,
63 'names' => _n_noop( '%s year', '%s years', 'action-scheduler' ),
64 ),
65 array(
66 'seconds' => MONTH_IN_SECONDS,
67 'names' => _n_noop( '%s month', '%s months', 'action-scheduler' ),
68 ),
69 array(
70 'seconds' => WEEK_IN_SECONDS,
71 'names' => _n_noop( '%s week', '%s weeks', 'action-scheduler' ),
72 ),
73 array(
74 'seconds' => DAY_IN_SECONDS,
75 'names' => _n_noop( '%s day', '%s days', 'action-scheduler' ),
76 ),
77 array(
78 'seconds' => HOUR_IN_SECONDS,
79 'names' => _n_noop( '%s hour', '%s hours', 'action-scheduler' ),
80 ),
81 array(
82 'seconds' => MINUTE_IN_SECONDS,
83 'names' => _n_noop( '%s minute', '%s minutes', 'action-scheduler' ),
84 ),
85 array(
86 'seconds' => 1,
87 'names' => _n_noop( '%s second', '%s seconds', 'action-scheduler' ),
88 ),
89 );
90 parent::__construct(
91 array(
92 'singular' => 'action-scheduler',
93 'plural' => 'action-scheduler',
94 'ajax' => false,
95 )
96 );
97 add_screen_option(
98 'per_page',
99 array(
100 'default' => $this->items_per_page,
101 )
102 );
103 add_filter( 'set_screen_option_' . $this->get_per_page_option_name(), array( $this, 'set_items_per_page_option' ), 10, 3 );
104 set_screen_options();
105 }
106 public function set_items_per_page_option( $status, $option, $value ) {
107 return $value;
108 }
109 private static function human_interval( $interval, $periods_to_include = 2 ) {
110 if ( $interval <= 0 ) {
111 return __( 'Now!', 'action-scheduler' );
112 }
113 $output = '';
114 $num_time_periods = count( self::$time_periods );
115 for ( $time_period_index = 0, $periods_included = 0, $seconds_remaining = $interval; $time_period_index < $num_time_periods && $seconds_remaining > 0 && $periods_included < $periods_to_include; $time_period_index++ ) {
116 $periods_in_interval = floor( $seconds_remaining / self::$time_periods[ $time_period_index ]['seconds'] );
117 if ( $periods_in_interval > 0 ) {
118 if ( ! empty( $output ) ) {
119 $output .= ' ';
120 }
121 $output .= sprintf( translate_nooped_plural( self::$time_periods[ $time_period_index ]['names'], $periods_in_interval, 'action-scheduler' ), $periods_in_interval );
122 $seconds_remaining -= $periods_in_interval * self::$time_periods[ $time_period_index ]['seconds'];
123 $periods_included++;
124 }
125 }
126 return $output;
127 }
128 protected function get_recurrence( $action ) {
129 $schedule = $action->get_schedule();
130 if ( $schedule->is_recurring() && method_exists( $schedule, 'get_recurrence' ) ) {
131 $recurrence = $schedule->get_recurrence();
132 if ( is_numeric( $recurrence ) ) {
133 return sprintf( __( 'Every %s', 'action-scheduler' ), self::human_interval( $recurrence ) );
134 } else {
135 return $recurrence;
136 }
137 }
138 return __( 'Non-repeating', 'action-scheduler' );
139 }
140 public function column_args( array $row ) {
141 if ( empty( $row['args'] ) ) {
142 return apply_filters( 'action_scheduler_list_table_column_args', '', $row );
143 }
144 $row_html = '<ul>';
145 foreach ( $row['args'] as $key => $value ) {
146 $row_html .= sprintf( '<li><code>%s => %s</code></li>', esc_html( var_export( $key, true ) ), esc_html( var_export( $value, true ) ) ); // phpcs:ignore WordPress.PHP.DevelopmentFunctions.error_log_var_export
147 }
148 $row_html .= '</ul>';
149 return apply_filters( 'action_scheduler_list_table_column_args', $row_html, $row );
150 }
151 public function column_log_entries( array $row ) {
152 $log_entries_html = '<ol>';
153 $timezone = new DateTimezone( 'UTC' );
154 foreach ( $row['log_entries'] as $log_entry ) {
155 $log_entries_html .= $this->get_log_entry_html( $log_entry, $timezone );
156 }
157 $log_entries_html .= '</ol>';
158 return $log_entries_html;
159 }
160 protected function get_log_entry_html( ActionScheduler_LogEntry $log_entry, DateTimezone $timezone ) {
161 $date = $log_entry->get_date();
162 $date->setTimezone( $timezone );
163 return sprintf( '<li><strong>%s</strong><br/>%s</li>', esc_html( $date->format( 'Y-m-d H:i:s O' ) ), esc_html( $log_entry->get_message() ) );
164 }
165 protected function maybe_render_actions( $row, $column_name ) {
166 if ( 'pending' === strtolower( $row['status_name'] ) ) {
167 return parent::maybe_render_actions( $row, $column_name );
168 }
169 return '';
170 }
171 public function display_admin_notices() {
172 global $wpdb;
173 if ( ( is_a( $this->store, 'ActionScheduler_HybridStore' ) || is_a( $this->store, 'ActionScheduler_DBStore' ) ) && apply_filters( 'action_scheduler_enable_recreate_data_store', true ) ) {
174 $table_list = array(
175 'actionscheduler_actions',
176 'actionscheduler_logs',
177 'actionscheduler_groups',
178 'actionscheduler_claims',
179 );
180 $found_tables = $wpdb->get_col( "SHOW TABLES LIKE '{$wpdb->prefix}actionscheduler%'" ); // phpcs:ignore WordPress.DB.PreparedSQL.InterpolatedNotPrepared
181 foreach ( $table_list as $table_name ) {
182 if ( ! in_array( $wpdb->prefix . $table_name, $found_tables, true ) ) {
183 $this->admin_notices[] = array(
184 'class' => 'error',
185 'message' => __( 'It appears one or more database tables were missing. Attempting to re-create the missing table(s).', 'action-scheduler' ),
186 );
187 $this->recreate_tables();
188 parent::display_admin_notices();
189 return;
190 }
191 }
192 }
193 if ( $this->runner->has_maximum_concurrent_batches() ) {
194 $claim_count = $this->store->get_claim_count();
195 $this->admin_notices[] = array(
196 'class' => 'updated',
197 'message' => sprintf(
198 _n(
199 'Maximum simultaneous queues already in progress (%s queue). No additional queues will begin processing until the current queues are complete.',
200 'Maximum simultaneous queues already in progress (%s queues). No additional queues will begin processing until the current queues are complete.',
201 $claim_count,
202 'action-scheduler'
203 ),
204 $claim_count
205 ),
206 );
207 } elseif ( $this->store->has_pending_actions_due() ) {
208 $async_request_lock_expiration = ActionScheduler::lock()->get_expiration( 'async-request-runner' );
209 // No lock set or lock expired.
210 if ( false === $async_request_lock_expiration || $async_request_lock_expiration < time() ) {
211 $in_progress_url = add_query_arg( 'status', 'in-progress', remove_query_arg( 'status' ) );
212 $async_request_message = sprintf( __( 'A new queue has begun processing. <a href="%s">View actions in-progress &raquo;</a>', 'action-scheduler' ), esc_url( $in_progress_url ) );
213 } else {
214 $async_request_message = sprintf( __( 'The next queue will begin processing in approximately %d seconds.', 'action-scheduler' ), $async_request_lock_expiration - time() );
215 }
216 $this->admin_notices[] = array(
217 'class' => 'notice notice-info',
218 'message' => $async_request_message,
219 );
220 }
221 $notification = get_transient( 'action_scheduler_admin_notice' );
222 if ( is_array( $notification ) ) {
223 delete_transient( 'action_scheduler_admin_notice' );
224 $action = $this->store->fetch_action( $notification['action_id'] );
225 $action_hook_html = '<strong><code>' . $action->get_hook() . '</code></strong>';
226 if ( 1 === absint( $notification['success'] ) ) {
227 $class = 'updated';
228 switch ( $notification['row_action_type'] ) {
229 case 'run':
230 $action_message_html = sprintf( __( 'Successfully executed action: %s', 'action-scheduler' ), $action_hook_html );
231 break;
232 case 'cancel':
233 $action_message_html = sprintf( __( 'Successfully canceled action: %s', 'action-scheduler' ), $action_hook_html );
234 break;
235 default:
236 $action_message_html = sprintf( __( 'Successfully processed change for action: %s', 'action-scheduler' ), $action_hook_html );
237 break;
238 }
239 } else {
240 $class = 'error';
241 $action_message_html = sprintf( __( 'Could not process change for action: "%1$s" (ID: %2$d). Error: %3$s', 'action-scheduler' ), $action_hook_html, esc_html( $notification['action_id'] ), esc_html( $notification['error_message'] ) );
242 }
243 $action_message_html = apply_filters( 'action_scheduler_admin_notice_html', $action_message_html, $action, $notification );
244 $this->admin_notices[] = array(
245 'class' => $class,
246 'message' => $action_message_html,
247 );
248 }
249 parent::display_admin_notices();
250 }
251 public function column_schedule( $row ) {
252 return $this->get_schedule_display_string( $row['schedule'] );
253 }
254 protected function get_schedule_display_string( ActionScheduler_Schedule $schedule ) {
255 $schedule_display_string = '';
256 if ( is_a( $schedule, 'ActionScheduler_NullSchedule' ) ) {
257 return __( 'async', 'action-scheduler' );
258 }
259 if ( ! method_exists( $schedule, 'get_date' ) || ! $schedule->get_date() ) {
260 return '0000-00-00 00:00:00';
261 }
262 $next_timestamp = $schedule->get_date()->getTimestamp();
263 $schedule_display_string .= $schedule->get_date()->format( 'Y-m-d H:i:s O' );
264 $schedule_display_string .= '<br/>';
265 if ( gmdate( 'U' ) > $next_timestamp ) {
266 $schedule_display_string .= sprintf( __( ' (%s ago)', 'action-scheduler' ), self::human_interval( gmdate( 'U' ) - $next_timestamp ) );
267 } else {
268 $schedule_display_string .= sprintf( __( ' (%s)', 'action-scheduler' ), self::human_interval( $next_timestamp - gmdate( 'U' ) ) );
269 }
270 return $schedule_display_string;
271 }
272 protected function bulk_delete( array $ids, $ids_sql ) {
273 foreach ( $ids as $id ) {
274 try {
275 $this->store->delete_action( $id );
276 } catch ( Exception $e ) {
277 // A possible reason for an exception would include a scenario where the same action is deleted by a
278 // concurrent request.
279 // phpcs:ignore WordPress.PHP.DevelopmentFunctions.error_log_error_log
280 error_log(
281 sprintf(
282 __( 'Action Scheduler was unable to delete action %1$d. Reason: %2$s', 'action-scheduler' ),
283 $id,
284 $e->getMessage()
285 )
286 );
287 }
288 }
289 }
290 protected function row_action_cancel( $action_id ) {
291 $this->process_row_action( $action_id, 'cancel' );
292 }
293 protected function row_action_run( $action_id ) {
294 $this->process_row_action( $action_id, 'run' );
295 }
296 protected function recreate_tables() {
297 if ( is_a( $this->store, 'ActionScheduler_HybridStore' ) ) {
298 $store = $this->store;
299 } else {
300 $store = new ActionScheduler_HybridStore();
301 }
302 add_action( 'action_scheduler/created_table', array( $store, 'set_autoincrement' ), 10, 2 );
303 $store_schema = new ActionScheduler_StoreSchema();
304 $logger_schema = new ActionScheduler_LoggerSchema();
305 $store_schema->register_tables( true );
306 $logger_schema->register_tables( true );
307 remove_action( 'action_scheduler/created_table', array( $store, 'set_autoincrement' ), 10 );
308 }
309 protected function process_row_action( $action_id, $row_action_type ) {
310 try {
311 switch ( $row_action_type ) {
312 case 'run':
313 $this->runner->process_action( $action_id, 'Admin List Table' );
314 break;
315 case 'cancel':
316 $this->store->cancel_action( $action_id );
317 break;
318 }
319 $success = 1;
320 $error_message = '';
321 } catch ( Exception $e ) {
322 $success = 0;
323 $error_message = $e->getMessage();
324 }
325 set_transient( 'action_scheduler_admin_notice', compact( 'action_id', 'success', 'error_message', 'row_action_type' ), 30 );
326 }
327 public function prepare_items() {
328 $this->prepare_column_headers();
329 $per_page = $this->get_items_per_page( $this->get_per_page_option_name(), $this->items_per_page );
330 $query = array(
331 'per_page' => $per_page,
332 'offset' => $this->get_items_offset(),
333 'status' => $this->get_request_status(),
334 'orderby' => $this->get_request_orderby(),
335 'order' => $this->get_request_order(),
336 'search' => $this->get_request_search_query(),
337 );
338 if ( 'past-due' === $this->get_request_status() ) {
339 $query['status'] = ActionScheduler_Store::STATUS_PENDING;
340 $query['date'] = as_get_datetime_object();
341 }
342 $this->items = array();
343 $total_items = $this->store->query_actions( $query, 'count' );
344 $status_labels = $this->store->get_status_labels();
345 foreach ( $this->store->query_actions( $query ) as $action_id ) {
346 try {
347 $action = $this->store->fetch_action( $action_id );
348 } catch ( Exception $e ) {
349 continue;
350 }
351 if ( is_a( $action, 'ActionScheduler_NullAction' ) ) {
352 continue;
353 }
354 $this->items[ $action_id ] = array(
355 'ID' => $action_id,
356 'hook' => $action->get_hook(),
357 'status_name' => $this->store->get_status( $action_id ),
358 'status' => $status_labels[ $this->store->get_status( $action_id ) ],
359 'args' => $action->get_args(),
360 'group' => $action->get_group(),
361 'log_entries' => $this->logger->get_logs( $action_id ),
362 'claim_id' => $this->store->get_claim_id( $action_id ),
363 'recurrence' => $this->get_recurrence( $action ),
364 'schedule' => $action->get_schedule(),
365 );
366 }
367 $this->set_pagination_args(
368 array(
369 'total_items' => $total_items,
370 'per_page' => $per_page,
371 'total_pages' => ceil( $total_items / $per_page ),
372 )
373 );
374 }
375 protected function display_filter_by_status() {
376 $this->status_counts = $this->store->action_counts() + $this->store->extra_action_counts();
377 parent::display_filter_by_status();
378 }
379 protected function get_search_box_button_text() {
380 return __( 'Search hook, args and claim ID', 'action-scheduler' );
381 }
382 protected function get_per_page_option_name() {
383 return str_replace( '-', '_', $this->screen->id ) . '_per_page';
384 }
385 }
386