PluginProbe
Yatra – Travel Booking & Tour Operator Software / trunk
Yatra – Travel Booking & Tour Operator Software vtrunk
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
← All changes | app/Shortcodes/DestinationShortcode.php +31 -10 3.0.3trunk View file →
@@ -3,8 +3,9 @@
3 3 declare(strict_types=1);
4 4
5 5 namespace Yatra\Shortcodes;
6 6
7 +use Yatra\Helpers\TripListingFilterBuilder;
7 8 use Yatra\Services\SettingsService;
8 9
9 10 /**
10 11 * Destination Shortcode
@@ -22,10 +23,14 @@
22 23 'show_trip_count' => 'yes',
23 24 'show_description' => 'yes',
24 25 'show_image' => 'yes',
25 26 'show_pagination' => 'yes', // Default to show pagination like trip shortcode
26 - 'destination' => '', // Specific destination slug(s), comma separated
27 - 'hide_empty' => 'yes',
27 + 'destination' => '', // Classification IDs, comma-separated
28 + // hide_empty defaults to 'no' to preserve the historical
29 + // behavior (show every destination, even ones with zero
30 + // trips). Operators that prefer the empty-archive defense
31 + // opt in with hide_empty="yes".
32 + 'hide_empty' => 'no',
28 33 'featured_only' => 'no',
29 34 'title' => 'Destination Showcase'
30 35 ]);
31 36 }
@@ -114,12 +119,16 @@
114 119 'order_by' => 'name',
115 120 'order' => $atts['order'] === 'asc' ? 'ASC' : 'DESC'
116 121 ];
117 122
118 - // Filter by specific destinations if provided
119 - if (!empty($atts['destination'])) {
120 - $args['where']['slug'] = explode(',', $atts['destination']);
121 - }
123 + $args['where'] = $args['where'] ?? [];
124 + TripListingFilterBuilder::applyTaxonomyWhere(
125 + $args['where'],
126 + $atts,
127 + 'destinationIds',
128 + 'destination_ids',
129 + 'destination'
130 + );
122 131
123 132 // Get total count for pagination
124 133 $count_args = $args;
125 134 unset($count_args['limit']);
@@ -267,12 +276,24 @@
267 276 'best_season' => $best_season
268 277 ];
269 278 }
270 279
271 - // Filter out empty destinations if requested
280 + // Filter out destinations that have no published trips.
281 + //
282 + // See ActivityShortcode for the full rationale — the
283 + // prior implementation only filtered on term-metadata
284 + // emptiness (which never actually fires), so destinations
285 + // with zero trips were rendered with empty trip counts
286 + // and broken archive links. We now drop any destination
287 + // whose trip_count (computed above from
288 + // TripClassificationsTable JOIN TripsTable WHERE
289 + // status=publish) is zero, plus the original sanity
290 + // check on name/slug.
272 291 if ($atts['hide_empty'] === 'yes') {
273 - $destinations = array_filter($destinations, function($destination) {
274 - return !empty($destination['term']->name) && !empty($destination['term']->slug);
292 + $destinations = array_filter($destinations, static function ($destination) {
293 + return (int) ($destination['trip_count'] ?? 0) > 0
294 + && !empty($destination['term']->name)
295 + && !empty($destination['term']->slug);
275 296 });
276 297 }
277 298
278 299 // Filter to show only featured destinations if requested
@@ -470,9 +491,9 @@
470 491 if (function_exists('yatra_get_destination_permalink')) {
471 492 return yatra_get_destination_permalink($destination);
472 493 }
473 494
474 - $base = SettingsService::getString('destination_base', 'destination');
495 + $base = SettingsService::getDestinationBase();
475 496 return home_url('/' . $base . '/' . $destination->slug . '/');
476 497 }
477 498
478 499 return '#'; // Fallback