Automattic\WooCommerce\Blocks\BlockTypes

ProductFilterRating::render_rating_label()privateWC 1.0

Render the rating label.

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

Хуков нет.

Возвращает

Строку|false.

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

// private - только в коде основоного (родительского) класса
$result = $this->render_rating_label( $rating, $count_label );
$rating(int) (обязательный)
The rating to render.
$count_label(строка) (обязательный)
The count label to render.

Код ProductFilterRating::render_rating_label() WC 9.4.2

<?php
private function render_rating_label( $rating, $count_label ) {
	$width = $rating * 20;

	$rating_label = sprintf(
		/* translators: %1$d is referring to rating value. Example: Rated 4 out of 5. */
		__( 'Rated %1$d out of 5', 'woocommerce' ),
		$rating,
	);

	ob_start();
	?>
	<div class="wc-block-components-product-rating">
		<div class="wc-block-components-product-rating__stars" role="img" aria-label="<?php echo esc_attr( $rating_label ); ?>">
			<span style="width: <?php echo esc_attr( $width ); ?>%" aria-hidden="true">
			</span>
		</div>
		<span class="wc-block-components-product-rating-count">
			<?php echo esc_html( $count_label ); ?>
		</span>
	</div>
	<?php
	return ob_get_clean();
}