Automattic\WooCommerce\Blocks\BlockTypes
ProductFilterRating::render_rating_label()
Render the rating label.
Method of the class: ProductFilterRating{}
No Hooks.
Return
String|false
.
Usage
// private - for code of main (parent) class only $result = $this->render_rating_label( $rating, $count_label );
- $rating(int) (required)
- The rating to render.
- $count_label(string) (required)
- The count label to render.
ProductFilterRating::render_rating_label() ProductFilterRating::render rating label code WC 9.7.1
<?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(); }