Automattic\WooCommerce\Internal\Admin\ProductReviews

ReviewsListTable::review_rating_dropdown()publicWC 1.0

Displays a review rating drop-down for filtering reviews in the Product Reviews list table.

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

Хуков нет.

Возвращает

null. Ничего.

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

$ReviewsListTable = new ReviewsListTable();
$ReviewsListTable->review_rating_dropdown( $current_rating ) : void;
$current_rating(int|строка|разное) (обязательный)
Rating to display reviews for.

Код ReviewsListTable::review_rating_dropdown() WC 6.8.0

<?php
public function review_rating_dropdown( $current_rating ) : void {

	$rating_options = [
		'0' => __( 'All ratings', 'woocommerce' ),
		'1' => '&#9733;',
		'2' => '&#9733;&#9733;',
		'3' => '&#9733;&#9733;&#9733;',
		'4' => '&#9733;&#9733;&#9733;&#9733;',
		'5' => '&#9733;&#9733;&#9733;&#9733;&#9733;',
	];

	?>
	<label class="screen-reader-text" for="filter-by-review-rating"><?php esc_html_e( 'Filter by review rating', 'woocommerce' ); ?></label>
	<select id="filter-by-review-rating" name="review_rating">
		<?php foreach ( $rating_options as $rating => $label ) : ?>
			<?php

			$title = 0 === (int) $rating
				? $label
				: sprintf(
					/* translators: %s: Star rating (1-5). */
					__( '%s-star rating', 'woocommerce' ),
					$rating
				);

			?>
			<option value="<?php echo esc_attr( $rating ); ?>" <?php selected( $rating, (string) $current_rating ); ?> title="<?php echo esc_attr( $title ); ?>"><?php echo esc_html( $label ); ?></option>
		<?php endforeach; ?>
	</select>
	<?php
}