Automattic\WooCommerce\Internal\Admin\ProductReviews

ReviewsListTable::get_views()protectedWC 1.0

Returns the available status filters.

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

Хуков нет.

Возвращает

Массив. An associative array of fully-formed comment status links. Includes 'All', 'Pending', 'Approved', 'Spam', and 'Trash'.

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

// protected - в коде основоного (родительского) или дочернего класса
$result = $this->get_views() : array;

Заметки

Код ReviewsListTable::get_views() WC 8.7.0

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;
}