| 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 |
/* translators: 1: number of destinations shown, 2: total destinations available. */ |
| 31 |
esc_html__('Showing %1$d of %2$d destinations', 'yatra'), |
| 32 |
(int) count($destinations), |
| 33 |
(int) $total_found |
| 34 |
); |
| 35 |
?> |
| 36 |
</div> |
| 37 |
<?php endif; ?> |
| 38 |
</div> |
| 39 |
|
| 40 |
<?php if (!empty($destinations)): ?> |
| 41 |
<div class="yatra-destination-grid <?php echo esc_attr($column_class); ?>"> |
| 42 |
<?php foreach ($destinations as $destination): ?> |
| 43 |
<div class="yatra-category-card"> |
| 44 |
<div class="yatra-category-card-image-wrapper"> |
| 45 |
<?php if (!empty($destination['image'])): ?> |
| 46 |
<a href="<?php echo esc_url($destination['link']); ?>"> |
| 47 |
<img src="<?php echo esc_url($destination['image']); ?>" alt="<?php echo esc_attr($destination['term']->name); ?>" class="yatra-category-card-image"> |
| 48 |
</a> |
| 49 |
<?php else: ?> |
| 50 |
<a href="<?php echo esc_url($destination['link']); ?>"> |
| 51 |
<img src="<?php echo YATRA_PLUGIN_URL; ?>assets/images/placeholder.png" alt="<?php echo esc_attr($destination['term']->name); ?>" class="yatra-category-card-image"> |
| 52 |
</a> |
| 53 |
<?php endif; ?> |
| 54 |
|
| 55 |
<!-- Overlay Content on Image --> |
| 56 |
<div class="yatra-category-card-overlay"> |
| 57 |
<div class="yatra-category-card-content"> |
| 58 |
<h3 class="yatra-category-card-title"> |
| 59 |
<a href="<?php echo esc_url($destination['link']); ?>" class="yatra-category-card-title-link"><?php echo esc_html($destination['term']->name); ?></a> |
| 60 |
</h3> |
| 61 |
|
| 62 |
<div class="yatra-category-card-stats"> |
| 63 |
<!-- Rating --> |
| 64 |
<div class="category-stat rating"> |
| 65 |
<span class="category-stat-icon"> |
| 66 |
<svg width="16" height="16" fill="currentColor" viewBox="0 0 20 20"> |
| 67 |
<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" /> |
| 68 |
</svg> |
| 69 |
</span> |
| 70 |
<span class="category-stat-value"><?php echo esc_html(number_format(!empty($destination['avg_rating']) ? $destination['avg_rating'] : 0, 1)); ?></span> |
| 71 |
</div> |
| 72 |
|
| 73 |
<!-- Trip Count --> |
| 74 |
<div class="category-stat trips"> |
| 75 |
<span class="category-stat-icon"> |
| 76 |
<svg width="16" height="16" fill="currentColor" viewBox="0 0 24 24"> |
| 77 |
<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"/> |
| 78 |
</svg> |
| 79 |
</span> |
| 80 |
<span class="category-stat-value"> |
| 81 |
<?php |
| 82 |
$trip_count = !empty($destination['trip_count']) ? $destination['trip_count'] : 0; |
| 83 |
echo esc_html($trip_count) . ' ' . _n('Trip', 'Trips', $trip_count, 'yatra'); |
| 84 |
?> |
| 85 |
</span> |
| 86 |
</div> |
| 87 |
|
| 88 |
<!-- Price (if available) --> |
| 89 |
<?php if (!empty($destination['min_price'])): ?> |
| 90 |
<div class="category-stat price"> |
| 91 |
<span class="category-stat-icon">$</span> |
| 92 |
<span class="category-stat-value"> |
| 93 |
<?php esc_html_e('From', 'yatra'); ?> <?php echo esc_html(yatra_format_price((float) $destination['min_price'])); ?> |
| 94 |
</span> |
| 95 |
</div> |
| 96 |
<?php endif; ?> |
| 97 |
</div> |
| 98 |
</div> |
| 99 |
</div> |
| 100 |
|
| 101 |
<!-- Featured Badge --> |
| 102 |
<?php if (isset($destination['term']->featured) && $destination['term']->featured == 1): ?> |
| 103 |
<div class="yatra-category-featured-badge"> |
| 104 |
<?php esc_html_e('Featured', 'yatra'); ?> |
| 105 |
</div> |
| 106 |
<?php endif; ?> |
| 107 |
</div> |
| 108 |
</div> |
| 109 |
<?php endforeach; ?> |
| 110 |
</div> |
| 111 |
<?php elseif ($total_found > 0): ?> |
| 112 |
<!-- No destinations on this page, but destinations exist on other pages --> |
| 113 |
<div class="yatra-destination-empty-page"> |
| 114 |
<p><?php esc_html_e('No destinations found on this page. Try navigating to other pages.', 'yatra'); ?></p> |
| 115 |
</div> |
| 116 |
<?php else: ?> |
| 117 |
<!-- No destinations found at all --> |
| 118 |
<div class="yatra-destination-empty"> |
| 119 |
<div class="yatra-empty-icon"> |
| 120 |
<?php echo yatra_svg_icon('map', 'yatra-empty-icon-svg'); ?> |
| 121 |
</div> |
| 122 |
<h3><?php esc_html_e('No Destinations Found', 'yatra'); ?></h3> |
| 123 |
<p><?php esc_html_e('We couldn\'t find any destinations. Please check back later or browse our trips directly.', 'yatra'); ?></p> |
| 124 |
<a href="<?php echo esc_url(get_post_type_archive_link('trip')); ?>" class="yatra-btn yatra-btn-primary yatra-archive-card-cta"> |
| 125 |
<?php echo yatra_svg_icon('globe', 'yatra-btn-icon'); ?> |
| 126 |
<span><?php esc_html_e('Browse All Trips', 'yatra'); ?></span> |
| 127 |
</a> |
| 128 |
</div> |
| 129 |
<?php endif; ?> |
| 130 |
|
| 131 |
<?php if ($atts['show_pagination'] === 'yes' && isset($max_pages) && $max_pages > 1): ?> |
| 132 |
<div class="yatra-destination-pagination"> |
| 133 |
<?php |
| 134 |
$current_url = remove_query_arg('destination_page', $_SERVER['REQUEST_URI']); |
| 135 |
$current_url = preg_replace('/&destination_page=[^&]*/', '', $current_url); |
| 136 |
|
| 137 |
// Previous page |
| 138 |
if ($current_page > 1): |
| 139 |
$prev_url = add_query_arg('destination_page', $current_page - 1, $current_url); |
| 140 |
?> |
| 141 |
<a href="#" class="yatra-pagination-link yatra-pagination-prev" data-page="<?php echo esc_attr($current_page - 1); ?>"> |
| 142 |
<?php echo yatra_svg_icon('chevron-left', ''); ?> |
| 143 |
<?php esc_html_e('Previous', 'yatra'); ?> |
| 144 |
</a> |
| 145 |
<?php endif; ?> |
| 146 |
|
| 147 |
<?php |
| 148 |
// Show all page numbers - no ellipsis |
| 149 |
for ($i = 1; $i <= $max_pages; $i++): |
| 150 |
$is_current = $i === $current_page; |
| 151 |
?> |
| 152 |
<a href="#" class="yatra-pagination-link <?php echo $is_current ? 'yatra-pagination-current' : ''; ?>" data-page="<?php echo esc_attr($i); ?>"> |
| 153 |
<?php echo esc_html($i); ?> |
| 154 |
</a> |
| 155 |
<?php endfor; ?> |
| 156 |
|
| 157 |
<?php |
| 158 |
// Next page |
| 159 |
if ($current_page < $max_pages): |
| 160 |
$next_url = add_query_arg('destination_page', $current_page + 1, $current_url); |
| 161 |
?> |
| 162 |
<a href="#" class="yatra-pagination-link yatra-pagination-next" data-page="<?php echo esc_attr($current_page + 1); ?>"> |
| 163 |
<?php esc_html_e('Next', 'yatra'); ?> |
| 164 |
<?php echo yatra_svg_icon('chevron-right', ''); ?> |
| 165 |
</a> |
| 166 |
<?php endif; ?> |
| 167 |
</div> |
| 168 |
<?php endif; ?> |
| 169 |
</div> |
| 170 |
|
| 171 |
|