forked from MinnPost/object-sync-for-salesforce
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
this fixes MinnPost#247 by updating action scheduler
- Loading branch information
1 parent
cd1f274
commit 59faee5
Showing
9 changed files
with
217 additions
and
33 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,7 +5,7 @@ | |
* Description: A robust scheduling library for use in WordPress plugins. | ||
* Author: Prospress | ||
* Author URI: http://prospress.com/ | ||
* Version: 2.2.0 | ||
* Version: 2.2.1 | ||
* License: GPLv3 | ||
* | ||
* Copyright 2018 Prospress, Inc. (email : [email protected]) | ||
|
@@ -25,21 +25,21 @@ | |
* | ||
*/ | ||
|
||
if ( ! function_exists( 'action_scheduler_register_2_dot_2_dot_0' ) ) { | ||
if ( ! function_exists( 'action_scheduler_register_2_dot_2_dot_1' ) ) { | ||
|
||
if ( ! class_exists( 'ActionScheduler_Versions' ) ) { | ||
require_once( 'classes/ActionScheduler_Versions.php' ); | ||
add_action( 'plugins_loaded', array( 'ActionScheduler_Versions', 'initialize_latest_version' ), 1, 0 ); | ||
} | ||
|
||
add_action( 'plugins_loaded', 'action_scheduler_register_2_dot_2_dot_0', 0, 0 ); | ||
add_action( 'plugins_loaded', 'action_scheduler_register_2_dot_2_dot_1', 0, 0 ); | ||
|
||
function action_scheduler_register_2_dot_2_dot_0() { | ||
function action_scheduler_register_2_dot_2_dot_1() { | ||
$versions = ActionScheduler_Versions::instance(); | ||
$versions->register( '2.2.0', 'action_scheduler_initialize_2_dot_2_dot_0' ); | ||
$versions->register( '2.2.1', 'action_scheduler_initialize_2_dot_2_dot_1' ); | ||
} | ||
|
||
function action_scheduler_initialize_2_dot_2_dot_0() { | ||
function action_scheduler_initialize_2_dot_2_dot_1() { | ||
require_once( 'classes/ActionScheduler.php' ); | ||
ActionScheduler::init( __FILE__ ); | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
129 changes: 129 additions & 0 deletions
129
vendor/prospress/action-scheduler/classes/ActionScheduler_wcSystemStatus.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,129 @@ | ||
<?php | ||
|
||
/** | ||
* Class ActionScheduler_wcSystemStatus | ||
*/ | ||
class ActionScheduler_wcSystemStatus { | ||
|
||
/** | ||
* The active data stores | ||
* | ||
* @var ActionScheduler_Store | ||
*/ | ||
protected $store; | ||
|
||
function __construct( $store ) { | ||
$this->store = $store; | ||
} | ||
|
||
/** | ||
* Display action data, including number of actions grouped by status and the oldest & newest action in each status. | ||
* | ||
* Helpful to identify issues, like a clogged queue. | ||
*/ | ||
public function print() { | ||
$action_counts = $this->store->action_counts(); | ||
$status_labels = $this->store->get_status_labels(); | ||
$oldest_and_newest = $this->get_oldest_and_newest( array_keys( $status_labels ) ); | ||
|
||
$this->get_template( $status_labels, $action_counts, $oldest_and_newest ); | ||
} | ||
|
||
/** | ||
* Get oldest and newest scheduled dates for a given set of statuses. | ||
* | ||
* @param array $status_keys Set of statuses to find oldest & newest action for. | ||
* @return array | ||
*/ | ||
protected function get_oldest_and_newest( $status_keys ) { | ||
|
||
$oldest_and_newest = array(); | ||
|
||
foreach ( $status_keys as $status ) { | ||
$oldest_and_newest[ $status ] = array( | ||
'oldest' => '–', | ||
'newest' => '–', | ||
); | ||
|
||
if ( 'in-progress' === $status ) { | ||
continue; | ||
} | ||
|
||
$oldest_and_newest[ $status ]['oldest'] = $this->get_action_status_date( $status, 'oldest' ); | ||
$oldest_and_newest[ $status ]['newest'] = $this->get_action_status_date( $status, 'newest' ); | ||
} | ||
|
||
return $oldest_and_newest; | ||
} | ||
|
||
/** | ||
* Get oldest or newest scheduled date for a given status. | ||
* | ||
* @param string $status Action status label/name string. | ||
* @param string $date_type Oldest or Newest. | ||
* @return DateTime | ||
*/ | ||
protected function get_action_status_date( $status, $date_type = 'oldest' ) { | ||
|
||
$order = 'oldest' === $date_type ? 'ASC' : 'DESC'; | ||
|
||
$action = $this->store->query_actions( array( | ||
'claimed' => false, | ||
'status' => $status, | ||
'per_page' => 1, | ||
'order' => $order, | ||
) ); | ||
|
||
if ( ! empty( $action ) ) { | ||
$date_object = $this->store->get_date( $action[0] ); | ||
$action_date = $date_object->format( 'Y-m-d H:i:s O' ); | ||
} else { | ||
$action_date = '–'; | ||
} | ||
|
||
return $action_date; | ||
} | ||
|
||
/** | ||
* Get oldest or newest scheduled date for a given status. | ||
* | ||
* @param array $status_labels Set of statuses to find oldest & newest action for. | ||
* @param array $action_counts Number of actions grouped by status. | ||
* @param array $oldest_and_newest Date of the oldest and newest action with each status. | ||
*/ | ||
protected function get_template( $status_labels, $action_counts, $oldest_and_newest ) { | ||
?> | ||
|
||
<table class="wc_status_table widefat" cellspacing="0"> | ||
<thead> | ||
<tr> | ||
<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> | ||
</tr> | ||
<tr> | ||
<td><strong><?php esc_html_e( 'Action Status', 'action-scheduler' ); ?></strong></td> | ||
<td class="help"> </td> | ||
<td><strong><?php esc_html_e( 'Count', 'action-scheduler' ); ?></strong></td> | ||
<td><strong><?php esc_html_e( 'Oldest Scheduled Date', 'action-scheduler' ); ?></strong></td> | ||
<td><strong><?php esc_html_e( 'Newest Scheduled Date', 'action-scheduler' ); ?></strong></td> | ||
</tr> | ||
</thead> | ||
<tbody> | ||
<?php | ||
foreach ( $action_counts as $status => $count ) { | ||
// 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. | ||
printf( | ||
'<tr><td>%1$s</td><td> </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>', | ||
esc_html( $status_labels[ $status ] ), | ||
number_format_i18n( $count ), | ||
$oldest_and_newest[ $status ]['oldest'], | ||
$oldest_and_newest[ $status ]['newest'] | ||
); | ||
} | ||
?> | ||
</tbody> | ||
</table> | ||
|
||
<?php | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters