Actaully using esc_html
won’t help because it will escape any html character, so you have to depend on wp_kses
so you can specify the accepted tags and there attributes, so no need then to escape the output. but you have to escape the values comming from DB, which in you case $average_rating
. so your can be like this.
$accepted_tags = array('strong'=>array());
$reviews_label = wp_kses(
sprintf(
__( '%s / %d', '<strong>woocommerce-product-reviews-pro</strong>' ),
esc_html($average_rating),
5
),
$accepted_tags );
<h3><?php echo $reviews_label ; ?></h3>
Update
As i can see from your comment, You need to add tag to the %s
, so you need to just change the $accepted_tags
to:
$accepted_tags = array('span'=>array());
anf the sprintf
to:
sprintf(
__( '<span>%s</span> / %d', 'woocommerce-product-reviews-pro' ),
esc_html($average_rating),
5
),