PluginProbe
Yatra – Travel Booking & Tour Operator Software / 3.0.4
Yatra – Travel Booking & Tour Operator Software v3.0.4
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 2.0.10 All 83 releases
yatra / templates / shortcodes / destination.php

destination.php in Yatra – Travel Booking & Tour Operator Software 3.0.4, at templates/shortcodes/destination.php

170 lines 9.3 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * Destination Shortcode Template
4 *
5 * @package Yatra
6 * @var array $destinations Array of destination data with trips
7 * @var array $atts Shortcode attributes
8 */
9
10 // Prevent direct access
11 if (!defined('ABSPATH')) {
12 exit;
13 }
14
15 $columns = (int) $atts['columns'];
16 $column_class = 'yatra-destination-grid-' . min(max($columns, 1), 6);
17 ?>
18
19 <div class="yatra-destination-shortcode" data-atts='<?php echo esc_attr(json_encode($atts)); ?>'>
20 <div class="yatra-destination-header">
21 <?php if (!empty($atts['title'])): ?>
22 <h2 class="yatra-destination-title"><?php echo esc_html($atts['title']); ?></h2>
23 <?php else: ?>
24 <h2 class="yatra-destination-title"><?php esc_html_e('Destination Showcase', 'yatra'); ?></h2>
25 <?php endif; ?>
26 <?php if (!empty($destinations)): ?>
27 <div class="yatra-destination-count">
28 <?php
29 printf(
30 esc_html__('Showing %d of %d destinations', 'yatra'),
31 esc_html(count($destinations)),
32 esc_html($total_found)
33 );
34 ?>
35 </div>
36 <?php endif; ?>
37 </div>
38
39 <?php if (!empty($destinations)): ?>
40 <div class="yatra-destination-grid <?php echo esc_attr($column_class); ?>">
41 <?php foreach ($destinations as $destination): ?>
42 <div class="yatra-category-card">
43 <div class="yatra-category-card-image-wrapper">
44 <?php if (!empty($destination['image'])): ?>
45 <a href="<?php echo esc_url($destination['link']); ?>">
46 <img src="<?php echo esc_url($destination['image']); ?>" alt="<?php echo esc_attr($destination['term']->name); ?>" class="yatra-category-card-image">
47 </a>
48 <?php else: ?>
49 <a href="<?php echo esc_url($destination['link']); ?>">
50 <img src="<?php echo YATRA_PLUGIN_URL; ?>assets/images/placeholder.png" alt="<?php echo esc_attr($destination['term']->name); ?>" class="yatra-category-card-image">
51 </a>
52 <?php endif; ?>
53
54 <!-- Overlay Content on Image -->
55 <div class="yatra-category-card-overlay">
56 <div class="yatra-category-card-content">
57 <h3 class="yatra-category-card-title">
58 <a href="<?php echo esc_url($destination['link']); ?>" class="yatra-category-card-title-link"><?php echo esc_html($destination['term']->name); ?></a>
59 </h3>
60
61 <div class="yatra-category-card-stats">
62 <!-- Rating -->
63 <div class="category-stat rating">
64 <span class="category-stat-icon">
65 <svg width="16" height="16" fill="currentColor" viewBox="0 0 20 20">
66 <path d="M9.049 2.927c.3-.921 1.603-.921 1.902 0l1.07 3.292a1 1 0 00.95.69h3.462c.969 0 1.371 1.24.588 1.81l-2.8 2.034a1 1 0 00-.364 1.118l1.07 3.292c.3.921-.755 1.688-1.54 1.118l-2.8-2.034a1 1 0 00-1.175 0l-2.8 2.034c-.784.57-1.838-.197-1.539-1.118l1.07-3.292a1 1 0 00-.364-1.118L2.98 8.72c-.783-.57-.38-1.81.588-1.81h3.461a1 1 0 00.951-.69l1.07-3.292z" />
67 </svg>
68 </span>
69 <span class="category-stat-value"><?php echo esc_html(number_format(!empty($destination['avg_rating']) ? $destination['avg_rating'] : 0, 1)); ?></span>
70 </div>
71
72 <!-- Trip Count -->
73 <div class="category-stat trips">
74 <span class="category-stat-icon">
75 <svg width="16" height="16" fill="currentColor" viewBox="0 0 24 24">
76 <path d="M12 2C8.13 2 5 5.13 5 9c0 5.25 7 13 7 13s7-7.75 7-13c0-3.87-3.13-7-7-7zm0 9.5c-1.38 0-2.5-1.12-2.5-2.5s1.12-2.5 2.5-2.5 2.5 1.12 2.5 2.5-1.12 2.5-2.5 2.5z"/>
77 </svg>
78 </span>
79 <span class="category-stat-value">
80 <?php
81 $trip_count = !empty($destination['trip_count']) ? $destination['trip_count'] : 0;
82 echo esc_html($trip_count) . ' ' . _n('Trip', 'Trips', $trip_count, 'yatra');
83 ?>
84 </span>
85 </div>
86
87 <!-- Price (if available) -->
88 <?php if (!empty($destination['min_price'])): ?>
89 <div class="category-stat price">
90 <span class="category-stat-icon">$</span>
91 <span class="category-stat-value">
92 <?php esc_html_e('From', 'yatra'); ?> <?php echo esc_html(yatra_get_currency_symbol(get_option('yatra_currency', 'USD')) . number_format($destination['min_price'], 2)); ?>
93 </span>
94 </div>
95 <?php endif; ?>
96 </div>
97 </div>
98 </div>
99
100 <!-- Featured Badge -->
101 <?php if (isset($destination['term']->featured) && $destination['term']->featured == 1): ?>
102 <div class="yatra-category-featured-badge">
103 <?php esc_html_e('Featured', 'yatra'); ?>
104 </div>
105 <?php endif; ?>
106 </div>
107 </div>
108 <?php endforeach; ?>
109 </div>
110 <?php elseif ($total_found > 0): ?>
111 <!-- No destinations on this page, but destinations exist on other pages -->
112 <div class="yatra-destination-empty-page">
113 <p><?php esc_html_e('No destinations found on this page. Try navigating to other pages.', 'yatra'); ?></p>
114 </div>
115 <?php else: ?>
116 <!-- No destinations found at all -->
117 <div class="yatra-destination-empty">
118 <div class="yatra-empty-icon">
119 <?php echo yatra_svg_icon('map', 'yatra-empty-icon-svg'); ?>
120 </div>
121 <h3><?php esc_html_e('No Destinations Found', 'yatra'); ?></h3>
122 <p><?php esc_html_e('We couldn\'t find any destinations. Please check back later or browse our trips directly.', 'yatra'); ?></p>
123 <a href="<?php echo esc_url(get_post_type_archive_link('trip')); ?>" class="yatra-btn yatra-btn-primary yatra-archive-card-cta">
124 <?php echo yatra_svg_icon('globe', 'yatra-btn-icon'); ?>
125 <span><?php esc_html_e('Browse All Trips', 'yatra'); ?></span>
126 </a>
127 </div>
128 <?php endif; ?>
129
130 <?php if ($atts['show_pagination'] === 'yes' && isset($max_pages) && $max_pages > 1): ?>
131 <div class="yatra-destination-pagination">
132 <?php
133 $current_url = remove_query_arg('destination_page', $_SERVER['REQUEST_URI']);
134 $current_url = preg_replace('/&destination_page=[^&]*/', '', $current_url);
135
136 // Previous page
137 if ($current_page > 1):
138 $prev_url = add_query_arg('destination_page', $current_page - 1, $current_url);
139 ?>
140 <a href="#" class="yatra-pagination-link yatra-pagination-prev" data-page="<?php echo esc_attr($current_page - 1); ?>">
141 <?php echo yatra_svg_icon('chevron-left', ''); ?>
142 <?php esc_html_e('Previous', 'yatra'); ?>
143 </a>
144 <?php endif; ?>
145
146 <?php
147 // Show all page numbers - no ellipsis
148 for ($i = 1; $i <= $max_pages; $i++):
149 $is_current = $i === $current_page;
150 ?>
151 <a href="#" class="yatra-pagination-link <?php echo $is_current ? 'yatra-pagination-current' : ''; ?>" data-page="<?php echo esc_attr($i); ?>">
152 <?php echo esc_html($i); ?>
153 </a>
154 <?php endfor; ?>
155
156 <?php
157 // Next page
158 if ($current_page < $max_pages):
159 $next_url = add_query_arg('destination_page', $current_page + 1, $current_url);
160 ?>
161 <a href="#" class="yatra-pagination-link yatra-pagination-next" data-page="<?php echo esc_attr($current_page + 1); ?>">
162 <?php esc_html_e('Next', 'yatra'); ?>
163 <?php echo yatra_svg_icon('chevron-right', ''); ?>
164 </a>
165 <?php endif; ?>
166 </div>
167 <?php endif; ?>
168 </div>
169
170