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 / activity.php

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

177 lines 9.5 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * Activity Shortcode Template
4 *
5 * This template displays activities in a grid layout with comprehensive information
6 * including pricing, ratings, duration, and other relevant details.
7 *
8 * @package Yatra
9 * @var array $atts Shortcode attributes
10 * @var array $activities Array of activity data
11 * @var int $current_page Current page number
12 * @var int $max_pages Maximum number of pages
13 * @var int $total_found Total number of activities found
14 * @var int $per_page Number of activities per page
15 */
16
17 // Prevent direct access
18 if (!defined('ABSPATH')) {
19 exit;
20 }
21
22
23 $columns = (int) $atts['columns'];
24 $column_class = 'yatra-activity-grid-' . min(max($columns, 1), 6);
25 ?>
26
27 <div class="yatra-activity-shortcode" data-atts='<?php echo esc_attr(json_encode($atts)); ?>'>
28 <div class="yatra-activity-header">
29 <?php if (!empty($atts['title'])): ?>
30 <h2 class="yatra-activity-title"><?php echo esc_html($atts['title']); ?></h2>
31 <?php else: ?>
32 <h2 class="yatra-activity-title"><?php esc_html_e('Activity Listings', 'yatra'); ?></h2>
33 <?php endif; ?>
34 <?php if (!empty($activities)): ?>
35 <div class="yatra-activity-count">
36 <?php
37 printf(
38 esc_html__('Showing %d of %d activities', 'yatra'),
39 esc_html(count($activities)),
40 esc_html($total_found)
41 );
42 ?>
43 </div>
44 <?php endif; ?>
45 </div>
46
47 <?php if (!empty($activities)): ?>
48 <div class="yatra-activity-grid <?php echo esc_attr($column_class); ?>">
49 <?php foreach ($activities as $activity): ?>
50 <div class="yatra-category-card">
51 <div class="yatra-category-card-image-wrapper">
52 <?php if (!empty($activity['image'])): ?>
53 <a href="<?php echo esc_url($activity['link']); ?>">
54 <img src="<?php echo esc_url($activity['image']); ?>" alt="<?php echo esc_attr($activity['term']->name); ?>" class="yatra-category-card-image">
55 </a>
56 <?php else: ?>
57 <a href="<?php echo esc_url($activity['link']); ?>">
58 <img src="<?php echo YATRA_PLUGIN_URL; ?>assets/images/placeholder.png" alt="<?php echo esc_attr($activity['term']->name); ?>" class="yatra-category-card-image">
59 </a>
60 <?php endif; ?>
61
62 <!-- Overlay Content on Image -->
63 <div class="yatra-category-card-overlay">
64 <div class="yatra-category-card-content">
65 <h3 class="yatra-category-card-title">
66 <a href="<?php echo esc_url($activity['link']); ?>" class="yatra-category-card-title-link"><?php echo esc_html($activity['term']->name); ?></a>
67 </h3>
68
69 <div class="yatra-category-card-stats">
70 <!-- Rating -->
71 <div class="category-stat rating">
72 <span class="category-stat-icon">
73 <svg width="16" height="16" fill="currentColor" viewBox="0 0 20 20">
74 <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" />
75 </svg>
76 </span>
77 <span class="category-stat-value"><?php echo esc_html(number_format(!empty($activity['avg_rating']) ? $activity['avg_rating'] : 0, 1)); ?></span>
78 </div>
79
80 <!-- Trip Count -->
81 <div class="category-stat trips">
82 <span class="category-stat-icon">
83 <svg width="16" height="16" fill="currentColor" viewBox="0 0 24 24">
84 <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"/>
85 </svg>
86 </span>
87 <span class="category-stat-value">
88 <?php
89 $trip_count = !empty($activity['trip_count']) ? $activity['trip_count'] : 0;
90 echo esc_html($trip_count) . ' ' . _n('Trip', 'Trips', $trip_count, 'yatra');
91 ?>
92 </span>
93 </div>
94
95 <!-- Price (if available) -->
96 <?php if (!empty($activity['min_price'])): ?>
97 <div class="category-stat price">
98 <span class="category-stat-icon">$</span>
99 <span class="category-stat-value">
100 <?php esc_html_e('From', 'yatra'); ?> <?php echo esc_html(yatra_get_currency_symbol(get_option('yatra_currency', 'USD')) . number_format($activity['min_price'], 2)); ?>
101 </span>
102 </div>
103 <?php endif; ?>
104 </div>
105 </div>
106 </div>
107
108 <!-- Featured Badge -->
109 <?php if (isset($activity['term']->featured) && $activity['term']->featured == 1): ?>
110 <div class="yatra-category-featured-badge">
111 <?php esc_html_e('Featured', 'yatra'); ?>
112 </div>
113 <?php endif; ?>
114 </div>
115 </div>
116 <?php endforeach; ?>
117 </div>
118 <?php elseif ($total_found > 0): ?>
119 <!-- No activities on this page, but activities exist on other pages -->
120 <div class="yatra-activity-empty-page">
121 <p><?php esc_html_e('No activities found on this page. Try navigating to other pages.', 'yatra'); ?></p>
122 </div>
123 <?php else: ?>
124 <!-- No activities found at all -->
125 <div class="yatra-activity-empty">
126 <div class="yatra-empty-icon">
127 <?php echo yatra_svg_icon('activity', 'yatra-empty-icon-svg'); ?>
128 </div>
129 <h3><?php esc_html_e('No Activities Found', 'yatra'); ?></h3>
130 <p><?php esc_html_e('We couldn\'t find any activities. Please check back later or browse our trips directly.', 'yatra'); ?></p>
131 <a href="<?php echo esc_url(get_post_type_archive_link('trip')); ?>" class="yatra-btn yatra-btn-primary yatra-archive-card-cta">
132 <?php echo yatra_svg_icon('globe', 'yatra-btn-icon'); ?>
133 <span><?php esc_html_e('Browse All Trips', 'yatra'); ?></span>
134 </a>
135 </div>
136 <?php endif; ?>
137
138 <?php if ($atts['show_pagination'] === 'yes' && isset($max_pages) && $max_pages > 1): ?>
139 <div class="yatra-activity-pagination">
140 <?php
141 $current_url = remove_query_arg('activity_page', $_SERVER['REQUEST_URI']);
142 $current_url = preg_replace('/&activity_page=[^&]*/', '', $current_url);
143
144 // Previous page
145 if ($current_page > 1):
146 $prev_url = add_query_arg('activity_page', $current_page - 1, $current_url);
147 ?>
148 <a href="#" class="yatra-pagination-link yatra-pagination-prev" data-page="<?php echo esc_attr($current_page - 1); ?>">
149 <?php echo yatra_svg_icon('chevron-left', ''); ?>
150 <?php esc_html_e('Previous', 'yatra'); ?>
151 </a>
152 <?php endif; ?>
153
154 <?php
155 // Show all page numbers - no ellipsis
156 for ($i = 1; $i <= $max_pages; $i++):
157 $is_current = $i === $current_page;
158 ?>
159 <a href="#" class="yatra-pagination-link <?php echo $is_current ? 'yatra-pagination-current' : ''; ?>" data-page="<?php echo esc_attr($i); ?>">
160 <?php echo esc_html($i); ?>
161 </a>
162 <?php endfor; ?>
163
164 <?php
165 // Next page
166 if ($current_page < $max_pages):
167 $next_url = add_query_arg('activity_page', $current_page + 1, $current_url);
168 ?>
169 <a href="#" class="yatra-pagination-link yatra-pagination-next" data-page="<?php echo esc_attr($current_page + 1); ?>">
170 <?php esc_html_e('Next', 'yatra'); ?>
171 <?php echo yatra_svg_icon('chevron-right', ''); ?>
172 </a>
173 <?php endif; ?>
174 </div>
175 <?php endif; ?>
176 </div>
177