PluginProbe
Yatra – Travel Booking & Tour Operator Software / 3.0.16
Yatra – Travel Booking & Tour Operator Software v3.0.16
3.0.16 3.0.15 3.0.14 3.0.14.1 3.0.14.2 3.0.12 3.0.13 3.0.11 3.0.10 3.0.9 3.0.8 3.0.7 3.0.6 3.0.5 3.0.5.1 3.0.4 3.0.3 3.0.2.9 3.0.2.7 3.0.2.8 3.0.2.6 trunk 1.0.0 2.0.0 2.0.1 All 84 releases
← All changes | templates/partials/single-trip/hero.php +79 -37 3.0.2.8 → 3.0.16 View file →
@@ -1,12 +1,16 @@
1 1 <?php
2 2 if (!defined('ABSPATH')) {
3 3 exit;
4 4 }
5 +$booking_disabled = isset($trip) && method_exists($trip, 'isBookingDisabled') && $trip->isBookingDisabled();
6 +$yatra_hero_dp_flags = function_exists('yatra_get_dynamic_pricing_display_flags') ? yatra_get_dynamic_pricing_display_flags() : [
7 + 'show_savings_badge' => true,
8 +];
5 9 ?>
6 10 <div class="yatra-trip-hero-new" itemscope itemtype="https://schema.org/TouristTrip">
7 11 <div class="yatra-hero-header">
8 - <nav class="yatra-hero-breadcrumb" aria-label="Breadcrumb" itemscope itemtype="https://schema.org/BreadcrumbList">
12 + <nav class="yatra-hero-breadcrumb" aria-label="<?php echo esc_attr__('Breadcrumb', 'yatra'); ?>" itemscope itemtype="https://schema.org/BreadcrumbList">
9 13 <span itemprop="itemListElement" itemscope itemtype="https://schema.org/ListItem">
10 14 <a href="<?php echo esc_url(home_url('/')); ?>" itemprop="item">
11 15 <span itemprop="name"><?php echo esc_html__('Home', 'yatra'); ?></span>
12 16 </a>
@@ -26,14 +30,18 @@
26 30 </span>
27 31 </nav>
28 32 <h1 class="yatra-trip-hero-title-new" itemprop="name"><?php echo esc_html($trip->getTitle()); ?></h1>
29 33 <div class="yatra-hero-meta">
30 - <div class="yatra-hero-rating" itemprop="aggregateRating" itemscope itemtype="https://schema.org/AggregateRating">
34 + <?php // Rating is expressed via JSON-LD (Product.aggregateRating) in SEOService — no microdata here, which Google rejected on a TouristTrip parent. ?>
35 + <div class="yatra-hero-rating">
31 36 <?php if ($trip->getAverageRating() > 0 || $trip->getReviewCount() > 0): ?>
32 37 <?php
38 + // Shared helper, so the hero, the reviews block below it and the
39 + // booking confirmation all draw the same rating identically.
33 40 $hero_avg = (float) $trip->getAverageRating();
34 - $hero_full = (int) floor($hero_avg);
35 - $hero_half = ($hero_avg - $hero_full) >= 0.3;
41 + $hero_parts = yatra_rating_star_parts($hero_avg);
42 + $hero_full = $hero_parts['full'];
43 + $hero_half = $hero_parts['half'];
36 44 ?>
37 45 <div class="yatra-rating-stars">
38 46 <?php for ($i = 1; $i <= 5; $i++) : ?>
39 47 <?php
@@ -44,26 +52,31 @@
44 52 } else {
45 53 $hero_star_class = 'yatra-star';
46 54 }
47 55 ?>
48 - <span class="<?php echo esc_attr($hero_star_class); ?>" aria-label="<?php echo esc_attr(sprintf(_n('%d star', '%d stars', $i, 'yatra'), $i)); ?>">★</span>
56 + <span class="<?php echo esc_attr($hero_star_class); ?>" aria-label="<?php echo esc_attr(sprintf(
57 + /* translators: %d: star rating number (1-5). */
58 + _n('%d star', '%d stars', $i, 'yatra'),
59 + $i
60 + )); ?>">★</span>
49 61 <?php endfor; ?>
50 62 </div>
51 - <span class="yatra-rating-number" itemprop="ratingValue"><?php echo esc_html(number_format($trip->getAverageRating(), 1)); ?></span>
63 + <span class="yatra-rating-number"><?php echo esc_html(number_format($trip->getAverageRating(), 1)); ?></span>
52 64 <span class="yatra-rating-text">
53 - <span itemprop="reviewCount"><?php echo esc_html($trip->getReviewCount()); ?></span>
65 + <span><?php echo esc_html($trip->getReviewCount()); ?></span>
54 66 <?php echo esc_html(_n('Review', 'Reviews', $trip->getReviewCount(), 'yatra')); ?>
55 67 </span>
56 - <meta itemprop="bestRating" content="5">
57 - <meta itemprop="worstRating" content="1">
58 68 <?php else: ?>
59 69 <div class="yatra-rating-stars yatra-no-rating">
60 70 <?php for ($i = 1; $i <= 5; $i++): ?>
61 - <span class="yatra-star" aria-label="<?php echo esc_attr(sprintf(_n('%d star', '%d stars', $i, 'yatra'), $i)); ?>">★</span>
71 + <span class="yatra-star" aria-label="<?php echo esc_attr(sprintf(
72 + /* translators: %d: star rating number (1-5). */
73 + _n('%d star', '%d stars', $i, 'yatra'),
74 + $i
75 + )); ?>">★</span>
62 76 <?php endfor; ?>
63 77 </div>
64 78 <span class="yatra-rating-text yatra-no-reviews"><?php echo esc_html__('No reviews yet', 'yatra'); ?></span>
65 - <meta itemprop="reviewCount" content="0">
66 79 <?php endif; ?>
67 80 </div>
68 81 <?php if (!empty($trip->getStartingLocation())): ?>
69 82 <div class="yatra-hero-location" itemprop="location" itemscope itemtype="https://schema.org/Place">
@@ -70,17 +83,29 @@
70 83 <?php echo yatra_svg_icon('map-pin', 'yatra-icon-sm'); ?>
71 84 <span itemprop="name"><?php echo esc_html($trip->getStartingLocation()); ?></span>
72 85 </div>
73 86 <?php endif; ?>
74 - <?php if (!empty($trip->getDurationDays())): ?>
87 + <?php if (!empty($trip->getDurationDays()) || $trip->getDurationHours() > 0): ?>
75 88 <div class="yatra-hero-duration" itemprop="duration">
76 89 <?php echo yatra_svg_icon('clock', 'yatra-icon-sm'); ?>
77 90 <span>
78 - <?php
79 - if (!empty($trip->getDurationNights()) && $trip->getDurationNights() > 0) {
80 - echo esc_html(sprintf(_n('%d day %d night', '%d days %d nights', $trip->getDurationDays(), 'yatra'), $trip->getDurationDays(), $trip->getDurationNights()));
91 + <?php
92 + if ($trip->getDurationHours() > 0) {
93 + // Hour-based day tour: "8 hours", not "1 day" (matches quick-facts).
94 + echo esc_html(yatra_format_duration(0, null, $trip->getDurationHours()));
95 + } elseif (!empty($trip->getDurationNights()) && $trip->getDurationNights() > 0) {
96 + echo esc_html(sprintf(
97 + /* translators: 1: number of days, 2: number of nights. */
98 + _n('%1$d day %2$d night', '%1$d days %2$d nights', $trip->getDurationDays(), 'yatra'),
99 + $trip->getDurationDays(),
100 + $trip->getDurationNights()
101 + ));
81 102 } else {
82 - echo esc_html(sprintf(_n('%d day', '%d days', $trip->getDurationDays(), 'yatra'), $trip->getDurationDays()));
103 + echo esc_html(sprintf(
104 + /* translators: %d: number of days. */
105 + _n('%d day', '%d days', $trip->getDurationDays(), 'yatra'),
106 + $trip->getDurationDays()
107 + ));
83 108 }
84 109 ?>
85 110 </span>
86 111 </div>
@@ -132,9 +157,9 @@
132 157 $total_images = count($all_gallery_images);
133 158 ?>
134 159 <div class="yatra-hero-images">
135 160 <div class="yatra-hero-main-image" itemprop="image" itemscope itemtype="https://schema.org/ImageObject">
136 - <?php if (isset($trip->discount_percentage) && $trip->discount_percentage > 0): ?>
161 + <?php if (isset($trip->discount_percentage) && $trip->discount_percentage > 0 && !empty($yatra_hero_dp_flags['show_savings_badge'])): ?>
137 162 <div class="yatra-hero-discount-tag" itemprop="offers" itemscope itemtype="https://schema.org/Offer">
138 163 <?php echo esc_html__('SAVE UP TO', 'yatra'); ?> <?php echo esc_html($trip->discount_percentage); ?>%
139 164 <meta itemprop="discount" content="<?php echo esc_attr($trip->discount_percentage); ?>">
140 165 <meta itemprop="discountCurrency" content="<?php echo esc_attr(\Yatra\Services\SettingsService::getCurrency()); ?>">
@@ -188,9 +213,13 @@
188 213
189 214 <?php if (!empty($main_image_url)): ?>
190 215 <a href="#" class="yatra-hero-main-img-link" data-gallery="hero-gallery" data-image-index="0">
191 216 <img src="<?php echo esc_url($main_image_url); ?>"
192 - alt="<?php echo esc_attr(sprintf(__('Main image for %s', 'yatra'), $trip->getTitle())); ?>"
217 + alt="<?php echo esc_attr(sprintf(
218 + /* translators: %s: trip title. */
219 + __('Main image for %s', 'yatra'),
220 + $trip->getTitle()
221 + )); ?>"
193 222 title="<?php echo esc_attr($trip->getTitle()); ?>"
194 223 itemprop="url" content="<?php echo esc_url($main_image_url); ?>"
195 224 data-yatra-src="<?php echo esc_url($main_image_url); ?>"
196 225 data-no-lazy="1"
@@ -201,9 +230,13 @@
201 230 <meta itemprop="width" content="1200">
202 231 <meta itemprop="height" content="630">
203 232 <?php else: ?>
204 233 <img src="<?php echo esc_url(plugins_url('assets/images/trip-placeholder.svg', YATRA_PLUGIN_FILE)); ?>"
205 - alt="<?php echo esc_attr(sprintf(__('Placeholder image for %s', 'yatra'), $trip->getTitle())); ?>"
234 + alt="<?php echo esc_attr(sprintf(
235 + /* translators: %s: trip title. */
236 + __('Placeholder image for %s', 'yatra'),
237 + $trip->getTitle()
238 + )); ?>"
206 239 title="<?php echo esc_attr($trip->getTitle()); ?>"
207 240 itemprop="url" content="<?php echo esc_url(plugins_url('assets/images/trip-placeholder.svg', YATRA_PLUGIN_FILE)); ?>"
208 241 class="yatra-hero-main-img">
209 242 <meta itemprop="contentUrl" content="<?php echo esc_url(plugins_url('assets/images/trip-placeholder.svg', YATRA_PLUGIN_FILE)); ?>">
@@ -213,32 +246,32 @@
213 246 <!-- Quick Media Switcher -->
214 247 <div class="yatra-hero-media-switcher">
215 248 <button type="button" class="yatra-media-switcher-btn yatra-media-switcher-active" data-media="images">
216 249 <?php echo yatra_svg_icon('camera', 'yatra-media-switcher-icon'); ?>
217 - <span>Images</span>
250 + <span><?php echo esc_html__('Images', 'yatra'); ?></span>
218 251 </button>
219 252 <?php if ($video_count > 0): ?>
220 253 <button type="button" class="yatra-media-switcher-btn" data-media="videos">
221 254 <?php echo yatra_svg_icon('play', 'yatra-media-switcher-icon'); ?>
222 - <span>Videos</span>
255 + <span><?php echo esc_html__('Videos', 'yatra'); ?></span>
223 256 </button>
224 257 <?php endif; ?>
225 258 <?php if ($youtube_count > 0): ?>
226 259 <button type="button" class="yatra-media-switcher-btn" data-media="youtube">
227 260 <?php echo yatra_svg_icon('video', 'yatra-media-switcher-icon'); ?>
228 - <span>Video</span>
261 + <span><?php echo esc_html__('Video', 'yatra'); ?></span>
229 262 </button>
230 263 <?php endif; ?>
231 264 <?php if ($tour_count > 0): ?>
232 265 <button type="button" class="yatra-media-switcher-btn" data-media="tours">
233 266 <?php echo yatra_svg_icon('globe', 'yatra-media-switcher-icon'); ?>
234 - <span>360°</span>
267 + <span><?php echo esc_html__('360°', 'yatra'); ?></span>
235 268 </button>
236 269 <?php endif; ?>
237 270 <?php if ($doc_count > 0): ?>
238 271 <button type="button" class="yatra-media-switcher-btn" data-media="documents">
239 272 <?php echo yatra_svg_icon('file-text', 'yatra-media-switcher-icon'); ?>
240 - <span>Documents</span>
273 + <span><?php echo esc_html__('Documents', 'yatra'); ?></span>
241 274 </button>
242 275 <?php endif; ?>
243 276 </div>
244 277
@@ -252,19 +285,21 @@
252 285 'documents' => $trip->documents ?? []
253 286 ]); ?>
254 287 </script>
255 288
256 - <!-- Book Now Button on Right Side of Main Image -->
257 - <div class="yatra-hero-book-now-container">
258 - <a href="#yatra-booking-widget" class="yatra-hero-book-now-btn">
259 - <svg width="18" height="18" fill="none" stroke="currentColor" viewBox="0 0 24 24">
260 - <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2"
261 - d="M8 7V3m8 4V3m-9 8h10M5 21h14a2 2 0 002-2V7a2 2 0 00-2-2H5a2 2 0 00-2 2v12a2 2 0 002 2z"/>
262 - </svg>
263 - <?php echo esc_html__('Book Now', 'yatra'); ?>
264 - - <?php echo esc_html(yatra_format_price($base_price)); ?>
265 - </a>
266 - </div>
289 + <?php if (!$booking_disabled): ?>
290 + <!-- Book Now Button on Right Side of Main Image -->
291 + <div class="yatra-hero-book-now-container">
292 + <a href="#booking" id="yatra-hero-book-now-btn" class="yatra-hero-book-now-btn">
293 + <svg width="18" height="18" fill="none" stroke="currentColor" viewBox="0 0 24 24" aria-hidden="true">
294 + <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2"
295 + d="M8 7V3m8 4V3m-9 8h10M5 21h14a2 2 0 002-2V7a2 2 0 00-2-2H5a2 2 0 00-2 2v12a2 2 0 002 2z"/>
296 + </svg>
297 + <?php echo esc_html__('Book Now', 'yatra'); ?>
298 + - <?php echo esc_html(yatra_format_price($base_price)); ?>
299 + </a>
300 + </div>
301 + <?php endif; ?>
267 302 </div>
268 303 <div class="yatra-hero-side-images">
269 304 <?php if (!empty($side_images)): ?>
270 305 <?php foreach ($side_images as $index => $img_url): ?>
@@ -275,10 +310,13 @@
275 310 data-no-lazy="1">
276 311 <?php if ($index === 0 && function_exists('yatra_wishlist_enabled') && yatra_wishlist_enabled() && !empty($trip->id)) : ?>
277 312 <button type="button" class="yatra-favorite-btn"
278 313 data-trip-id="<?php echo esc_attr((string) $trip->id); ?>"
314 + title="<?php esc_attr_e('Save to wishlist', 'yatra'); ?>"
279 315 aria-label="<?php echo esc_attr__('Save to wishlist', 'yatra'); ?>">
280 - <?php echo yatra_svg_icon('heart', 'yatra-icon-sm'); ?>
316 + <svg width="20" height="20" fill="none" stroke="currentColor" viewBox="0 0 24 24" aria-hidden="true">
317 + <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M4.318 6.318a4.5 4.5 0 000 6.364L12 20.364l7.682-7.682a4.5 4.5 0 00-6.364-6.364L12 7.636l-1.318-1.318a4.5 4.5 0 00-6.364 0z"/>
318 + </svg>
281 319 </button>
282 320 <?php endif; ?>
283 321 <?php if ($index === count($side_images) - 1 && $total_images > 4): ?>
284 322 <button type="button" class="yatra-view-all-photos-btn yatra-gallery-play-btn"
@@ -283,9 +321,13 @@
283 321 <?php if ($index === count($side_images) - 1 && $total_images > 4): ?>
284 322 <button type="button" class="yatra-view-all-photos-btn yatra-gallery-play-btn"
285 323 data-gallery="hero-gallery">
286 324 <?php echo yatra_svg_icon('camera', 'yatra-icon-sm'); ?>
287 - <?php echo sprintf(esc_html__('View all %d photos', 'yatra'), $total_images); ?>
325 + <?php echo sprintf(
326 + /* translators: %d: total number of photos in the trip gallery. */
327 + esc_html__('View all %d photos', 'yatra'),
328 + $total_images
329 + ); ?>
288 330 </button>
289 331 <?php endif; ?>
290 332 </div>
291 333 <?php endforeach; ?>