PluginProbe
Yatra – Travel Booking & Tour Operator Software / 3.0.15
Yatra – Travel Booking & Tour Operator Software v3.0.15
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 / trip-category.php

trip-category.php in Yatra – Travel Booking & Tour Operator Software 3.0.15, at templates/shortcodes/trip-category.php

153 lines 8.5 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * Trip category shortcode template (same card layout as destination shortcode).
4 *
5 * @package Yatra
6 * @var array $categories
7 * @var array $atts
8 */
9
10 if (!defined('ABSPATH')) {
11 exit;
12 }
13
14 $columns = (int) $atts['columns'];
15 $column_class = 'yatra-destination-grid-' . min(max($columns, 1), 6);
16 ?>
17
18 <div class="yatra-destination-shortcode yatra-trip-category-shortcode" data-atts='<?php echo esc_attr(json_encode($atts)); ?>'>
19 <div class="yatra-destination-header">
20 <?php if (!empty($atts['title'])): ?>
21 <h2 class="yatra-destination-title"><?php echo esc_html($atts['title']); ?></h2>
22 <?php else: ?>
23 <h2 class="yatra-destination-title"><?php esc_html_e('Trip Categories', 'yatra'); ?></h2>
24 <?php endif; ?>
25 <?php if (!empty($categories)): ?>
26 <div class="yatra-destination-count">
27 <?php
28 printf(
29 /* translators: 1: number of categories shown, 2: total categories available. */
30 esc_html__('Showing %1$d of %2$d categories', 'yatra'),
31 (int) count($categories),
32 (int) $total_found
33 );
34 ?>
35 </div>
36 <?php endif; ?>
37 </div>
38
39 <?php if (!empty($categories)): ?>
40 <div class="yatra-destination-grid <?php echo esc_attr($column_class); ?>">
41 <?php foreach ($categories as $category_row): ?>
42 <div class="yatra-category-card">
43 <div class="yatra-category-card-image-wrapper">
44 <?php if (!empty($category_row['image'])): ?>
45 <a href="<?php echo esc_url($category_row['link']); ?>">
46 <img src="<?php echo esc_url($category_row['image']); ?>" alt="<?php echo esc_attr($category_row['term']->name); ?>" class="yatra-category-card-image">
47 </a>
48 <?php else: ?>
49 <a href="<?php echo esc_url($category_row['link']); ?>">
50 <img src="<?php echo esc_url(YATRA_PLUGIN_URL . 'assets/images/placeholder.png'); ?>" alt="<?php echo esc_attr($category_row['term']->name); ?>" class="yatra-category-card-image">
51 </a>
52 <?php endif; ?>
53
54 <div class="yatra-category-card-overlay">
55 <div class="yatra-category-card-content">
56 <h3 class="yatra-category-card-title">
57 <a href="<?php echo esc_url($category_row['link']); ?>" class="yatra-category-card-title-link"><?php echo esc_html($category_row['term']->name); ?></a>
58 </h3>
59
60 <div class="yatra-category-card-stats">
61 <div class="category-stat rating">
62 <span class="category-stat-icon">
63 <svg width="16" height="16" fill="currentColor" viewBox="0 0 20 20">
64 <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" />
65 </svg>
66 </span>
67 <span class="category-stat-value"><?php echo esc_html(number_format(!empty($category_row['avg_rating']) ? $category_row['avg_rating'] : 0, 1)); ?></span>
68 </div>
69
70 <div class="category-stat trips">
71 <span class="category-stat-icon">
72 <svg width="16" height="16" fill="currentColor" viewBox="0 0 24 24">
73 <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"/>
74 </svg>
75 </span>
76 <span class="category-stat-value">
77 <?php
78 $trip_count = !empty($category_row['trip_count']) ? $category_row['trip_count'] : 0;
79 echo esc_html($trip_count) . ' ' . _n('Trip', 'Trips', $trip_count, 'yatra');
80 ?>
81 </span>
82 </div>
83
84 <?php if (!empty($category_row['min_price'])): ?>
85 <div class="category-stat price">
86 <span class="category-stat-icon">$</span>
87 <span class="category-stat-value">
88 <?php esc_html_e('From', 'yatra'); ?> <?php echo esc_html(yatra_format_price((float) $category_row['min_price'])); ?>
89 </span>
90 </div>
91 <?php endif; ?>
92 </div>
93 </div>
94 </div>
95
96 <?php
97 $t = $category_row['term'];
98 $is_featured = (isset($t->is_featured) && (int) $t->is_featured === 1)
99 || (isset($t->featured) && (int) $t->featured === 1);
100 ?>
101 <?php if ($is_featured): ?>
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 <div class="yatra-destination-empty-page">
112 <p><?php esc_html_e('No categories found on this page. Try navigating to other pages.', 'yatra'); ?></p>
113 </div>
114 <?php else: ?>
115 <div class="yatra-destination-empty">
116 <div class="yatra-empty-icon">
117 <?php echo yatra_svg_icon('tag', 'yatra-empty-icon-svg'); ?>
118 </div>
119 <h3><?php esc_html_e('No Categories Found', 'yatra'); ?></h3>
120 <p><?php esc_html_e('We could not find any trip categories. Please check back later or browse our trips directly.', 'yatra'); ?></p>
121 <a href="<?php echo esc_url(function_exists('yatra_get_trip_listing_url') ? yatra_get_trip_listing_url() : home_url('/')); ?>" class="yatra-btn yatra-btn-primary yatra-archive-card-cta">
122 <?php echo yatra_svg_icon('globe', 'yatra-btn-icon'); ?>
123 <span><?php esc_html_e('Browse All Trips', 'yatra'); ?></span>
124 </a>
125 </div>
126 <?php endif; ?>
127
128 <?php if ($atts['show_pagination'] === 'yes' && isset($max_pages) && $max_pages > 1): ?>
129 <div class="yatra-destination-pagination">
130 <?php if ($current_page > 1): ?>
131 <a href="#" class="yatra-pagination-link yatra-pagination-prev" data-page="<?php echo esc_attr($current_page - 1); ?>">
132 <?php echo yatra_svg_icon('chevron-left', ''); ?>
133 <?php esc_html_e('Previous', 'yatra'); ?>
134 </a>
135 <?php endif; ?>
136
137 <?php for ($i = 1; $i <= $max_pages; $i++): ?>
138 <?php $is_current = $i === $current_page; ?>
139 <a href="#" class="yatra-pagination-link <?php echo $is_current ? 'yatra-pagination-current' : ''; ?>" data-page="<?php echo esc_attr($i); ?>">
140 <?php echo esc_html((string) $i); ?>
141 </a>
142 <?php endfor; ?>
143
144 <?php if ($current_page < $max_pages): ?>
145 <a href="#" class="yatra-pagination-link yatra-pagination-next" data-page="<?php echo esc_attr($current_page + 1); ?>">
146 <?php esc_html_e('Next', 'yatra'); ?>
147 <?php echo yatra_svg_icon('chevron-right', ''); ?>
148 </a>
149 <?php endif; ?>
150 </div>
151 <?php endif; ?>
152 </div>
153