PluginProbe ʕ •ᴥ•ʔ
WP Mail SMTP by WPForms – The Most Popular SMTP and Email Log Plugin / 3.11.0
WP Mail SMTP by WPForms – The Most Popular SMTP and Email Log Plugin v3.11.0
4.9.0 0.9.6 1.0.0 1.0.1 1.0.2 1.1.0 1.2.0 1.2.1 1.2.2 1.2.3 1.2.4 1.2.5 1.3.0 1.3.1 1.3.2 1.3.3 1.4.0 1.4.1 1.4.2 1.5.0 1.5.1 1.5.2 1.6.0 1.6.2 1.7.0 1.7.1 1.8.0 1.8.1 1.9.0 2.0.0 2.0.1 2.1.1 2.2.1 2.3.1 2.4.0 2.5.0 2.5.1 2.6.0 2.7.0 2.8.0 2.9.0 3.0.1 3.0.2 3.0.3 3.1.0 3.10.0 3.11.0 3.11.1 3.2.0 3.2.1 3.3.0 3.4.0 3.5.0 3.5.1 3.5.2 3.6.1 3.7.0 3.8.0 3.8.2 3.9.0 4.0.1 4.1.0 4.1.1 4.2.0 4.3.0 4.4.0 4.5.0 4.6.0 4.7.0 4.7.1 4.8.0 trunk 0.10.0 0.10.1 0.11.1 0.11.2 0.3.1 0.3.2 0.4 0.4.1 0.4.2 0.5.0 0.5.1 0.5.2 0.6 0.7 0.8 0.8.2 0.8.3 0.8.4 0.8.5 0.8.6 0.8.7 0.9.0 0.9.1 0.9.2 0.9.3 0.9.4 0.9.5
wp-mail-smtp / vendor / woocommerce / action-scheduler / classes / ActionScheduler_AdminView.php
wp-mail-smtp / vendor / woocommerce / action-scheduler / classes Last commit date
WP_CLI 2 years ago abstracts 2 years ago actions 2 years ago data-stores 2 years ago migration 2 years ago schedules 2 years ago schema 2 years ago ActionScheduler_ActionClaim.php 2 years ago ActionScheduler_ActionFactory.php 2 years ago ActionScheduler_AdminView.php 2 years ago ActionScheduler_AsyncRequest_QueueRunner.php 2 years ago ActionScheduler_Compatibility.php 2 years ago ActionScheduler_DataController.php 2 years ago ActionScheduler_DateTime.php 2 years ago ActionScheduler_Exception.php 2 years ago ActionScheduler_FatalErrorMonitor.php 2 years ago ActionScheduler_InvalidActionException.php 2 years ago ActionScheduler_ListTable.php 2 years ago ActionScheduler_LogEntry.php 2 years ago ActionScheduler_NullLogEntry.php 2 years ago ActionScheduler_OptionLock.php 2 years ago ActionScheduler_QueueCleaner.php 2 years ago ActionScheduler_QueueRunner.php 2 years ago ActionScheduler_Versions.php 2 years ago ActionScheduler_WPCommentCleaner.php 2 years ago ActionScheduler_wcSystemStatus.php 2 years ago
ActionScheduler_AdminView.php
253 lines
1 <?php
2
3 /**
4 * Class ActionScheduler_AdminView
5 * @codeCoverageIgnore
6 */
7 class ActionScheduler_AdminView extends ActionScheduler_AdminView_Deprecated {
8
9 private static $admin_view = NULL;
10
11 private static $screen_id = 'tools_page_action-scheduler';
12
13 /** @var ActionScheduler_ListTable */
14 protected $list_table;
15
16 /**
17 * @return ActionScheduler_AdminView
18 * @codeCoverageIgnore
19 */
20 public static function instance() {
21
22 if ( empty( self::$admin_view ) ) {
23 $class = apply_filters('action_scheduler_admin_view_class', 'ActionScheduler_AdminView');
24 self::$admin_view = new $class();
25 }
26
27 return self::$admin_view;
28 }
29
30 /**
31 * @codeCoverageIgnore
32 */
33 public function init() {
34 if ( is_admin() && ( ! defined( 'DOING_AJAX' ) || false == DOING_AJAX ) ) {
35
36 if ( class_exists( 'WooCommerce' ) ) {
37 add_action( 'woocommerce_admin_status_content_action-scheduler', array( $this, 'render_admin_ui' ) );
38 add_action( 'woocommerce_system_status_report', array( $this, 'system_status_report' ) );
39 add_filter( 'woocommerce_admin_status_tabs', array( $this, 'register_system_status_tab' ) );
40 }
41
42 add_action( 'admin_menu', array( $this, 'register_menu' ) );
43 add_action( 'admin_notices', array( $this, 'maybe_check_pastdue_actions' ) );
44 add_action( 'current_screen', array( $this, 'add_help_tabs' ) );
45 }
46 }
47
48 public function system_status_report() {
49 $table = new ActionScheduler_wcSystemStatus( ActionScheduler::store() );
50 $table->render();
51 }
52
53 /**
54 * Registers action-scheduler into WooCommerce > System status.
55 *
56 * @param array $tabs An associative array of tab key => label.
57 * @return array $tabs An associative array of tab key => label, including Action Scheduler's tabs
58 */
59 public function register_system_status_tab( array $tabs ) {
60 $tabs['action-scheduler'] = __( 'Scheduled Actions', 'action-scheduler' );
61
62 return $tabs;
63 }
64
65 /**
66 * Include Action Scheduler's administration under the Tools menu.
67 *
68 * A menu under the Tools menu is important for backward compatibility (as that's
69 * where it started), and also provides more convenient access than the WooCommerce
70 * System Status page, and for sites where WooCommerce isn't active.
71 */
72 public function register_menu() {
73 $hook_suffix = add_submenu_page(
74 'tools.php',
75 __( 'Scheduled Actions', 'action-scheduler' ),
76 __( 'Scheduled Actions', 'action-scheduler' ),
77 'manage_options',
78 'action-scheduler',
79 array( $this, 'render_admin_ui' )
80 );
81 add_action( 'load-' . $hook_suffix , array( $this, 'process_admin_ui' ) );
82 }
83
84 /**
85 * Triggers processing of any pending actions.
86 */
87 public function process_admin_ui() {
88 $this->get_list_table();
89 }
90
91 /**
92 * Renders the Admin UI
93 */
94 public function render_admin_ui() {
95 $table = $this->get_list_table();
96 $table->display_page();
97 }
98
99 /**
100 * Get the admin UI object and process any requested actions.
101 *
102 * @return ActionScheduler_ListTable
103 */
104 protected function get_list_table() {
105 if ( null === $this->list_table ) {
106 $this->list_table = new ActionScheduler_ListTable( ActionScheduler::store(), ActionScheduler::logger(), ActionScheduler::runner() );
107 $this->list_table->process_actions();
108 }
109
110 return $this->list_table;
111 }
112
113 /**
114 * Action: admin_notices
115 *
116 * Maybe check past-due actions, and print notice.
117 *
118 * @uses $this->check_pastdue_actions()
119 */
120 public function maybe_check_pastdue_actions() {
121
122 # Filter to prevent checking actions (ex: inappropriate user).
123 if ( ! apply_filters( 'action_scheduler_check_pastdue_actions', current_user_can( 'manage_options' ) ) ) {
124 return;
125 }
126
127 # Get last check transient.
128 $last_check = get_transient( 'action_scheduler_last_pastdue_actions_check' );
129
130 # If transient exists, we're within interval, so bail.
131 if ( ! empty( $last_check ) ) {
132 return;
133 }
134
135 # Perform the check.
136 $this->check_pastdue_actions();
137 }
138
139 /**
140 * 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 */
144 protected function check_pastdue_actions() {
145
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 );
149
150 // Set fallback value for past-due actions count.
151 $num_pastdue_actions = 0;
152
153 // Allow third-parties to preempt the default check logic.
154 $check = apply_filters( 'action_scheduler_pastdue_actions_check_pre', null );
155
156 // If no third-party preempted and there are no past-due actions, return early.
157 if ( ! is_null( $check ) ) {
158 return;
159 }
160
161 # Scheduled actions query arguments.
162 $query_args = array(
163 'date' => as_get_datetime_object( time() - $threshold_seconds ),
164 'status' => ActionScheduler_Store::STATUS_PENDING,
165 'per_page' => $threshhold_min,
166 );
167
168 # If no third-party preempted, run default check.
169 if ( is_null( $check ) ) {
170 $store = ActionScheduler_Store::instance();
171 $num_pastdue_actions = ( int ) $store->query_actions( $query_args, 'count' );
172
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 );
176 }
177
178 # If check failed, set transient and abort.
179 if ( ! boolval( $check ) ) {
180 $interval = apply_filters( 'action_scheduler_pastdue_actions_check_interval', round( $threshold_seconds / 4 ), $threshold_seconds );
181 set_transient( 'action_scheduler_last_pastdue_actions_check', time(), $interval );
182
183 return;
184 }
185
186 $actions_url = add_query_arg( array(
187 'page' => 'action-scheduler',
188 'status' => 'past-due',
189 'order' => 'asc',
190 ), admin_url( 'tools.php' ) );
191
192 # Print notice.
193 echo '<div class="notice notice-warning"><p>';
194 printf(
195 _n(
196 // 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'
201 ),
202 $num_pastdue_actions,
203 esc_attr( esc_url( $actions_url ) )
204 );
205 echo '</p></div>';
206
207 # Facilitate third-parties to evaluate and print notices.
208 do_action( 'action_scheduler_pastdue_actions_extra_notices', $query_args );
209 }
210
211 /**
212 * Provide more information about the screen and its data in the help tab.
213 */
214 public function add_help_tabs() {
215 $screen = get_current_screen();
216
217 if ( ! $screen || self::$screen_id != $screen->id ) {
218 return;
219 }
220
221 $as_version = ActionScheduler_Versions::instance()->latest_version();
222 $screen->add_help_tab(
223 array(
224 'id' => 'action_scheduler_about',
225 'title' => __( 'About', 'action-scheduler' ),
226 'content' =>
227 '<h2>' . sprintf( __( 'About Action Scheduler %s', 'action-scheduler' ), $as_version ) . '</h2>' .
228 '<p>' .
229 __( '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 '</p>',
231 )
232 );
233
234 $screen->add_help_tab(
235 array(
236 'id' => 'action_scheduler_columns',
237 'title' => __( 'Columns', 'action-scheduler' ),
238 'content' =>
239 '<h2>' . __( 'Scheduled Action Columns', 'action-scheduler' ) . '</h2>' .
240 '<ul>' .
241 sprintf( '<li><strong>%1$s</strong>: %2$s</li>', __( 'Hook', 'action-scheduler' ), __( 'Name of the action hook that will be triggered.', 'action-scheduler' ) ) .
242 sprintf( '<li><strong>%1$s</strong>: %2$s</li>', __( 'Status', 'action-scheduler' ), __( 'Action statuses are Pending, Complete, Canceled, Failed', 'action-scheduler' ) ) .
243 sprintf( '<li><strong>%1$s</strong>: %2$s</li>', __( 'Arguments', 'action-scheduler' ), __( 'Optional data array passed to the action hook.', 'action-scheduler' ) ) .
244 sprintf( '<li><strong>%1$s</strong>: %2$s</li>', __( 'Group', 'action-scheduler' ), __( 'Optional action group.', 'action-scheduler' ) ) .
245 sprintf( '<li><strong>%1$s</strong>: %2$s</li>', __( 'Recurrence', 'action-scheduler' ), __( 'The action\'s schedule frequency.', 'action-scheduler' ) ) .
246 sprintf( '<li><strong>%1$s</strong>: %2$s</li>', __( 'Scheduled', 'action-scheduler' ), __( 'The date/time the action is/was scheduled to run.', 'action-scheduler' ) ) .
247 sprintf( '<li><strong>%1$s</strong>: %2$s</li>', __( 'Log', 'action-scheduler' ), __( 'Activity log for the action.', 'action-scheduler' ) ) .
248 '</ul>',
249 )
250 );
251 }
252 }
253