Created
April 1, 2020 21:20
-
-
Save crstauf/b85a83b30f460c0f518461fa8b5f61d8 to your computer and use it in GitHub Desktop.
Patch to implement "Past-due" view on Action Scheduler list table
This file contains hidden or 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
diff --git a/classes/ActionScheduler_ListTable.php b/classes/ActionScheduler_ListTable.php | |
index b680054..d12667e 100644 | |
--- a/classes/ActionScheduler_ListTable.php | |
+++ b/classes/ActionScheduler_ListTable.php | |
@@ -559,6 +559,11 @@ class ActionScheduler_ListTable extends ActionScheduler_Abstract_ListTable { | |
'search' => $this->get_request_search_query(), | |
); | |
+ if ( 'past-due' === $this->get_request_status() ) { | |
+ $query['status'] = ActionScheduler_Store::STATUS_PENDING; | |
+ $query['date'] = as_get_datetime_object(); | |
+ } | |
+ | |
$this->items = array(); | |
$total_items = $this->store->query_actions( $query, 'count' ); | |
diff --git a/classes/data-stores/ActionScheduler_DBStore.php b/classes/data-stores/ActionScheduler_DBStore.php | |
index d70e4ce..bfa4f85 100644 | |
--- a/classes/data-stores/ActionScheduler_DBStore.php | |
+++ b/classes/data-stores/ActionScheduler_DBStore.php | |
@@ -432,6 +432,14 @@ class ActionScheduler_DBStore extends ActionScheduler_Store { | |
} | |
} | |
+ $pastdue_actions_count = $this->query_actions( array( | |
+ 'status' => ActionScheduler_Store::STATUS_PENDING, | |
+ 'date' => as_get_datetime_object(), | |
+ ), 'count' ); | |
+ | |
+ if ( !empty( $pastdue_actions_count ) ) | |
+ $actions_count_by_status['past-due'] = $pastdue_actions_count; | |
+ | |
return $actions_count_by_status; | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment