PluginProbe
Filter Everything — WordPress & WooCommerce Filters / 1.9.7
Filter Everything — WordPress & WooCommerce Filters v1.9.7
1.9.7 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 All 52 releases
← All changes | views/frontend/labels.php +64 -18 1.9.2.21.9.7 View file →
@@ -16,32 +16,37 @@
16 16 exit;
17 17 }
18 18
19 19 $args = [
20 - 'hide' => $view_args['ask_to_select_parent']
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'] : '',
21 24 ];
22 25
23 26 $is_brand = ( in_array( $filter['e_name'], flrt_brand_filter_entities() ) );
24 -
25 -if ( $is_brand ){
26 - $image_meta_key = 'image';
27 - if ( $filter['e_name'] === 'pwb-brand' ) {
28 - $image_meta_key = 'pwb_brand_image';
29 - } else if ( in_array( $filter['e_name'], ['yith_product_brand', 'product_brand'] ) ) {
30 - $image_meta_key = 'thumbnail_id';
31 - }
32 -}
33 -
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);
34 35 ?>
35 -<div class="<?php echo flrt_filter_class( $filter, [], $terms, $args ); // Already escaped ?>" data-fid="<?php echo esc_attr( $filter['ID'] ); ?>"><?php
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
36 37 flrt_filter_header( $filter, $terms ); // Safe, escaped
37 38 ?><div class="<?php echo esc_attr( flrt_filter_content_class( $filter ) ); ?>">
38 39 <?php flrt_filter_search_field( $filter, $view_args, $terms ); ?>
39 40 <ul class="wpc-filters-ul-list wpc-filters-labels wpc-filters-list-<?php echo esc_attr( $filter['ID'] ); ?>">
40 41 <?php if( ! empty( $terms ) || $view_args['ask_to_select_parent'] ):
41 - if( $view_args['ask_to_select_parent'] !== false ) { ?>
42 - <li><?php echo esc_html( $view_args['ask_to_select_parent'] ); ?></li>
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>
43 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;
44 49 foreach ( $terms as $id => $term_object ){
45 50 $disabled = 0;
46 51 $checked = ( in_array( $term_object->slug, $filter['values'] ) ) ? 1 : 0;
47 52 $image_class = '';
@@ -52,15 +57,18 @@
52 57 }
53 58
54 59 $active_class = $checked ? ' wpc-term-selected' : '';
55 60 $disabled_class = $disabled ? ' wpc-term-disabled' : '';
56 - $link = $url_manager->getTermUrl( $term_object->slug, $filter['e_name'], $filter['entity'] );
61 + $link = flrt_get_filtered_term_url($term_object, $filter, $url_manager);
57 62 $link_attributes = 'href="'.esc_url($link).'"';
58 63 $link_attributes .= ' class="wpc-filter-link"';
59 64
60 65 if ( $is_brand ) {
61 66 $image_class = '';
62 - if ( get_term_meta( $term_object->term_id, $image_meta_key, true ) ){
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 ) ){
63 71 $image_class = ' wpc-term-has-image';
64 72 }
65 73 }
66 74
@@ -65,13 +73,51 @@
65 73 }
66 74
67 75 $is_rating = false;
68 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 + }
69 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 + }
70 116 ?>
71 - <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 ); ?>" id="<?php flrt_term_id('term', $filter, $id ); ?>">
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 ); ?>">
72 118 <div class="wpc-term-item-content-wrapper">
73 - <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); ?>" /><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
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
74 120 /**
75 121 * Allow developers to change filter terms html
76 122 */
77 123 echo apply_filters( 'wpc_filters_label_term_html', '<a '.$link_attributes.'>'.$term_object->name.'</a>', $link_attributes, $term_object, $filter );