ActionScheduler_DBStore::action_counts
Get a count of all actions in the store, grouped by status.
Method of the class: ActionScheduler_DBStore{}
No Hooks.
Returns
Array. Set of 'status' => int $count pairs for statuses with 1 or more actions of that status.
Usage
$ActionScheduler_DBStore = new ActionScheduler_DBStore(); $ActionScheduler_DBStore->action_counts();
ActionScheduler_DBStore::action_counts() ActionScheduler DBStore::action counts code WC 10.5.0
public function action_counts() {
global $wpdb;
$sql = "SELECT a.status, count(a.status) as 'count'";
$sql .= " FROM {$wpdb->actionscheduler_actions} a";
$sql .= ' GROUP BY a.status';
$actions_count_by_status = array();
$action_stati_and_labels = $this->get_status_labels();
foreach ( $wpdb->get_results( $sql ) as $action_data ) { // phpcs:ignore WordPress.DB.PreparedSQL.NotPrepared
// Ignore any actions with invalid status.
if ( array_key_exists( $action_data->status, $action_stati_and_labels ) ) {
$actions_count_by_status[ $action_data->status ] = $action_data->count;
}
}
return $actions_count_by_status;
}