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
← All changes | app/Shortcodes/ActivityShortcode.php +21 -4 3.0.4trunk View file →
@@ -24,9 +24,13 @@
24 24 'show_description' => 'yes',
25 25 'show_image' => 'yes',
26 26 'show_pagination' => 'yes', // Default to show pagination like trip shortcode
27 27 'activity' => '', // Classification IDs, comma-separated
28 - 'hide_empty' => 'yes',
28 + // hide_empty defaults to 'no' to preserve the historical
29 + // behavior (show every activity, even ones with zero
30 + // trips). Operators that prefer the empty-archive defense
31 + // opt in with hide_empty="yes".
32 + 'hide_empty' => 'no',
29 33 'title' => 'Activity Listings'
30 34 ]);
31 35 }
32 36
@@ -258,12 +262,25 @@
258 262 'difficulty' => !empty($difficulties) ? $this->getMostCommonDifficulty($difficulties) : null
259 263 ];
260 264 }
261 265
262 - // Filter out empty activities if requested
266 + // Filter out activities that have no published trips.
267 + //
268 + // Previously this only checked term name/slug presence —
269 + // which never actually fires because all valid terms have
270 + // both. As a result the shortcode would render activity
271 + // cards with "0 trips" badges, leading users to click
272 + // into empty archive pages. With hide_empty=yes we now
273 + // drop any activity whose trip_count (computed above
274 + // from TripClassificationsTable JOIN TripsTable WHERE
275 + // status=publish) is zero. Term-metadata sanity is also
276 + // preserved as a secondary safety check so we don't
277 + // render orphan terms.
263 278 if ($atts['hide_empty'] === 'yes') {
264 - $activities = array_filter($activities, function($activity) {
265 - return !empty($activity['term']->name) && !empty($activity['term']->slug);
279 + $activities = array_filter($activities, static function ($activity) {
280 + return (int) ($activity['trip_count'] ?? 0) > 0
281 + && !empty($activity['term']->name)
282 + && !empty($activity['term']->slug);
266 283 });
267 284 }
268 285
269 286 // Calculate pagination data