ActionScheduler_DBStore::action_counts()publicWC 1.0

Get a count of all actions in the store, grouped by status.

Метод класса: ActionScheduler_DBStore{}

Хуков нет.

Возвращает

Массив. Set of 'status' => int $count pairs for statuses with 1 or more actions of that status.

Использование

$ActionScheduler_DBStore = new ActionScheduler_DBStore();
$ActionScheduler_DBStore->action_counts();

Код ActionScheduler_DBStore::action_counts() WC 8.7.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;
}