attribution-details.php
5 months ago
customer-history.php
2 months ago
customer-review-order-empty.php
1 month ago
customer-review-order-row.php
1 month ago
customer-review-order.php
1 month ago
form-tracking.php
2 years ago
order-again.php
2 years ago
order-details-customer.php
2 years ago
order-details-fulfillment-item.php
3 months ago
order-details-fulfillments.php
3 months ago
order-details-item.php
2 years ago
order-details.php
1 month ago
order-downloads.php
2 years ago
star-rating.php
1 month ago
tracking.php
4 months ago
star-rating.php
78 lines
| 1 | <?php |
| 2 | /** |
| 3 | * Star-rating control partial. |
| 4 | * |
| 5 | * Theme-overridable. Copy to `yourtheme/woocommerce/order/star-rating.php`. |
| 6 | * |
| 7 | * @see https://woocommerce.com/document/template-structure/ |
| 8 | * @package WooCommerce\Templates |
| 9 | * @version 10.8.0 |
| 10 | * |
| 11 | * @var string $name Form field name (e.g. `reviews[123][rating]`). |
| 12 | * @var string $id_prefix Prefix used for unique radio ids. |
| 13 | * @var string $label_id Existing label id; bound via aria-labelledby. |
| 14 | * @var int $selected Pre-selected value (0 = none). |
| 15 | * @var array<int, string> $labels Map of value (1-5) to caption text. |
| 16 | */ |
| 17 | |
| 18 | defined( 'ABSPATH' ) || exit; |
| 19 | |
| 20 | $caption_id = $id_prefix . '-caption'; |
| 21 | $initial_caption = $selected > 0 && isset( $labels[ $selected ] ) ? $labels[ $selected ] : ''; |
| 22 | |
| 23 | // Reverse so row-reverse + `~` selectors can fill stars 1..N without `:has()`. |
| 24 | $reversed = array_reverse( $labels, true ); |
| 25 | ?> |
| 26 | <div |
| 27 | class="woocommerce-star-rating" |
| 28 | role="radiogroup" |
| 29 | aria-labelledby="<?php echo esc_attr( $label_id ); ?>" |
| 30 | aria-describedby="<?php echo esc_attr( $caption_id ); ?>" |
| 31 | > |
| 32 | <div class="woocommerce-star-rating__stars"> |
| 33 | <?php foreach ( $reversed as $value => $label ) : ?> |
| 34 | <?php |
| 35 | $input_id = $id_prefix . '-' . $value; |
| 36 | $checked = $value === $selected; |
| 37 | ?> |
| 38 | <input |
| 39 | class="woocommerce-star-rating__input" |
| 40 | type="radio" |
| 41 | id="<?php echo esc_attr( $input_id ); ?>" |
| 42 | name="<?php echo esc_attr( $name ); ?>" |
| 43 | value="<?php echo esc_attr( (string) $value ); ?>" |
| 44 | data-label="<?php echo esc_attr( $label ); ?>" |
| 45 | <?php checked( $checked ); ?> |
| 46 | /> |
| 47 | <label class="woocommerce-star-rating__star" for="<?php echo esc_attr( $input_id ); ?>"> |
| 48 | <span class="screen-reader-text"> |
| 49 | <?php |
| 50 | printf( |
| 51 | /* translators: 1: numeric star rating 2: label text e.g. "Good" */ |
| 52 | esc_html__( '%1$d out of 5 stars: %2$s', 'woocommerce' ), |
| 53 | (int) $value, |
| 54 | esc_html( $label ) |
| 55 | ); |
| 56 | ?> |
| 57 | </span> |
| 58 | <svg |
| 59 | class="woocommerce-star-rating__icon" |
| 60 | width="24" |
| 61 | height="24" |
| 62 | viewBox="0 0 24 24" |
| 63 | aria-hidden="true" |
| 64 | focusable="false" |
| 65 | > |
| 66 | <path d="M12 2.5l2.92 6.36 6.99.74-5.21 4.74 1.46 6.86L12 17.77l-6.16 3.43 1.46-6.86L2.09 9.6l6.99-.74L12 2.5z" /> |
| 67 | </svg> |
| 68 | </label> |
| 69 | <?php endforeach; ?> |
| 70 | </div> |
| 71 | |
| 72 | <span |
| 73 | id="<?php echo esc_attr( $caption_id ); ?>" |
| 74 | class="woocommerce-star-rating__caption" |
| 75 | aria-live="polite" |
| 76 | ><?php echo esc_html( $initial_caption ); ?></span> |
| 77 | </div> |
| 78 |