PluginProbe
Yatra – Travel Booking & Tour Operator Software / 3.0.17
Yatra – Travel Booking & Tour Operator Software v3.0.17
3.0.17 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 All 85 releases
← All changes | templates/partials/single-trip/hero.php +86 -40 3.0.2.6 → 3.0.17 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,11 +157,11 @@
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 - <?php echo esc_html__('SAVE', 'yatra'); ?> <?php echo esc_html($trip->discount_percentage); ?>%
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()); ?>">
141 166 </div>
142 167 <?php endif; ?>
@@ -187,12 +212,18 @@
187 212 </div>
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 - <img src="<?php echo esc_url($main_image_url); ?>"
192 - alt="<?php echo esc_attr(sprintf(__('Main image for %s', 'yatra'), $trip->getTitle())); ?>"
216 + <img src="<?php echo esc_url($main_image_url); ?>"
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); ?>"
224 + data-yatra-src="<?php echo esc_url($main_image_url); ?>"
225 + data-no-lazy="1"
195 226 class="yatra-hero-main-img">
196 227 </a>
197 228 <meta itemprop="contentUrl" content="<?php echo esc_url($main_image_url); ?>">
198 229 <meta itemprop="encodingFormat" content="image/jpeg">
@@ -199,9 +230,13 @@
199 230 <meta itemprop="width" content="1200">
200 231 <meta itemprop="height" content="630">
201 232 <?php else: ?>
202 233 <img src="<?php echo esc_url(plugins_url('assets/images/trip-placeholder.svg', YATRA_PLUGIN_FILE)); ?>"
203 - 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 + )); ?>"
204 239 title="<?php echo esc_attr($trip->getTitle()); ?>"
205 240 itemprop="url" content="<?php echo esc_url(plugins_url('assets/images/trip-placeholder.svg', YATRA_PLUGIN_FILE)); ?>"
206 241 class="yatra-hero-main-img">
207 242 <meta itemprop="contentUrl" content="<?php echo esc_url(plugins_url('assets/images/trip-placeholder.svg', YATRA_PLUGIN_FILE)); ?>">
@@ -211,32 +246,32 @@
211 246 <!-- Quick Media Switcher -->
212 247 <div class="yatra-hero-media-switcher">
213 248 <button type="button" class="yatra-media-switcher-btn yatra-media-switcher-active" data-media="images">
214 249 <?php echo yatra_svg_icon('camera', 'yatra-media-switcher-icon'); ?>
215 - <span>Images</span>
250 + <span><?php echo esc_html__('Images', 'yatra'); ?></span>
216 251 </button>
217 252 <?php if ($video_count > 0): ?>
218 253 <button type="button" class="yatra-media-switcher-btn" data-media="videos">
219 254 <?php echo yatra_svg_icon('play', 'yatra-media-switcher-icon'); ?>
220 - <span>Videos</span>
255 + <span><?php echo esc_html__('Videos', 'yatra'); ?></span>
221 256 </button>
222 257 <?php endif; ?>
223 258 <?php if ($youtube_count > 0): ?>
224 259 <button type="button" class="yatra-media-switcher-btn" data-media="youtube">
225 260 <?php echo yatra_svg_icon('video', 'yatra-media-switcher-icon'); ?>
226 - <span>Video</span>
261 + <span><?php echo esc_html__('Video', 'yatra'); ?></span>
227 262 </button>
228 263 <?php endif; ?>
229 264 <?php if ($tour_count > 0): ?>
230 265 <button type="button" class="yatra-media-switcher-btn" data-media="tours">
231 266 <?php echo yatra_svg_icon('globe', 'yatra-media-switcher-icon'); ?>
232 - <span>360°</span>
267 + <span><?php echo esc_html__('360°', 'yatra'); ?></span>
233 268 </button>
234 269 <?php endif; ?>
235 270 <?php if ($doc_count > 0): ?>
236 271 <button type="button" class="yatra-media-switcher-btn" data-media="documents">
237 272 <?php echo yatra_svg_icon('file-text', 'yatra-media-switcher-icon'); ?>
238 - <span>Documents</span>
273 + <span><?php echo esc_html__('Documents', 'yatra'); ?></span>
239 274 </button>
240 275 <?php endif; ?>
241 276 </div>
242 277
@@ -250,19 +285,21 @@
250 285 'documents' => $trip->documents ?? []
251 286 ]); ?>
252 287 </script>
253 288
254 - <!-- Book Now Button on Right Side of Main Image -->
255 - <div class="yatra-hero-book-now-container">
256 - <a href="#yatra-booking-widget" class="yatra-hero-book-now-btn">
257 - <svg width="18" height="18" fill="none" stroke="currentColor" viewBox="0 0 24 24">
258 - <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2"
259 - 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"/>
260 - </svg>
261 - <?php echo esc_html__('Book Now', 'yatra'); ?>
262 - - <?php echo esc_html(yatra_format_price($base_price)); ?>
263 - </a>
264 - </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; ?>
265 302 </div>
266 303 <div class="yatra-hero-side-images">
267 304 <?php if (!empty($side_images)): ?>
268 305 <?php foreach ($side_images as $index => $img_url): ?>
@@ -267,14 +304,19 @@
267 304 <?php if (!empty($side_images)): ?>
268 305 <?php foreach ($side_images as $index => $img_url): ?>
269 306 <div class="yatra-side-image-item">
270 307 <img src="<?php echo esc_url($img_url); ?>"
271 - alt="<?php echo esc_attr__('Gallery Image', 'yatra'); ?>">
308 + alt="<?php echo esc_attr__('Gallery Image', 'yatra'); ?>"
309 + data-yatra-src="<?php echo esc_url($img_url); ?>"
310 + data-no-lazy="1">
272 311 <?php if ($index === 0 && function_exists('yatra_wishlist_enabled') && yatra_wishlist_enabled() && !empty($trip->id)) : ?>
273 312 <button type="button" class="yatra-favorite-btn"
274 313 data-trip-id="<?php echo esc_attr((string) $trip->id); ?>"
314 + title="<?php esc_attr_e('Save to wishlist', 'yatra'); ?>"
275 315 aria-label="<?php echo esc_attr__('Save to wishlist', 'yatra'); ?>">
276 - <?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>
277 319 </button>
278 320 <?php endif; ?>
279 321 <?php if ($index === count($side_images) - 1 && $total_images > 4): ?>
280 322 <button type="button" class="yatra-view-all-photos-btn yatra-gallery-play-btn"
@@ -279,9 +321,13 @@
279 321 <?php if ($index === count($side_images) - 1 && $total_images > 4): ?>
280 322 <button type="button" class="yatra-view-all-photos-btn yatra-gallery-play-btn"
281 323 data-gallery="hero-gallery">
282 324 <?php echo yatra_svg_icon('camera', 'yatra-icon-sm'); ?>
283 - <?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 + ); ?>
284 330 </button>
285 331 <?php endif; ?>
286 332 </div>
287 333 <?php endforeach; ?>