PluginProbe
Filter Everything — WordPress & WooCommerce Filters / trunk
Filter Everything — WordPress & WooCommerce Filters vtrunk
1.9.6 1.9.5 1.9.4 1.9.3 1.9.2.2 1.9.2.1 trunk 1.2.1 1.2.3 1.2.4 1.2.5 1.3.0 1.3.1 1.3.2 1.4.1 1.4.4 1.4.5 1.4.8 1.4.9 1.5.0 1.5.1 1.6.0 1.6.1 1.6.2 1.6.3 All 51 releases
filter-everything / views / frontend / labels.php

labels.php in Filter Everything — WordPress & WooCommerce Filters trunk, at views/frontend/labels.php

136 lines 8.6 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * The Template for displaying filter labels.
4 *
5 * This template can be overridden by copying it to yourtheme/filters/labels.php.
6 *
7 * $set - array, with the Filter Set parameters
8 * $filter - array, with the Filter parameters
9 * $url_manager - object, of the UrlManager PHP class
10 * $terms - array, with objects of all filter terms except excluded
11 *
12 * @see https://filtereverything.pro/resources/templates-overriding/
13 */
14
15 if ( ! defined('ABSPATH') ) {
16 exit;
17 }
18
19 $args = [
20 'hide' => $view_args['ask_to_select_parent'],
21 'use_apply_button' => $view_args['use_apply_button'],
22 'hide_empty' => $set['hide_empty']['value'],
23 'hide_empty_filter' => isset($set['hide_empty_filter']['value']) ? $set['hide_empty_filter']['value'] : '',
24 ];
25
26 $is_brand = ( in_array( $filter['e_name'], flrt_brand_filter_entities() ) );
27 $rating_slugs = flrt_rating_slugs();
28 $hide_for_apply_button_mode = flrt_check_apply_buttom_mode($set);
29 $is_hide_empty_terms = (isset($set['hide_empty']['value']) && $set['hide_empty']['value'] === 'yes');
30 $parent_filter_apply_button_data = flrt_parent_filter_apply_button_data($filter, $view_args);
31 $parent_filter_apply_class = flrt_parent_filter_apply_class($filter, $view_args, $terms);
32 $isMoreLess = flrtIsMoreLess($filter);
33 $flrt_more_less_count = flrt_more_less_count();
34 $isParentFilter = flrtParentFilter($filter);
35 ?>
36 <div class="<?php echo flrt_filter_class( $filter, [], $terms, $args ); // Already escaped ?><?php echo $parent_filter_apply_class; ?>" data-fid="<?php echo esc_attr( $filter['ID'] ); ?>" data-filter-e-name="<?php echo esc_attr($filter['e_name']); ?>"<?php echo $parent_filter_apply_button_data; ?>><?php
37 flrt_filter_header( $filter, $terms ); // Safe, escaped
38 ?><div class="<?php echo esc_attr( flrt_filter_content_class( $filter ) ); ?>">
39 <?php flrt_filter_search_field( $filter, $view_args, $terms ); ?>
40 <ul class="wpc-filters-ul-list wpc-filters-labels wpc-filters-list-<?php echo esc_attr( $filter['ID'] ); ?>">
41 <?php if( ! empty( $terms ) || $view_args['ask_to_select_parent'] ):
42 if( $view_args['ask_to_select_parent'] !== false && !$view_args['use_apply_button'] ) { ?>
43 <li class="wpc-ask-to-parent-display"><?php echo esc_html( $view_args['ask_to_select_parent'] ); ?></li>
44 <?php } else {
45 if( $view_args['ask_to_select_parent'] !== false && $view_args['use_apply_button'] ) { ?>
46 <li class="wpc-ask-to-parent-display"><?php echo esc_html( $view_args['ask_to_select_parent'] ); ?></li>
47 <?php }
48 $hidden_terms_count = 1;
49 foreach ( $terms as $id => $term_object ){
50 $disabled = 0;
51 $checked = ( in_array( $term_object->slug, $filter['values'] ) ) ? 1 : 0;
52 $image_class = '';
53
54 if( isset( $term_object->wp_queried ) && $term_object->wp_queried ){
55 $checked = 1;
56 $disabled = 1;
57 }
58
59 $active_class = $checked ? ' wpc-term-selected' : '';
60 $disabled_class = $disabled ? ' wpc-term-disabled' : '';
61 $link = flrt_get_filtered_term_url($term_object, $filter, $url_manager);
62 $link_attributes = 'href="'.esc_url($link).'"';
63 $link_attributes .= ' class="wpc-filter-link"';
64
65 if ( $is_brand ) {
66 $image_class = '';
67 // Single source of truth for "does this term have a brand
68 // image" — the same helper the logo renderer uses, so the
69 // wpc-term-has-image class can never diverge from the markup
70 if ( flrt_get_term_brand_image( $term_object->term_id, $filter ) ){
71 $image_class = ' wpc-term-has-image';
72 }
73 }
74
75 $is_rating = false;
76 if( mb_strpos( $term_object->slug, 'rated-' ) !== false) $is_rating = true;
77 $rating_data = (isset($rating_slugs[$term_object->slug])) ? ' data-rating-num="' . esc_attr($rating_slugs[$term_object->slug]) . '" ' : '';
78 $show_with_parent_class = '';
79 if(isset($term_object->show_with_parent)) {
80 if($term_object->show_with_parent === true){
81 $show_with_parent_class = ' wpc-show-with-parent-true';
82 }else{
83 $show_with_parent_class = ' wpc-show-with-parent-false';
84 }
85 }
86
87 if (!isset($term_object->show_with_parent)) {
88 if ($view_args['ask_to_select_parent'] !== false && $view_args['use_apply_button']) {
89 if ((!$checked)) {
90 $show_with_parent_class = ' wpc-show-with-parent-false';
91 }
92 }
93 }
94 $hidden_class_for_apply_button_mode = '';
95 if($hide_for_apply_button_mode){
96 $hidden_class_for_apply_button_mode = ($term_object->cross_count <= 0 && $is_hide_empty_terms) ? esc_attr(' wpc-term-count-hidden-0') : '';
97 if($term_object->cross_count > 0){
98 $hidden_class_for_apply_button_mode .= esc_attr(' wpc-has-terms');
99 }
100 if($checked){
101 $hidden_class_for_apply_button_mode .= esc_attr(' wpc-term-count-hidden-checked-0');
102 }
103 }
104 $more_less_hidden_class = '';
105 if ( $isMoreLess ) {
106 $is_visible = ! $isParentFilter || ( isset( $term_object->show_with_parent ) && $term_object->show_with_parent === true ) || !isset($term_object->show_with_parent);
107 $has_results = ! $is_hide_empty_terms || $term_object->cross_count > 0;
108
109 if ( $is_visible && $has_results ) {
110 if ( $hidden_terms_count <= $flrt_more_less_count ) {
111 $more_less_hidden_class = ' wpc-not-hidden-term';
112 }
113 $hidden_terms_count++;
114 }
115 }
116 ?>
117 <li class="wpc-label-item wpc-term-item<?php echo esc_attr( $active_class ); ?><?php echo esc_attr( $disabled_class ); ?><?php echo esc_attr( $image_class ); ?> wpc-term-count-<?php echo esc_attr( $term_object->cross_count ); ?> wpc-term-id-<?php echo esc_attr( $id ); ?><?php echo $hidden_class_for_apply_button_mode; ?><?php echo esc_attr($show_with_parent_class); ?><?php echo esc_attr( $more_less_hidden_class ); ?>" id="<?php flrt_term_id('term', $filter, $id ); ?>">
118 <div class="wpc-term-item-content-wrapper">
119 <input class="wpc-label-input" <?php checked( 1, $checked ); disabled( 1, $disabled ); ?> type="checkbox" data-wpc-link="<?php echo esc_url( $link ); ?>" id="<?php flrt_term_id('checkbox', $filter, $id); ?>" data-wpc-e-name="<?php echo esc_attr($filter['e_name']); ?>" data-wpc-slug="<?php echo esc_attr($term_object->slug); ?>" data-term-id="<?php echo esc_attr($id); ?>"<?php echo $rating_data;?>/><label for="<?php flrt_term_id('checkbox', $filter, $id); ?>"><span class="wpc-filter-label-wrapper<?php echo ($is_rating) ? ' wpc-filter-label-stars-wrapper' : ''; ?>"><?php
120 /**
121 * Allow developers to change filter terms html
122 */
123 echo apply_filters( 'wpc_filters_label_term_html', '<a '.$link_attributes.'>'.$term_object->name.'</a>', $link_attributes, $term_object, $filter );
124
125 ?><?php flrt_filter_count( $term_object, $set['show_count']['value'] ); // Safe, escaped?></span></label>
126 </div>
127 </li>
128 <?php } /* end foreach */ ?>
129 <?php } /* end if ask to select parent */ ?>
130 <?php else:
131 flrt_filter_no_terms_message();
132 endif;
133 ?> </ul>
134 <?php flrt_filter_more_less( $filter ); ?>
135 </div>
136 </div>