ActionScheduler_ListTable::prepare_items()publicWC 1.0

{@inheritDoc}

Method of the class: ActionScheduler_ListTable{}

No Hooks.

Return

null. Nothing (null).

Usage

$ActionScheduler_ListTable = new ActionScheduler_ListTable();
$ActionScheduler_ListTable->prepare_items();

ActionScheduler_ListTable::prepare_items() code WC 9.3.3

public function prepare_items() {
	$this->prepare_column_headers();

	$per_page = $this->get_items_per_page( $this->get_per_page_option_name(), $this->items_per_page );

	$query = array(
		'per_page' => $per_page,
		'offset'   => $this->get_items_offset(),
		'status'   => $this->get_request_status(),
		'orderby'  => $this->get_request_orderby(),
		'order'    => $this->get_request_order(),
		'search'   => $this->get_request_search_query(),
	);

	/**
	 * Change query arguments to query for past-due actions.
	 * Past-due actions have the 'pending' status and are in the past.
	 * This is needed because registering 'past-due' as a status is overkill.
	 */
	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' );

	$status_labels = $this->store->get_status_labels();

	foreach ( $this->store->query_actions( $query ) as $action_id ) {
		try {
			$action = $this->store->fetch_action( $action_id );
		} catch ( Exception $e ) {
			continue;
		}
		if ( is_a( $action, 'ActionScheduler_NullAction' ) ) {
			continue;
		}
		$this->items[ $action_id ] = array(
			'ID'          => $action_id,
			'hook'        => $action->get_hook(),
			'status_name' => $this->store->get_status( $action_id ),
			'status'      => $status_labels[ $this->store->get_status( $action_id ) ],
			'args'        => $action->get_args(),
			'group'       => $action->get_group(),
			'log_entries' => $this->logger->get_logs( $action_id ),
			'claim_id'    => $this->store->get_claim_id( $action_id ),
			'recurrence'  => $this->get_recurrence( $action ),
			'schedule'    => $action->get_schedule(),
		);
	}

	$this->set_pagination_args( array(
		'total_items' => $total_items,
		'per_page'    => $per_page,
		'total_pages' => ceil( $total_items / $per_page ),
	) );
}