PluginProbe
Yatra – Travel Booking & Tour Operator Software / 3.0.16
Yatra – Travel Booking & Tour Operator Software v3.0.16
3.0.16 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 All 84 releases
← All changes | app/Shortcodes/DestinationShortcode.php +35 -13 3.0.2.9 → 3.0.16 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 }
@@ -56,14 +61,15 @@
56 61 'total_found' => $destinations_data['total_found'] ?? 0,
57 62 'per_page' => $per_page
58 63 ];
59 64
60 - // Enqueue shortcode-specific CSS
65 + $destinationCssPath = YATRA_PLUGIN_PATH . 'assets/css/shortcodes/destination-shortcode.css';
66 + $destinationCssVer = is_readable($destinationCssPath) ? YATRA_VERSION . '.' . filemtime($destinationCssPath) : YATRA_VERSION;
61 67 wp_enqueue_style(
62 68 'yatra-destination-shortcode',
63 69 YATRA_PLUGIN_URL . 'assets/css/shortcodes/destination-shortcode.css',
64 - [],
65 - YATRA_VERSION
70 + \Yatra\Providers\FrontendAssetsProvider::shortcodeStyleDependencies(),
71 + $destinationCssVer
66 72 );
67 73
68 74 // Enqueue shortcode-specific JavaScript
69 75 wp_enqueue_script(
@@ -113,12 +119,16 @@
113 119 'order_by' => 'name',
114 120 'order' => $atts['order'] === 'asc' ? 'ASC' : 'DESC'
115 121 ];
116 122
117 - // Filter by specific destinations if provided
118 - if (!empty($atts['destination'])) {
119 - $args['where']['slug'] = explode(',', $atts['destination']);
120 - }
123 + $args['where'] = $args['where'] ?? [];
124 + TripListingFilterBuilder::applyTaxonomyWhere(
125 + $args['where'],
126 + $atts,
127 + 'destinationIds',
128 + 'destination_ids',
129 + 'destination'
130 + );
121 131
122 132 // Get total count for pagination
123 133 $count_args = $args;
124 134 unset($count_args['limit']);
@@ -266,12 +276,24 @@
266 276 'best_season' => $best_season
267 277 ];
268 278 }
269 279
270 - // 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.
271 291 if ($atts['hide_empty'] === 'yes') {
272 - $destinations = array_filter($destinations, function($destination) {
273 - 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);
274 296 });
275 297 }
276 298
277 299 // Filter to show only featured destinations if requested
@@ -469,9 +491,9 @@
469 491 if (function_exists('yatra_get_destination_permalink')) {
470 492 return yatra_get_destination_permalink($destination);
471 493 }
472 494
473 - $base = SettingsService::getString('destination_base', 'destination');
495 + $base = SettingsService::getDestinationBase();
474 496 return home_url('/' . $base . '/' . $destination->slug . '/');
475 497 }
476 498
477 499 return '#'; // Fallback