extras
3 weeks ago
rating-extras
3 weeks ago
rating.php
3 weeks ago
text-aliexpress.php
3 weeks ago
text-booking.php
3 weeks ago
text.php
3 weeks ago
rating.php
50 lines
| 1 | <?php |
| 2 | |
| 3 | /** |
| 4 | * Smash Balloon Reviews Feed Rating Template |
| 5 | * Adds a star rating, plus a per-provider rating-replacement slot when |
| 6 | * the provider's design substitutes stars with a different element |
| 7 | * (Booking score badge, Facebook recommendation chip, etc.). The legacy |
| 8 | * star block is kept in DOM for backwards compatibility — providers that |
| 9 | * substitute it hide `.sb-item-rating-ctn` via CSS scoped to their |
| 10 | * `.sbr-provider-<name>` wrapper class (see assets/css/sbr-styles.css). |
| 11 | * |
| 12 | * @version 1.0 Reviews Feed by Smash Balloon |
| 13 | * |
| 14 | */ |
| 15 | |
| 16 | if (!defined('ABSPATH')) { |
| 17 | exit; // Exit if accessed directly |
| 18 | } |
| 19 | |
| 20 | $provider_name = $post['provider']['name'] ?? ''; |
| 21 | ?> |
| 22 | <div class="sb-item-rating sb-fs"> |
| 23 | <span class="sb-relative"> |
| 24 | <div class='sb-item-rating-ctn'> |
| 25 | <?php |
| 26 | // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped -- Method returns safe SVG HTML |
| 27 | echo $this->star_rating_display($post, $settings); |
| 28 | ?> |
| 29 | </div> |
| 30 | </span> |
| 31 | <?php |
| 32 | // SMASH-782 Phase 2 — per-provider rating-slot inject. Booking renders |
| 33 | // a score badge (e.g. "8.7 Very Good") that REPLACES the stars per the |
| 34 | // prototype design. The legacy `.sb-item-rating-ctn` above stays in |
| 35 | // DOM but is hidden by provider-scoped CSS. Other providers that need |
| 36 | // the same treatment in the future drop a file here following the |
| 37 | // `rating-extras/<provider>.php` convention. |
| 38 | // Whitelist the provider slug (same rationale as item.php — keep raw |
| 39 | // `$post['provider']['name']` away from path interpolation). |
| 40 | if ($provider_name !== '' && preg_match('/^[a-z][a-z0-9_-]*$/', $provider_name)) { |
| 41 | $rating_extras_path = trailingslashit(SBR_PLUGIN_DIR) |
| 42 | . 'templates/frontend/post-elements/rating-extras/' |
| 43 | . $provider_name . '.php'; |
| 44 | if (file_exists($rating_extras_path)) { |
| 45 | include $rating_extras_path; |
| 46 | } |
| 47 | } |
| 48 | ?> |
| 49 | </div> |
| 50 |