Automattic\WooCommerce\Internal\Admin\ProductReviews

ReviewsListTable::get_views()protectedWC 1.0

Returns the available status filters.

Method of the class: ReviewsListTable{}

No Hooks.

Return

Array. An associative array of fully-formed comment status links. Includes 'All', 'Pending', 'Approved', 'Spam', and 'Trash'.

Usage

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

Notes

ReviewsListTable::get_views() code WC 9.4.2

protected function get_views() : array {
	global $post_id, $comment_status, $comment_type;

	$status_links = [];

	$status_labels = $this->get_status_filters();

	if ( ! EMPTY_TRASH_DAYS ) {
		unset( $status_labels['trash'] );
	}

	$link = $this->get_view_url( (string) $comment_type, (int) $post_id );

	foreach ( $status_labels as $status => $label ) {
		$current_link_attributes = '';

		if ( $status === $comment_status ) {
			$current_link_attributes = ' class="current" aria-current="page"';
		}

		$link = add_query_arg( 'comment_status', urlencode( $status ), $link );

		$number_reviews_for_status = $this->get_review_count( $status, (int) $post_id );

		$count_html = sprintf(
			'<span class="%s-count">%s</span>',
			( 'moderated' === $status ) ? 'pending' : $status,
			number_format_i18n( $number_reviews_for_status )
		);

		$status_links[ $status ] = '<a href="' . esc_url( $link ) . '"' . $current_link_attributes . '>' . sprintf( translate_nooped_plural( $label, $number_reviews_for_status ), $count_html ) . '</a>';
	}

	return $status_links;
}