| 1 |
<?php |
| 2 |
if (!defined('ABSPATH')) |
| 3 |
exit; // Exit if accessed directly |
| 4 |
|
| 5 |
// this file print filters - filters callback |
| 6 |
if (!function_exists('ufg_filters')) { |
| 7 |
function ufg_filters($ufg_gallery_id, $ufg_filters, $ufg_gallery, $atts = array()) |
| 8 |
{ |
| 9 |
if (is_array($ufg_filters) && count($ufg_filters)) { |
| 10 |
if (function_exists('ufg_normalize_filters_recursive')) { |
| 11 |
ufg_normalize_filters_recursive($ufg_filters); |
| 12 |
} |
| 13 |
if (function_exists('ufg_remove_blank_filters_recursive')) { |
| 14 |
ufg_remove_blank_filters_recursive($ufg_filters); |
| 15 |
} |
| 16 |
$filters_count = count($ufg_filters); |
| 17 |
|
| 18 |
//echo $filters_count; |
| 19 |
//load settings |
| 20 |
$ufg_setting = get_option("ufg_settings_" . $ufg_gallery_id); |
| 21 |
include('setting.php'); |
| 22 |
|
| 23 |
// filters image count |
| 24 |
$ufg_total_image_count = 0; |
| 25 |
if (isset($ufg_gallery['ufg-attachment-id']) && is_array($ufg_gallery['ufg-attachment-id'])) { |
| 26 |
$ufg_total_image_count = count($ufg_gallery['ufg-attachment-id']); |
| 27 |
} |
| 28 |
|
| 29 |
// Pre-calculate filter image mapped IDs |
| 30 |
$ufg_filter_images = array(); |
| 31 |
if (isset($ufg_gallery['ufg-image-filters']) && is_array($ufg_gallery['ufg-image-filters'])) { |
| 32 |
foreach ($ufg_gallery['ufg-image-filters'] as $att_id => $item_filters) { |
| 33 |
if (is_array($item_filters)) { |
| 34 |
foreach ($item_filters as $filter_key) { |
| 35 |
$clean_key = strtolower(trim($filter_key)); |
| 36 |
if (!isset($ufg_filter_images[$clean_key])) { |
| 37 |
$ufg_filter_images[$clean_key] = array(); |
| 38 |
} |
| 39 |
$ufg_filter_images[$clean_key][] = $att_id; |
| 40 |
} |
| 41 |
} |
| 42 |
} |
| 43 |
} |
| 44 |
|
| 45 |
// Add parent-child image count sum logic using unique image IDs |
| 46 |
$ufg_filter_counts = array(); |
| 47 |
if (!function_exists('ufg_compute_filter_counts')) { |
| 48 |
function ufg_compute_filter_counts($filters, $images_map, &$counts) { |
| 49 |
$all_assigned = array(); |
| 50 |
if (is_array($filters)) { |
| 51 |
foreach ($filters as $filter) { |
| 52 |
if (!isset($filter->filterkey)) continue; |
| 53 |
$key = strtolower(trim($filter->filterkey)); |
| 54 |
$my_images = isset($images_map[$key]) ? $images_map[$key] : array(); |
| 55 |
|
| 56 |
if (isset($filter->children) && is_array($filter->children)) { |
| 57 |
ufg_compute_filter_counts($filter->children, $images_map, $counts); |
| 58 |
} |
| 59 |
$my_images = array_unique($my_images); |
| 60 |
$counts[$key] = count($my_images); |
| 61 |
$all_assigned = array_merge($all_assigned, $my_images); |
| 62 |
} |
| 63 |
} |
| 64 |
return array_unique($all_assigned); |
| 65 |
} |
| 66 |
} |
| 67 |
|
| 68 |
if (is_array($ufg_filters)) { |
| 69 |
ufg_compute_filter_counts($ufg_filters, $ufg_filter_images, $ufg_filter_counts); |
| 70 |
} |
| 71 |
|
| 72 |
// Define count display logic |
| 73 |
$get_count_html = function ($filter_key) use ($ufg_show_filters_count, $ufg_filter_counts) { |
| 74 |
$clean_key = strtolower(trim($filter_key)); |
| 75 |
if ($ufg_show_filters_count && isset($ufg_filter_counts[$clean_key])) { |
| 76 |
return " (" . intval($ufg_filter_counts[$clean_key]) . ")"; |
| 77 |
} |
| 78 |
return ""; |
| 79 |
}; |
| 80 |
|
| 81 |
$ufg_filter_style = (isset($ufg_setting['filter_style']) && $ufg_setting['filter_style'] === 'dropdown') ? 'dropdown' : 'buttons'; |
| 82 |
|
| 83 |
if (!function_exists('ufg_fa_class_to_unicode')) { |
| 84 |
function ufg_fa_class_to_unicode($class) { |
| 85 |
if (empty($class)) return ''; |
| 86 |
$hex_map = array( |
| 87 |
'fa-filter' => '\uf0b0', |
| 88 |
'fa-camera' => '\uf030', |
| 89 |
'fa-image' => '\uf03e', |
| 90 |
'fa-star' => '\uf005', |
| 91 |
'fa-heart' => '\uf004', |
| 92 |
'fa-shield-alt' => '\uf3ed', |
| 93 |
'fa-shield' => '\uf132', |
| 94 |
'fa-search' => '\uf002', |
| 95 |
'fa-link' => '\uf0c1', |
| 96 |
'fa-tag' => '\uf02b', |
| 97 |
'fa-tags' => '\uf02c', |
| 98 |
'fa-folder' => '\uf07b', |
| 99 |
'fa-folder-open' => '\uf07c', |
| 100 |
'fa-user' => '\uf007', |
| 101 |
'fa-users' => '\uf0c0', |
| 102 |
'fa-eye' => '\uf06e', |
| 103 |
'fa-check' => '\uf00c', |
| 104 |
'fa-bookmark' => '\uf02e', |
| 105 |
'fa-cog' => '\uf013', |
| 106 |
'fa-cogs' => '\uf085', |
| 107 |
'fa-layer-group' => '\uf5fd', |
| 108 |
'fa-palette' => '\uf53f', |
| 109 |
'fa-images' => '\uf302', |
| 110 |
'fa-calendar' => '\uf133', |
| 111 |
'fa-clock' => '\uf017', |
| 112 |
'fa-map-marker-alt' => '\uf3c5', |
| 113 |
'fa-globe' => '\uf0ac', |
| 114 |
'fa-thumbs-up' => '\uf164', |
| 115 |
'fa-fire' => '\uf06d', |
| 116 |
'fa-bolt' => '\uf0e7', |
| 117 |
'fa-gem' => '\uf3a5', |
| 118 |
'fa-trophy' => '\uf091', |
| 119 |
'fa-gift' => '\uf06b', |
| 120 |
'fa-music' => '\uf001', |
| 121 |
'fa-video' => '\uf03d', |
| 122 |
'fa-film' => '\uf008', |
| 123 |
'fa-compass' => '\uf14e', |
| 124 |
'fa-sun' => '\uf185', |
| 125 |
'fa-moon' => '\uf186', |
| 126 |
'fa-leaf' => '\uf06c', |
| 127 |
'fa-circle' => '\uf111', |
| 128 |
'fa-square' => '\uf0c8', |
| 129 |
'fa-play' => '\uf04b', |
| 130 |
'fa-pause' => '\uf04c', |
| 131 |
'fa-stop' => '\uf04d', |
| 132 |
'fa-info-circle' => '\uf05a', |
| 133 |
'fa-question-circle' => '\uf059', |
| 134 |
'fa-exclamation-circle' => '\uf06a', |
| 135 |
'fa-exclamation-triangle' => '\uf071', |
| 136 |
'fa-arrow-right' => '\uf061', |
| 137 |
'fa-arrow-left' => '\uf060', |
| 138 |
'fa-arrow-up' => '\uf062', |
| 139 |
'fa-arrow-down' => '\uf063', |
| 140 |
'fa-envelope' => '\uf0e0', |
| 141 |
'fa-phone' => '\uf095', |
| 142 |
'fa-home' => '\uf015', |
| 143 |
'fa-shopping-cart' => '\uf07a', |
| 144 |
'fa-th' => '\uf00a', |
| 145 |
'fa-th-large' => '\uf009', |
| 146 |
'fa-list' => '\uf03a', |
| 147 |
); |
| 148 |
foreach ($hex_map as $key => $hex) { |
| 149 |
if (strpos($class, $key) !== false) { |
| 150 |
return json_decode('"' . $hex . '"') . ' '; |
| 151 |
} |
| 152 |
} |
| 153 |
return ''; |
| 154 |
} |
| 155 |
} |
| 156 |
|
| 157 |
// Dropdown Style Rendering |
| 158 |
if ($ufg_filter_style === 'dropdown') { |
| 159 |
echo "<div class='ufg-filter-dropdown-container'>"; |
| 160 |
echo "<select class='ufg-filter-dropdown filters' data-gallery-id='" . esc_attr($ufg_gallery_id) . "'>"; |
| 161 |
if ($ufg_show_all_button) { |
| 162 |
$all_icon_unicode = ''; |
| 163 |
if ($ufg_show_filters_icon != 0) { |
| 164 |
$icon_to_use = !empty($ufg_all_button_icon) ? $ufg_all_button_icon : 'fas fa-filter'; |
| 165 |
$all_icon_unicode = ufg_fa_class_to_unicode($icon_to_use); |
| 166 |
} |
| 167 |
echo "<option class='ufg-opt-parent ufg-opt-all' value='*'>" . esc_html($all_icon_unicode . $ufg_all_button_text) . " (" . intval($ufg_total_image_count) . ")</option>"; |
| 168 |
} |
| 169 |
if (!function_exists('ufg_render_dropdown_options')) { |
| 170 |
function ufg_render_dropdown_options($filters, $get_count_html, $ufg_show_filters_icon, $depth = 0) { |
| 171 |
if (!is_array($filters)) return; |
| 172 |
$level_classes = array(0 => 'parent', 1 => 'l1', 2 => 'l2', 3 => 'l3', 4 => 'l4'); |
| 173 |
$class_suffix = isset($level_classes[$depth]) ? $level_classes[$depth] : 'parent'; |
| 174 |
$option_class = 'ufg-opt-' . $class_suffix; |
| 175 |
|
| 176 |
foreach ($filters as $filter) { |
| 177 |
if (!isset($filter->filterkey)) continue; |
| 178 |
$key = str_replace(" ", "-", strtolower(trim($filter->filterkey))); |
| 179 |
$text = $filter->text; |
| 180 |
$indent = str_repeat(chr(194) . chr(160) . chr(194) . chr(160) . chr(194) . chr(160) . chr(194) . chr(160), $depth); |
| 181 |
$prefix = $depth > 0 ? '— ' : ''; |
| 182 |
$count_html = $get_count_html($filter->filterkey); |
| 183 |
|
| 184 |
$icon_unicode = ''; |
| 185 |
if ($ufg_show_filters_icon != 0 && isset($filter->icon) && !empty($filter->icon)) { |
| 186 |
$icon_unicode = ufg_fa_class_to_unicode($filter->icon); |
| 187 |
} |
| 188 |
|
| 189 |
echo '<option class="' . esc_attr($option_class) . '" value="' . esc_attr($key) . '">' . esc_html($indent) . esc_html($prefix) . esc_html($icon_unicode . $text) . esc_html($count_html) . '</option>'; |
| 190 |
|
| 191 |
if (isset($filter->children) && is_array($filter->children)) { |
| 192 |
ufg_render_dropdown_options($filter->children, $get_count_html, $ufg_show_filters_icon, $depth + 1); |
| 193 |
} |
| 194 |
} |
| 195 |
} |
| 196 |
} |
| 197 |
ufg_render_dropdown_options($ufg_filters, $get_count_html, $ufg_show_filters_icon, 0); |
| 198 |
echo "</select>"; |
| 199 |
echo "</div>"; |
| 200 |
return; |
| 201 |
} |
| 202 |
|
| 203 |
// print parent filters |
| 204 |
echo "<!-- UFG DEBUG: " . esc_html(json_encode($ufg_filter_counts)) . " -->"; |
| 205 |
echo "<div class='filter-group ufg-parent-filters'>"; |
| 206 |
echo "<div class='ufg-filter-group-inner'>"; |
| 207 |
|
| 208 |
if (isset($ufg_setting['parent_filters_heading'])) |
| 209 |
$parent_filters_heading = $ufg_setting['parent_filters_heading']; |
| 210 |
else |
| 211 |
$parent_filters_heading = ""; |
| 212 |
if ($parent_filters_heading) { |
| 213 |
echo "<p class='parent-filters-label'>" . esc_html($parent_filters_heading) . "</p>"; |
| 214 |
} |
| 215 |
|
| 216 |
if ($ufg_show_all_button) { |
| 217 |
$ufg_all_icon_html = ""; |
| 218 |
$icon_to_use = !empty($ufg_all_button_icon) ? $ufg_all_button_icon : 'fas fa-filter'; |
| 219 |
if ($ufg_show_filters_icon != 0) { |
| 220 |
$ufg_all_icon_html = "<i class='" . esc_attr($icon_to_use) . "'></i>"; |
| 221 |
} |
| 222 |
echo "<button data-filter='*' data-fname='none' id='1evel1-all' class='ufg-btn ufg-btn-3 filters ufg-all-filter-button ufg-parent-filters ufg-all-filter all ' onclick='return filter(this.id, this.value)' value='*'>" . wp_kses_post($ufg_all_icon_html) . " " . esc_html($ufg_all_button_text) . " (" . intval($ufg_total_image_count) . ") <span class='ufg-active-dot'></span></button>"; |
| 223 |
} |
| 224 |
|
| 225 |
|
| 226 |
|
| 227 |
for ($i = 0; $i <= $filters_count; $i++) { |
| 228 |
/* echo "<pre>"; |
| 229 |
print_r($ufg_filters); |
| 230 |
echo "</pre>"; */ |
| 231 |
if (isset($ufg_filters[$i]->text)) { |
| 232 |
$parent_filter_name = $ufg_filters[$i]->text; |
| 233 |
//filter icon |
| 234 |
$parent_filter_icon = ""; |
| 235 |
if (isset($ufg_filters[$i]->icon)) |
| 236 |
$parent_filter_icon = $ufg_filters[$i]->icon; |
| 237 |
if ($parent_filter_icon != "") |
| 238 |
$parent_icon_html = "<i class='" . esc_attr($parent_filter_icon) . "'></i>"; |
| 239 |
else |
| 240 |
$parent_icon_html = ""; |
| 241 |
if ($ufg_show_filters_icon == 0) { |
| 242 |
$parent_icon_html = ""; |
| 243 |
} |
| 244 |
$parent_filter_class = str_replace(" ", "-", strtolower($ufg_filters[$i]->filterkey)); |
| 245 |
//echo "<button data-filter='.$parent_filter_class' data-fname='.$parent_filter_class' id='1evel1-$parent_filter_class' class='ufg-btn ufg-btn-3 filters ufg-parent-filter-button ufg-parent-filters $parent_filter_class' onclick='return filter(this.id, this.value)' value='$parent_filter_class'>$parent_icon_html $parent_filter_name <span class='ufg-active-dot'></span></button>"; |
| 246 |
echo "<button data-filter='." . esc_attr($parent_filter_class) . "' data-fname='." . esc_attr($parent_filter_class) . "' id='1evel1-" . esc_attr($parent_filter_class) . "' class='ufg-btn ufg-btn-3 filters ufg-parent-filter-button ufg-parent-filters " . esc_attr($parent_filter_class) . "' onclick='return filter(this.id, this.value)' value='" . esc_attr($parent_filter_class) . "'>" . wp_kses_post($parent_icon_html) . " " . esc_html($parent_filter_name) . wp_kses_post($get_count_html($ufg_filters[$i]->filterkey)) . " <span class='ufg-active-dot'></span></button>"; |
| 247 |
} |
| 248 |
} |
| 249 |
echo "</div>"; |
| 250 |
echo "</div>"; |
| 251 |
// print parent filters end |
| 252 |
|
| 253 |
// print child level one filters |
| 254 |
echo "<div class='filter-group ufg-level-one-filters'>"; |
| 255 |
echo "<div class='ufg-filter-group-inner'>"; |
| 256 |
if (isset($ufg_setting['l1_filters_heading'])) |
| 257 |
$l1_filters_heading = $ufg_setting['l1_filters_heading']; |
| 258 |
else |
| 259 |
$l1_filters_heading = ""; |
| 260 |
if ($l1_filters_heading) { |
| 261 |
echo "<p class='level-one-filters-label'>" . esc_html($l1_filters_heading) . "</p>"; |
| 262 |
} |
| 263 |
for ($i = 0; $i <= $filters_count; $i++) { |
| 264 |
|
| 265 |
//check level one children |
| 266 |
if (isset($ufg_filters[$i]->children)) { |
| 267 |
$parent_filter_class = str_replace(" ", "-", strtolower($ufg_filters[$i]->filterkey)); |
| 268 |
$child_count_level_one = count($ufg_filters[$i]->children); |
| 269 |
if ($child_count_level_one) { |
| 270 |
$level_one_array = $ufg_filters[$i]->children; |
| 271 |
for ($j = 0; $j < $child_count_level_one; $j++) { |
| 272 |
$level_one_filter_name = $level_one_array[$j]->text; |
| 273 |
//filter icon |
| 274 |
$level_one_filter_icon = isset($level_one_array[$j]->icon) ? $level_one_array[$j]->icon : ""; |
| 275 |
if ($level_one_filter_icon != "") |
| 276 |
$level_one_filter_icon_html = "<i class='" . esc_attr($level_one_filter_icon) . "'></i>"; |
| 277 |
else |
| 278 |
$level_one_filter_icon_html = ""; |
| 279 |
if ($ufg_show_filters_icon == 0) { |
| 280 |
$level_one_filter_icon_html = ""; |
| 281 |
} |
| 282 |
$level_one_filter_class = str_replace(" ", "-", strtolower($level_one_array[$j]->filterkey)); |
| 283 |
//echo "<button data-filter='.$parent_filter_class .$level_one_filter_class' data-fname='.$level_one_filter_class' id='level2-$level_one_filter_class' class='ufg-btn ufg-btn-3 filters ufg-filter-button ufg-level-one-button $parent_filter_class $level_one_filter_class' onclick='return filter(this.id, this.value)' value='$level_one_filter_class'>$level_one_filter_icon_html $level_one_filter_name <span class='ufg-active-dot'></span></button>"; |
| 284 |
echo "<button data-filter='." . esc_attr($parent_filter_class) . " ." . esc_attr($level_one_filter_class) . "' data-fname='." . esc_attr($level_one_filter_class) . "' id='level2-" . esc_attr($level_one_filter_class) . "' class='ufg-btn ufg-btn-3 filters ufg-filter-button ufg-level-one-button " . esc_attr($parent_filter_class) . " " . esc_attr($level_one_filter_class) . "' onclick='return filter(this.id, this.value)' value='" . esc_attr($level_one_filter_class) . "'>" . wp_kses_post($level_one_filter_icon_html) . " " . esc_html($level_one_filter_name) . wp_kses_post($get_count_html($level_one_array[$j]->filterkey)) . " <span class='ufg-active-dot'></span></button>"; |
| 285 |
} |
| 286 |
} |
| 287 |
} |
| 288 |
} |
| 289 |
echo "</div>"; |
| 290 |
echo "</div>"; |
| 291 |
// print child level one filters end |
| 292 |
|
| 293 |
|
| 294 |
|
| 295 |
|
| 296 |
// print child level two filters |
| 297 |
echo "<div class='filter-group ufg-level-two-filters'>"; |
| 298 |
echo "<div class='ufg-filter-group-inner'>"; |
| 299 |
if (isset($ufg_setting['l2_filters_heading'])) |
| 300 |
$l2_filters_heading = $ufg_setting['l2_filters_heading']; |
| 301 |
else |
| 302 |
$l2_filters_heading = ""; |
| 303 |
if ($l2_filters_heading) { |
| 304 |
echo "<p class='level-two-filters-label'>" . esc_html($l2_filters_heading) . "</p>"; |
| 305 |
} |
| 306 |
for ($i = 0; $i <= $filters_count; $i++) { |
| 307 |
//check level one children |
| 308 |
if (isset($ufg_filters[$i]->children)) { |
| 309 |
$parent_filter_class = str_replace(" ", "-", strtolower($ufg_filters[$i]->filterkey)); |
| 310 |
$child_count_level_one = count($ufg_filters[$i]->children); |
| 311 |
$level_one_array = $ufg_filters[$i]->children; |
| 312 |
for ($j = 0; $j < $child_count_level_one; $j++) { |
| 313 |
$level_one_filter_class = str_replace(" ", "-", strtolower($level_one_array[$j]->filterkey)); |
| 314 |
|
| 315 |
//check level two children |
| 316 |
if (isset($level_one_array[$j]->children)) { |
| 317 |
$child_count_level_two = count($level_one_array[$j]->children); |
| 318 |
$level_two_array = $level_one_array[$j]->children; |
| 319 |
for ($k = 0; $k < $child_count_level_two; $k++) { |
| 320 |
$level_two_filter_name = $level_two_array[$k]->text; |
| 321 |
//filter icon |
| 322 |
$level_two_filter_icon = isset($level_two_array[$k]->icon) ? $level_two_array[$k]->icon : ""; |
| 323 |
if ($level_two_filter_icon != "") |
| 324 |
$level_two_filter_icon_html = "<i class='" . esc_attr($level_two_filter_icon) . "'></i>"; |
| 325 |
else |
| 326 |
$level_two_filter_icon_html = ""; |
| 327 |
if ($ufg_show_filters_icon == 0) { |
| 328 |
$level_two_filter_icon_html = ""; |
| 329 |
} |
| 330 |
$level_two_filter_class = str_replace(" ", "-", strtolower($level_two_array[$k]->filterkey)); |
| 331 |
echo "<button data-filter='." . esc_attr($parent_filter_class) . " ." . esc_attr($level_one_filter_class) . " ." . esc_attr($level_two_filter_class) . "' data-fname='." . esc_attr($level_two_filter_class) . "' id='level3-" . esc_attr($level_two_filter_class) . "' class='ufg-btn ufg-btn-3 filters ufg-filter-button ufg-level-two-button " . esc_attr($parent_filter_class) . " " . esc_attr($level_one_filter_class) . " " . esc_attr($level_two_filter_class) . "' onclick='return filter(this.id, this.value)' value='" . esc_attr($level_two_filter_class) . "'>" . wp_kses_post($level_two_filter_icon_html) . " " . esc_html($level_two_filter_name) . wp_kses_post($get_count_html($level_two_array[$k]->filterkey)) . " <span class='ufg-active-dot'></span></button>"; |
| 332 |
} |
| 333 |
} |
| 334 |
// level two children check end |
| 335 |
} |
| 336 |
|
| 337 |
} |
| 338 |
} |
| 339 |
echo "</div>"; |
| 340 |
echo "</div>"; |
| 341 |
// print child level two filters end |
| 342 |
|
| 343 |
|
| 344 |
// print child level three filters |
| 345 |
echo "<div class='filter-group ufg-level-three-filters'>"; |
| 346 |
echo "<div class='ufg-filter-group-inner'>"; |
| 347 |
|
| 348 |
if (isset($ufg_setting['l3_filters_heading'])) |
| 349 |
$l3_filters_heading = $ufg_setting['l3_filters_heading']; |
| 350 |
else |
| 351 |
$l3_filters_heading = ""; |
| 352 |
if ($l3_filters_heading) { |
| 353 |
echo "<p class='level-three-filters-label'>" . esc_html($l3_filters_heading) . "</p>"; |
| 354 |
} |
| 355 |
|
| 356 |
for ($i = 0; $i <= $filters_count; $i++) { |
| 357 |
//check level one children |
| 358 |
if (isset($ufg_filters[$i]->children)) { |
| 359 |
$child_count_level_one = count($ufg_filters[$i]->children); |
| 360 |
$level_one_array = $ufg_filters[$i]->children; |
| 361 |
for ($j = 0; $j < $child_count_level_one; $j++) { |
| 362 |
|
| 363 |
//check level two children |
| 364 |
if (isset($level_one_array[$j]->children)) { |
| 365 |
$child_count_level_two = count($level_one_array[$j]->children); |
| 366 |
$level_two_array = $level_one_array[$j]->children; |
| 367 |
for ($k = 0; $k < $child_count_level_two; $k++) { |
| 368 |
|
| 369 |
//check level three children |
| 370 |
if (isset($level_two_array[$k]->children)) { |
| 371 |
$child_count_level_three = count($level_two_array[$k]->children); |
| 372 |
$level_three_array = $level_two_array[$k]->children; |
| 373 |
for ($l = 0; $l < $child_count_level_three; $l++) { |
| 374 |
$parent_filter_class = str_replace(" ", "-", strtolower($ufg_filters[$i]->filterkey)); |
| 375 |
$level_one_filter_class = str_replace(" ", "-", strtolower($level_one_array[$j]->filterkey)); |
| 376 |
$level_two_filter_class = str_replace(" ", "-", strtolower($level_two_array[$k]->filterkey)); |
| 377 |
$level_three_filter_name = $level_three_array[$l]->text; |
| 378 |
//filter icon |
| 379 |
$level_three_filter_icon = isset($level_three_array[$l]->icon) ? $level_three_array[$l]->icon : ""; |
| 380 |
if ($level_three_filter_icon != "") |
| 381 |
$level_three_filter_icon_html = "<i class='" . esc_attr($level_three_filter_icon) . "'></i>"; |
| 382 |
else |
| 383 |
$level_three_filter_icon_html = ""; |
| 384 |
if ($ufg_show_filters_icon == 0) { |
| 385 |
$level_three_filter_icon_html = ""; |
| 386 |
} |
| 387 |
$level_three_filter_class = str_replace(" ", "-", strtolower($level_three_array[$l]->filterkey)); |
| 388 |
echo "<button data-filter='." . esc_attr($parent_filter_class) . " ." . esc_attr($level_one_filter_class) . " ." . esc_attr($level_two_filter_class) . " ." . esc_attr($level_three_filter_class) . "' data-fname='." . esc_attr($level_three_filter_class) . "' id='level4-" . esc_attr($level_three_filter_class) . "' class='ufg-btn ufg-btn-3 filters ufg-filter-button ufg-level-three-button " . esc_attr($parent_filter_class) . " " . esc_attr($level_one_filter_class) . " " . esc_attr($level_two_filter_class) . " " . esc_attr($level_three_filter_class) . "' onclick='return filter(this.id, this.value)' value='" . esc_attr($level_three_filter_class) . "'>" . wp_kses_post($level_three_filter_icon_html) . " " . esc_html($level_three_filter_name) . wp_kses_post($get_count_html($level_three_array[$l]->filterkey)) . " <span class='ufg-active-dot'></span></button>"; |
| 389 |
} |
| 390 |
} |
| 391 |
// level three children check end |
| 392 |
|
| 393 |
|
| 394 |
} |
| 395 |
} |
| 396 |
// level two children check end |
| 397 |
} |
| 398 |
|
| 399 |
} |
| 400 |
} |
| 401 |
echo "</div>"; |
| 402 |
echo "</div>"; |
| 403 |
// print child level three filters end |
| 404 |
|
| 405 |
|
| 406 |
|
| 407 |
|
| 408 |
|
| 409 |
// print child level four filters |
| 410 |
echo "<div class='filter-group ufg-level-four-filters'>"; |
| 411 |
echo "<div class='ufg-filter-group-inner'>"; |
| 412 |
|
| 413 |
if (isset($ufg_setting['l4_filters_heading'])) |
| 414 |
$l4_filters_heading = $ufg_setting['l4_filters_heading']; |
| 415 |
else |
| 416 |
$l4_filters_heading = ""; |
| 417 |
if ($l4_filters_heading) { |
| 418 |
echo "<p class='level-four-filters-label'>" . esc_html($l4_filters_heading) . "</p>"; |
| 419 |
} |
| 420 |
|
| 421 |
for ($i = 0; $i <= $filters_count; $i++) { |
| 422 |
//check level one children |
| 423 |
if (isset($ufg_filters[$i]->children)) { |
| 424 |
$child_count_level_one = count($ufg_filters[$i]->children); |
| 425 |
$level_one_array = $ufg_filters[$i]->children; |
| 426 |
for ($j = 0; $j < $child_count_level_one; $j++) { |
| 427 |
|
| 428 |
//check level two children |
| 429 |
if (isset($level_one_array[$j]->children)) { |
| 430 |
$child_count_level_two = count($level_one_array[$j]->children); |
| 431 |
$level_two_array = $level_one_array[$j]->children; |
| 432 |
for ($k = 0; $k < $child_count_level_two; $k++) { |
| 433 |
|
| 434 |
//check level three children |
| 435 |
if (isset($level_two_array[$k]->children)) { |
| 436 |
$child_count_level_three = count($level_two_array[$k]->children); |
| 437 |
$level_three_array = $level_two_array[$k]->children; |
| 438 |
for ($l = 0; $l < $child_count_level_three; $l++) { |
| 439 |
$level_three_filter_name = $level_three_array[$l]->text; |
| 440 |
$level_three_filter_class = str_replace(" ", "-", strtolower($level_three_array[$l]->filterkey)); |
| 441 |
|
| 442 |
//check level four children |
| 443 |
if (isset($level_three_array[$l]->children)) { |
| 444 |
$child_count_level_four = count($level_three_array[$l]->children); |
| 445 |
$level_four_array = $level_three_array[$l]->children; |
| 446 |
for ($m = 0; $m < $child_count_level_four; $m++) { |
| 447 |
$parent_filter_class = str_replace(" ", "-", strtolower($ufg_filters[$i]->filterkey)); |
| 448 |
$level_one_filter_class = str_replace(" ", "-", strtolower($level_one_array[$j]->filterkey)); |
| 449 |
$level_two_filter_class = str_replace(" ", "-", strtolower($level_two_array[$k]->filterkey)); |
| 450 |
$level_three_filter_class = str_replace(" ", "-", strtolower($level_three_array[$l]->filterkey)); |
| 451 |
$level_four_filter_name = $level_four_array[$m]->text; |
| 452 |
//filter icon |
| 453 |
$level_four_filter_icon = isset($level_four_array[$m]->icon) ? $level_four_array[$m]->icon : ""; |
| 454 |
if ($level_four_filter_icon != "") |
| 455 |
$level_four_filter_icon_html = "<i class='" . esc_attr($level_four_filter_icon) . "'></i>"; |
| 456 |
else |
| 457 |
$level_four_filter_icon_html = ""; |
| 458 |
if ($ufg_show_filters_icon == 0) { |
| 459 |
$level_four_filter_icon_html = ""; |
| 460 |
} |
| 461 |
$level_four_filter_class = str_replace(" ", "-", strtolower($level_four_array[$m]->filterkey)); |
| 462 |
echo "<button data-filter='." . esc_attr($parent_filter_class) . " ." . esc_attr($level_one_filter_class) . " ." . esc_attr($level_two_filter_class) . " ." . esc_attr($level_three_filter_class) . " ." . esc_attr($level_four_filter_class) . "' data-fname='." . esc_attr($level_four_filter_class) . "' id='level5-" . esc_attr($level_four_filter_class) . "' class='ufg-btn ufg-btn-3 filters ufg-filter-button ufg-level-four-button sub-filter sub-filter-4 " . esc_attr($parent_filter_class) . " " . esc_attr($level_one_filter_class) . " " . esc_attr($level_two_filter_class) . " " . esc_attr($level_three_filter_class) . " " . esc_attr($level_four_filter_class) . "' onclick='return filter(this.id, this.value)' value='" . esc_attr($level_four_filter_class) . "'>" . wp_kses_post($level_four_filter_icon_html) . " " . esc_html($level_four_filter_name) . wp_kses_post($get_count_html($level_four_array[$m]->filterkey)) . " <span class='ufg-active-dot'></span></button>"; |
| 463 |
} |
| 464 |
} |
| 465 |
// level four children check end |
| 466 |
|
| 467 |
|
| 468 |
} |
| 469 |
} |
| 470 |
// level three children check end |
| 471 |
|
| 472 |
|
| 473 |
} |
| 474 |
} |
| 475 |
// level two children check end |
| 476 |
} |
| 477 |
|
| 478 |
} |
| 479 |
} |
| 480 |
echo "</div>"; |
| 481 |
echo "</div>"; |
| 482 |
// print child level four filters end |
| 483 |
|
| 484 |
|
| 485 |
|
| 486 |
|
| 487 |
|
| 488 |
} |
| 489 |
} |
| 490 |
} |
| 491 |
?> |