ActionScheduler_Abstract_ListTable::display_filter_by_status()protectedWC 1.0

Prints the available statuses so the user can click to filter.

Method of the class: ActionScheduler_Abstract_ListTable{}

No Hooks.

Return

null. Nothing (null).

Usage

// protected - for code of main (parent) or child class
$result = $this->display_filter_by_status();

ActionScheduler_Abstract_ListTable::display_filter_by_status() code WC 9.3.3

protected function display_filter_by_status() {

	$status_list_items = array();
	$request_status    = $this->get_request_status();

	// Helper to set 'all' filter when not set on status counts passed in.
	if ( ! isset( $this->status_counts['all'] ) ) {
		$all_count = array_sum( $this->status_counts );
		if ( isset( $this->status_counts['past-due'] ) ) {
			$all_count -= $this->status_counts['past-due'];
		}
		$this->status_counts = array( 'all' => $all_count ) + $this->status_counts;
	}

	// Translated status labels.
	$status_labels             = ActionScheduler_Store::instance()->get_status_labels();
	$status_labels['all']      = esc_html_x( 'All', 'status labels', 'woocommerce' );
	$status_labels['past-due'] = esc_html_x( 'Past-due', 'status labels', 'woocommerce' );

	foreach ( $this->status_counts as $status_slug => $count ) {

		if ( 0 === $count ) {
			continue;
		}

		if ( $status_slug === $request_status || ( empty( $request_status ) && 'all' === $status_slug ) ) {
			$status_list_item = '<li class="%1$s"><a href="%2$s" class="current">%3$s</a> (%4$d)</li>';
		} else {
			$status_list_item = '<li class="%1$s"><a href="%2$s">%3$s</a> (%4$d)</li>';
		}

		$status_name         = isset( $status_labels[ $status_slug ] ) ? $status_labels[ $status_slug ] : ucfirst( $status_slug );
		$status_filter_url   = ( 'all' === $status_slug ) ? remove_query_arg( 'status' ) : add_query_arg( 'status', $status_slug );
		$status_filter_url   = remove_query_arg( array( 'paged', 's' ), $status_filter_url );
		$status_list_items[] = sprintf( $status_list_item, esc_attr( $status_slug ), esc_url( $status_filter_url ), esc_html( $status_name ), absint( $count ) );
	}

	if ( $status_list_items ) {
		echo '<ul class="subsubsub">';
		echo implode( " | \n", $status_list_items ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
		echo '</ul>';
	}
}