PluginProbe ʕ •ᴥ•ʔ
WP Mail SMTP by WPForms – The Most Popular SMTP and Email Log Plugin / 2.1.1
WP Mail SMTP by WPForms – The Most Popular SMTP and Email Log Plugin v2.1.1
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_wcSystemStatus.php
wp-mail-smtp / vendor / woocommerce / action-scheduler / classes Last commit date
WP_CLI 6 years ago abstracts 6 years ago actions 6 years ago data-stores 6 years ago migration 6 years ago schedules 6 years ago schema 6 years ago ActionScheduler_ActionClaim.php 6 years ago ActionScheduler_ActionFactory.php 6 years ago ActionScheduler_AdminView.php 6 years ago ActionScheduler_AsyncRequest_QueueRunner.php 6 years ago ActionScheduler_Compatibility.php 6 years ago ActionScheduler_DataController.php 6 years ago ActionScheduler_DateTime.php 6 years ago ActionScheduler_Exception.php 6 years ago ActionScheduler_FatalErrorMonitor.php 6 years ago ActionScheduler_InvalidActionException.php 6 years ago ActionScheduler_ListTable.php 6 years ago ActionScheduler_LogEntry.php 6 years ago ActionScheduler_NullLogEntry.php 6 years ago ActionScheduler_OptionLock.php 6 years ago ActionScheduler_QueueCleaner.php 6 years ago ActionScheduler_QueueRunner.php 6 years ago ActionScheduler_Versions.php 6 years ago ActionScheduler_WPCommentCleaner.php 6 years ago ActionScheduler_wcSystemStatus.php 6 years ago
ActionScheduler_wcSystemStatus.php
153 lines
1 <?php
2
3 /**
4 * Class ActionScheduler_wcSystemStatus
5 */
6 class ActionScheduler_wcSystemStatus {
7
8 /**
9 * The active data stores
10 *
11 * @var ActionScheduler_Store
12 */
13 protected $store;
14
15 function __construct( $store ) {
16 $this->store = $store;
17 }
18
19 /**
20 * Display action data, including number of actions grouped by status and the oldest & newest action in each status.
21 *
22 * Helpful to identify issues, like a clogged queue.
23 */
24 public function render() {
25 $action_counts = $this->store->action_counts();
26 $status_labels = $this->store->get_status_labels();
27 $oldest_and_newest = $this->get_oldest_and_newest( array_keys( $status_labels ) );
28
29 $this->get_template( $status_labels, $action_counts, $oldest_and_newest );
30 }
31
32 /**
33 * Get oldest and newest scheduled dates for a given set of statuses.
34 *
35 * @param array $status_keys Set of statuses to find oldest & newest action for.
36 * @return array
37 */
38 protected function get_oldest_and_newest( $status_keys ) {
39
40 $oldest_and_newest = array();
41
42 foreach ( $status_keys as $status ) {
43 $oldest_and_newest[ $status ] = array(
44 'oldest' => '&ndash;',
45 'newest' => '&ndash;',
46 );
47
48 if ( 'in-progress' === $status ) {
49 continue;
50 }
51
52 $oldest_and_newest[ $status ]['oldest'] = $this->get_action_status_date( $status, 'oldest' );
53 $oldest_and_newest[ $status ]['newest'] = $this->get_action_status_date( $status, 'newest' );
54 }
55
56 return $oldest_and_newest;
57 }
58
59 /**
60 * Get oldest or newest scheduled date for a given status.
61 *
62 * @param string $status Action status label/name string.
63 * @param string $date_type Oldest or Newest.
64 * @return DateTime
65 */
66 protected function get_action_status_date( $status, $date_type = 'oldest' ) {
67
68 $order = 'oldest' === $date_type ? 'ASC' : 'DESC';
69
70 $action = $this->store->query_actions( array(
71 'claimed' => false,
72 'status' => $status,
73 'per_page' => 1,
74 'order' => $order,
75 ) );
76
77 if ( ! empty( $action ) ) {
78 $date_object = $this->store->get_date( $action[0] );
79 $action_date = $date_object->format( 'Y-m-d H:i:s O' );
80 } else {
81 $action_date = '&ndash;';
82 }
83
84 return $action_date;
85 }
86
87 /**
88 * Get oldest or newest scheduled date for a given status.
89 *
90 * @param array $status_labels Set of statuses to find oldest & newest action for.
91 * @param array $action_counts Number of actions grouped by status.
92 * @param array $oldest_and_newest Date of the oldest and newest action with each status.
93 */
94 protected function get_template( $status_labels, $action_counts, $oldest_and_newest ) {
95 $as_version = ActionScheduler_Versions::instance()->latest_version();
96 ?>
97
98 <table class="wc_status_table widefat" cellspacing="0">
99 <thead>
100 <tr>
101 <th colspan="5" data-export-label="Action Scheduler"><h2><?php esc_html_e( 'Action Scheduler', 'action-scheduler' ); ?><?php echo wc_help_tip( esc_html__( 'This section shows scheduled action counts.', 'action-scheduler' ) ); ?></h2></th>
102 </tr>
103 <tr>
104 <td colspan="2" data-export-label="Version"><?php esc_html_e( 'Version:', 'action-scheduler' ); ?></td>
105 <td colspan="3"><?php echo esc_html( $as_version ); ?></td>
106 </tr>
107 <tr>
108 <td><strong><?php esc_html_e( 'Action Status', 'action-scheduler' ); ?></strong></td>
109 <td class="help">&nbsp;</td>
110 <td><strong><?php esc_html_e( 'Count', 'action-scheduler' ); ?></strong></td>
111 <td><strong><?php esc_html_e( 'Oldest Scheduled Date', 'action-scheduler' ); ?></strong></td>
112 <td><strong><?php esc_html_e( 'Newest Scheduled Date', 'action-scheduler' ); ?></strong></td>
113 </tr>
114 </thead>
115 <tbody>
116 <?php
117 foreach ( $action_counts as $status => $count ) {
118 // WC uses the 3rd column for export, so we need to display more data in that (hidden when viewed as part of the table) and add an empty 2nd column.
119 printf(
120 '<tr><td>%1$s</td><td>&nbsp;</td><td>%2$s<span style="display: none;">, Oldest: %3$s, Newest: %4$s</span></td><td>%3$s</td><td>%4$s</td></tr>',
121 esc_html( $status_labels[ $status ] ),
122 number_format_i18n( $count ),
123 $oldest_and_newest[ $status ]['oldest'],
124 $oldest_and_newest[ $status ]['newest']
125 );
126 }
127 ?>
128 </tbody>
129 </table>
130
131 <?php
132 }
133
134 /**
135 * is triggered when invoking inaccessible methods in an object context.
136 *
137 * @param string $name
138 * @param array $arguments
139 *
140 * @return mixed
141 * @link https://php.net/manual/en/language.oop5.overloading.php#language.oop5.overloading.methods
142 */
143 public function __call( $name, $arguments ) {
144 switch ( $name ) {
145 case 'print':
146 _deprecated_function( __CLASS__ . '::print()', '2.2.4', __CLASS__ . '::render()' );
147 return call_user_func_array( array( $this, 'render' ), $arguments );
148 }
149
150 return null;
151 }
152 }
153