block.json
6 months ago
controller.php
6 months ago
index.asset.php
4 months ago
index.js
4 months ago
style-index-rtl.css
4 months ago
style-index.css
4 months ago
view.php
6 months ago
view.php
37 lines
| 1 | <div <?php echo wp_kses_data( get_block_wrapper_attributes( [ 'style' => $style ] ) ); ?> role="list" aria-label="<?php esc_attr_e( 'Review breakdown by star rating', 'surecart' ); ?>"> |
| 2 | <div class="sc-star-bars sc-star-bars__columns-<?php echo esc_attr( $columns ); ?>"> |
| 3 | <?php for ( $star = 5; $star >= 1; $star-- ) : ?> |
| 4 | <?php |
| 5 | // get the count of the stars for the current star rating. |
| 6 | $count = isset( $product->reviews_breakdown->$star ) ? (int) $product->reviews_breakdown->$star : 0; |
| 7 | // get the percentage of the count out of the total reviews. |
| 8 | $percentage = $total > 0 ? ( $count / $total ) * 100 : 0; |
| 9 | ?> |
| 10 | <div class="sc-star-row" role="listitem" aria-label="<?php echo esc_attr( sprintf( _n( '%1$d star: %2$d review', '%1$d stars: %2$d reviews', $star, 'surecart' ), $star, $count ) ); ?>"> |
| 11 | <span class="sc-star-text" aria-hidden="true"><?php echo (int) $star; ?></span> |
| 12 | |
| 13 | <?php |
| 14 | echo wp_kses( |
| 15 | SureCart::svg()->get( |
| 16 | 'star', |
| 17 | [ |
| 18 | 'class' => 'sc-star-icon', |
| 19 | 'fill' => 'var(--sc-star-fill-color)', |
| 20 | 'stroke' => 'var(--sc-star-fill-color)', |
| 21 | 'aria-hidden' => 'true', |
| 22 | ] |
| 23 | ), |
| 24 | sc_allowed_svg_html() |
| 25 | ); |
| 26 | ?> |
| 27 | |
| 28 | <div class="sc-star-row__bar" role="progressbar" aria-valuenow="<?php echo esc_attr( round( $percentage ) ); ?>" aria-valuemin="0" aria-valuemax="100" aria-label="<?php echo esc_attr( sprintf( __( '%d%% of reviews', 'surecart' ), round( $percentage ) ) ); ?>"> |
| 29 | <div class="sc-star-row__bar-fill" style="width: <?php echo esc_attr( $percentage ); ?>%;"></div> |
| 30 | </div> |
| 31 | |
| 32 | <div class="sc-star-row__count" aria-hidden="true"><?php echo esc_html( $count ); ?></div> |
| 33 | </div> |
| 34 | <?php endfor; ?> |
| 35 | </div> |
| 36 | </div> |
| 37 |