PluginProbe
Yatra – Travel Booking & Tour Operator Software / trunk
Yatra – Travel Booking & Tour Operator Software vtrunk
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 2.0.11 All 82 releases
yatra / templates / shortcodes / trip.php

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

120 lines 5.1 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * Tour Shortcode Template
4 *
5 * @package Yatra
6 * @var array $trips Array of trip objects
7 * @var array $atts Shortcode attributes
8 * @var array $query_args WP_Query arguments
9 * @var int $max_pages Maximum number of pages
10 * @var int $current_page Current page number
11 * @var int $total_found Total number of trips found
12 */
13 // Prevent direct access
14 if (!defined('ABSPATH')) {
15 exit;
16 }
17 $columns = (int) $atts['columns'];
18 $column_class = 'yatra-tour-grid-' . min(max($columns, 1), 6);
19 // Extract pagination variables from trips data structure
20 $current_page = $trips['current_page'] ?? $current_page ?? 1;
21 $max_pages = $trips['max_pages'] ?? $max_pages ?? 1;
22 $total_found = (int) ($trips['total_found'] ?? $total_found ?? 0);
23 $trip_items = $trips['trips'] ?? [];
24
25 // Section title: align with activity/destination blocks (always same header structure).
26 if (!empty($atts['title'])) {
27 $display_title = (string) $atts['title'];
28 } elseif (!empty($atts['featured']) && $atts['featured'] === '1') {
29 $display_title = __('Featured Trips', 'yatra');
30 } else {
31 $display_title = __('Our Trips', 'yatra');
32 }
33 ?>
34 <div class="yatra-tour-shortcode" data-atts='<?php echo esc_attr(json_encode($atts)); ?>'>
35 <div class="yatra-tour-header">
36 <h2 class="yatra-tour-title"><?php echo esc_html($display_title); ?></h2>
37 <?php if (!empty($trip_items) && $total_found > 0) : ?>
38 <div class="yatra-tour-count">
39 <?php
40 printf(
41 /* translators: 1: number of trips shown, 2: total trips available. */
42 esc_html__('Showing %1$d of %2$d trips', 'yatra'),
43 (int) count($trip_items),
44 (int) $total_found
45 );
46 ?>
47 </div>
48 <?php endif; ?>
49 </div>
50 <?php if (!empty($trip_items)): ?>
51 <div class="yatra-tour-grid <?php echo esc_attr($column_class); ?>">
52 <?php foreach ($trip_items as $trip): ?>
53 <div class="yatra-tour-item">
54 <?php
55 // Load the trip card template
56 include YATRA_PLUGIN_PATH . 'templates/trip-listing-card.php';
57 ?>
58 </div>
59 <?php endforeach; ?>
60 </div>
61 <?php elseif ($total_found > 0): ?>
62 <!-- No trips on this page, but trips exist on other pages -->
63 <div class="yatra-tour-empty-page">
64 <p><?php esc_html_e('No trips found on this page. Try navigating to other pages.', 'yatra'); ?></p>
65 </div>
66 <?php else: ?>
67 <!-- No trips found at all -->
68 <div class="yatra-tour-empty">
69 <div class="yatra-empty-icon">
70 <?php echo yatra_svg_icon('map', 'yatra-empty-icon-svg'); ?>
71 </div>
72 <h3><?php esc_html_e('No Trips Found', 'yatra'); ?></h3>
73 <p><?php esc_html_e('We couldn\'t find any trips matching your criteria. Try adjusting your filters or browse all trips.', 'yatra'); ?></p>
74
75
76
77 <a href="<?php echo esc_url(home_url('/trips')); ?>" class="yatra-btn yatra-btn-primary yatra-archive-card-cta">
78 <?php echo yatra_svg_icon('globe', 'yatra-btn-icon'); ?>
79 <span><?php esc_html_e('Browse All Trips', 'yatra'); ?></span>
80 </a>
81 </div>
82 <?php endif; ?>
83 <?php if ($atts['show_pagination'] === 'yes' && $max_pages > 1): ?>
84 <div class="yatra-tour-pagination">
85 <?php
86 $current_url = remove_query_arg('trip_page', $_SERVER['REQUEST_URI']);
87 $current_url = preg_replace('/&trip_page=[^&]*/', '', $current_url);
88
89 // Previous page
90 if ($current_page > 1):
91 $prev_url = add_query_arg('trip_page', $current_page - 1, $current_url);
92 ?>
93 <a href="#" class="yatra-pagination-link yatra-pagination-prev" data-page="<?php echo esc_attr($current_page - 1); ?>">
94 <?php echo yatra_svg_icon('chevron-left', 'yatra-btn-icon'); ?>
95 <span><?php esc_html_e('Previous', 'yatra'); ?></span>
96 </a>
97 <?php endif; ?>
98 <?php
99 // Show all page numbers - no ellipsis
100 for ($i = 1; $i <= $max_pages; $i++):
101 $is_current = $i === $current_page;
102 ?>
103 <a href="#" class="yatra-pagination-link <?php echo $is_current ? 'yatra-pagination-current' : ''; ?>" data-page="<?php echo esc_attr($i); ?>">
104 <?php echo esc_html($i); ?>
105 </a>
106 <?php endfor; ?>
107 <?php
108 // Next page
109 if ($current_page < $max_pages):
110 $next_url = add_query_arg('trip_page', $current_page + 1, $current_url);
111 ?>
112 <a href="#" class="yatra-pagination-link yatra-pagination-next" data-page="<?php echo esc_attr($current_page + 1); ?>">
113 <span><?php esc_html_e('Next', 'yatra'); ?></span>
114 <?php echo yatra_svg_icon('chevron-right', 'yatra-btn-icon'); ?>
115 </a>
116 <?php endif; ?>
117 </div>
118 <?php endif; ?>
119 </div>
120