Automattic\WooCommerce\Blocks\BlockTypes
ProductFilterRating::render_rating_label
Render the rating label.
Method of the class: ProductFilterRating{}
No Hooks.
Returns
String|false.
Usage
// private - for code of main (parent) class only $result = $this->render_rating_label( $rating );
- $rating(int) (required)
- The rating to render.
ProductFilterRating::render_rating_label() ProductFilterRating::render rating label code WC 10.5.0
<?php
private function render_rating_label( $rating ) {
$view_box_width = $rating * 24;
$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();
?>
<svg
width="<?php echo esc_attr( $view_box_width ); ?>"
height="24"
viewBox="0 0 <?php echo esc_attr( $view_box_width ); ?> 24"
fill="currentColor"
aria-label="<?php echo esc_attr( $rating_label ); ?>"
>
<?php
for ( $i = 0; $i < $rating; $i++ ) {
?>
<path
d="M12 17.27L18.18 21l-1.64-7.03L22 9.24l-7.19-.61L12 2 9.19 8.63 2 9.24l5.46 4.73L5.82 21z"
transform="translate(<?php echo esc_attr( $i * 24 ); ?>, 0)"
/>
<?php
}
?>
</svg>
<?php
return ob_get_clean();
}