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_wcSystemStatus.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_wcSystemStatus.php
167 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 /**
16 * Constructor method for ActionScheduler_wcSystemStatus.
17 *
18 * @param ActionScheduler_Store $store Active store object.
19 *
20 * @return void
21 */
22 public function __construct( $store ) {
23 $this->store = $store;
24 }
25
26 /**
27 * Display action data, including number of actions grouped by status and the oldest & newest action in each status.
28 *
29 * Helpful to identify issues, like a clogged queue.
30 */
31 public function render() {
32 $action_counts = $this->store->action_counts();
33 $status_labels = $this->store->get_status_labels();
34 $oldest_and_newest = $this->get_oldest_and_newest( array_keys( $status_labels ) );
35
36 $this->get_template( $status_labels, $action_counts, $oldest_and_newest );
37 }
38
39 /**
40 * Get oldest and newest scheduled dates for a given set of statuses.
41 *
42 * @param array $status_keys Set of statuses to find oldest & newest action for.
43 * @return array
44 */
45 protected function get_oldest_and_newest( $status_keys ) {
46
47 $oldest_and_newest = array();
48
49 foreach ( $status_keys as $status ) {
50 $oldest_and_newest[ $status ] = array(
51 'oldest' => '&ndash;',
52 'newest' => '&ndash;',
53 );
54
55 if ( 'in-progress' === $status ) {
56 continue;
57 }
58
59 $oldest_and_newest[ $status ]['oldest'] = $this->get_action_status_date( $status, 'oldest' );
60 $oldest_and_newest[ $status ]['newest'] = $this->get_action_status_date( $status, 'newest' );
61 }
62
63 return $oldest_and_newest;
64 }
65
66 /**
67 * Get oldest or newest scheduled date for a given status.
68 *
69 * @param string $status Action status label/name string.
70 * @param string $date_type Oldest or Newest.
71 * @return DateTime
72 */
73 protected function get_action_status_date( $status, $date_type = 'oldest' ) {
74
75 $order = 'oldest' === $date_type ? 'ASC' : 'DESC';
76
77 $action = $this->store->query_actions(
78 array(
79 'claimed' => false,
80 'status' => $status,
81 'per_page' => 1,
82 'order' => $order,
83 )
84 );
85
86 if ( ! empty( $action ) ) {
87 $date_object = $this->store->get_date( $action[0] );
88 $action_date = $date_object->format( 'Y-m-d H:i:s O' );
89 } else {
90 $action_date = '&ndash;';
91 }
92
93 return $action_date;
94 }
95
96 /**
97 * Get oldest or newest scheduled date for a given status.
98 *
99 * @param array $status_labels Set of statuses to find oldest & newest action for.
100 * @param array $action_counts Number of actions grouped by status.
101 * @param array $oldest_and_newest Date of the oldest and newest action with each status.
102 */
103 protected function get_template( $status_labels, $action_counts, $oldest_and_newest ) {
104 $as_version = ActionScheduler_Versions::instance()->latest_version();
105 $as_datastore = get_class( ActionScheduler_Store::instance() );
106 ?>
107
108 <table class="wc_status_table widefat" cellspacing="0">
109 <thead>
110 <tr>
111 <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 details of Action Scheduler.', 'action-scheduler' ) ); ?></h2></th>
112 </tr>
113 <tr>
114 <td colspan="2" data-export-label="Version"><?php esc_html_e( 'Version:', 'action-scheduler' ); ?></td>
115 <td colspan="3"><?php echo esc_html( $as_version ); ?></td>
116 </tr>
117 <tr>
118 <td colspan="2" data-export-label="Data store"><?php esc_html_e( 'Data store:', 'action-scheduler' ); ?></td>
119 <td colspan="3"><?php echo esc_html( $as_datastore ); ?></td>
120 </tr>
121 <tr>
122 <td><strong><?php esc_html_e( 'Action Status', 'action-scheduler' ); ?></strong></td>
123 <td class="help">&nbsp;</td>
124 <td><strong><?php esc_html_e( 'Count', 'action-scheduler' ); ?></strong></td>
125 <td><strong><?php esc_html_e( 'Oldest Scheduled Date', 'action-scheduler' ); ?></strong></td>
126 <td><strong><?php esc_html_e( 'Newest Scheduled Date', 'action-scheduler' ); ?></strong></td>
127 </tr>
128 </thead>
129 <tbody>
130 <?php
131 foreach ( $action_counts as $status => $count ) {
132 // 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.
133 printf(
134 '<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>',
135 esc_html( $status_labels[ $status ] ),
136 esc_html( number_format_i18n( $count ) ),
137 esc_html( $oldest_and_newest[ $status ]['oldest'] ),
138 esc_html( $oldest_and_newest[ $status ]['newest'] )
139 );
140 }
141 ?>
142 </tbody>
143 </table>
144
145 <?php
146 }
147
148 /**
149 * Is triggered when invoking inaccessible methods in an object context.
150 *
151 * @param string $name Name of method called.
152 * @param array $arguments Parameters to invoke the method with.
153 *
154 * @return mixed
155 * @link https://php.net/manual/en/language.oop5.overloading.php#language.oop5.overloading.methods
156 */
157 public function __call( $name, $arguments ) {
158 switch ( $name ) {
159 case 'print':
160 _deprecated_function( __CLASS__ . '::print()', '2.2.4', __CLASS__ . '::render()' );
161 return call_user_func_array( array( $this, 'render' ), $arguments );
162 }
163
164 return null;
165 }
166 }
167