ActionScheduler_wpPostStore::action_counts()publicWC 1.0

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

Method of the class: ActionScheduler_wpPostStore{}

No Hooks.

Return

Array.

Usage

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

ActionScheduler_wpPostStore::action_counts() code WC 9.3.3

public function action_counts() {

	$action_counts_by_status = array();
	$action_stati_and_labels = $this->get_status_labels();
	$posts_count_by_status   = (array) wp_count_posts( self::POST_TYPE, 'readable' );

	foreach ( $posts_count_by_status as $post_status_name => $count ) {

		try {
			$action_status_name = $this->get_action_status_by_post_status( $post_status_name );
		} catch ( Exception $e ) {
			// Ignore any post statuses that aren't for actions.
			continue;
		}
		if ( array_key_exists( $action_status_name, $action_stati_and_labels ) ) {
			$action_counts_by_status[ $action_status_name ] = $count;
		}
	}

	return $action_counts_by_status;
}