Add a screen reader label to the star rating div to avoid screen readers trying to read the text of the star font.

This commit is contained in:
Gerhard 2019-01-29 13:34:04 +02:00
parent 00a93ae8f0
commit e74f0acc19
1 changed files with 2 additions and 1 deletions

View File

@ -3292,7 +3292,8 @@ function wc_get_stock_html( $product ) {
* @return string
*/
function wc_get_rating_html( $rating, $count = 0 ) {
$html = 0 < $rating ? '<div class="star-rating">' . wc_get_star_rating_html( $rating, $count ) . '</div>' : '';
/* translators: screen reader rating value */
$html = 0 < $rating ? '<div class="star-rating" aria-label="' . esc_attr( sprintf( __( 'Rating: %s out of 5', 'woocommerce' ), $rating ) ) . '">' . wc_get_star_rating_html( $rating, $count ) . '</div>' : '';
return apply_filters( 'woocommerce_product_get_rating_html', $html, $rating, $count );
}