PluginProbe
Yatra – Travel Booking & Tour Operator Software / 3.0.5
Yatra – Travel Booking & Tour Operator Software v3.0.5
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
yatra / templates / partials / listing-sidebar-collapsible-checkboxes.php

listing-sidebar-collapsible-checkboxes.php in Yatra – Travel Booking & Tour Operator Software 3.0.5, at templates/partials/listing-sidebar-collapsible-checkboxes.php

81 lines 2.8 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * Trip listing sidebar: checkbox list with optional "Show more / Show less".
4 *
5 * Expects before include:
6 * - $yatra_sidebar_cb_rows — list of rows: value, label, optional count (int)
7 * - $yatra_sidebar_cb_input_name — e.g. categories[]
8 * - $yatra_sidebar_cb_active — array of selected values (same semantics as listing template)
9 *
10 * @package Yatra
11 */
12
13 if (!defined('ABSPATH')) {
14 exit;
15 }
16
17 $rows = isset($yatra_sidebar_cb_rows) ? array_values((array) $yatra_sidebar_cb_rows) : [];
18 $input_name = isset($yatra_sidebar_cb_input_name) ? (string) $yatra_sidebar_cb_input_name : '';
19 $active_vals = isset($yatra_sidebar_cb_active) && is_array($yatra_sidebar_cb_active) ? $yatra_sidebar_cb_active : [];
20
21 if ($input_name === '' || $rows === []) {
22 return;
23 }
24
25 $cap = function_exists('yatra_listing_sidebar_filter_visible_cap')
26 ? yatra_listing_sidebar_filter_visible_cap()
27 : 8;
28 $total = count($rows);
29 $expand = false;
30
31 if ($total > $cap && $active_vals !== []) {
32 for ($i = $cap; $i < $total; $i++) {
33 if (in_array($rows[$i]['value'], $active_vals)) {
34 $expand = true;
35 break;
36 }
37 }
38 }
39
40 $has_more = $total > $cap;
41 $wrapper_classes = 'yatra-checkbox-group yatra-filter-collapsible';
42 if ($has_more) {
43 $wrapper_classes .= ' has-more';
44 }
45 if ($expand) {
46 $wrapper_classes .= ' is-expanded';
47 }
48 ?>
49 <div class="<?php echo esc_attr($wrapper_classes); ?>" data-visible-cap="<?php echo esc_attr((string) $cap); ?>">
50 <?php foreach ($rows as $idx => $row) : ?>
51 <?php
52 $val = $row['value'] ?? '';
53 $label = isset($row['label']) ? (string) $row['label'] : '';
54 $more_class = $idx >= $cap ? ' yatra-filter-option-more' : '';
55 $attr_val = is_scalar($val) ? (string) $val : '';
56 ?>
57 <label class="yatra-checkbox-label<?php echo esc_attr($more_class); ?>">
58 <input
59 type="checkbox"
60 name="<?php echo esc_attr($input_name); ?>"
61 value="<?php echo esc_attr($attr_val); ?>"
62 <?php checked(in_array($val, $active_vals)); ?>
63 >
64 <span><?php echo esc_html($label); ?></span>
65 <?php if (array_key_exists('count', $row) && $row['count'] !== null && $row['count'] !== '') : ?>
66 <span class="yatra-filter-count">(<?php echo (int) $row['count']; ?>)</span>
67 <?php endif; ?>
68 </label>
69 <?php endforeach; ?>
70 <?php if ($has_more) : ?>
71 <button
72 type="button"
73 class="yatra-filter-show-more-toggle"
74 aria-expanded="<?php echo $expand ? 'true' : 'false'; ?>"
75 >
76 <span class="yatra-filter-show-more-label"><?php esc_html_e('Show more', 'yatra'); ?></span>
77 <span class="yatra-filter-show-less-label"><?php esc_html_e('Show less', 'yatra'); ?></span>
78 </button>
79 <?php endif; ?>
80 </div>
81