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 +97 -44 1.6.11.9.7 View file →
@@ -11,31 +11,46 @@
11 11 *
12 12 * @see https://filtereverything.pro/resources/templates-overriding/
13 13 */
14 14
15 -if ( ! defined('WPINC') ) {
16 - wp_die();
15 +if ( ! defined('ABSPATH') ) {
16 + exit;
17 17 }
18 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);
19 35 ?>
20 -<div class="<?php echo flrt_filter_class( $filter ); // Already escaped ?>" data-fid="<?php echo esc_attr( $filter['ID'] ); ?>">
21 - <?php flrt_filter_header( $filter, $terms ); // Safe, escaped ?>
22 - <div class="<?php echo esc_attr( flrt_filter_content_class( $filter ) ); ?>">
23 - <?php if( $filter['search'] === 'yes' && ! empty( $terms ) && $view_args['ask_to_select_parent'] === false ): ?>
24 - <div class="wpc-filter-search-wrapper wpc-filter-search-wrapper-<?php echo esc_attr( $filter['ID'] ); ?>">
25 - <input class="wpc-filter-search-field" type="text" value="" placeholder="<?php esc_html_e('Search', 'filter-everything' ) ?>" />
26 - <button class="wpc-search-clear" type="button" title="<?php esc_html_e('Clear search', 'filter-everything' ) ?>"><span class="wpc-search-clear-icon">&#215;</span></button>
27 - </div>
28 - <?php endif; ?>
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 ); ?>
29 40 <ul class="wpc-filters-ul-list wpc-filters-labels wpc-filters-list-<?php echo esc_attr( $filter['ID'] ); ?>">
30 41 <?php if( ! empty( $terms ) || $view_args['ask_to_select_parent'] ):
31 -
32 - if( $view_args['ask_to_select_parent'] !== false ) { ?>
33 - <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>
34 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;
35 49 foreach ( $terms as $id => $term_object ){
36 50 $disabled = 0;
37 - $checked = ( in_array( $term_object->slug, $filter['values'] ) ) ? 1 : 0;
51 + $checked = ( in_array( $term_object->slug, $filter['values'] ) ) ? 1 : 0;
52 + $image_class = '';
38 53
39 54 if( isset( $term_object->wp_queried ) && $term_object->wp_queried ){
40 55 $checked = 1;
41 56 $disabled = 1;
@@ -42,42 +57,80 @@
42 57 }
43 58
44 59 $active_class = $checked ? ' wpc-term-selected' : '';
45 60 $disabled_class = $disabled ? ' wpc-term-disabled' : '';
46 - $link = $url_manager->getTermUrl( $term_object->slug, $filter['e_name'] );
61 + $link = flrt_get_filtered_term_url($term_object, $filter, $url_manager);
47 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 + }
48 116 ?>
49 - <li class="wpc-label-item wpc-term-item<?php echo esc_attr( $active_class ); ?><?php echo esc_attr( $disabled_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 ); ?>">
50 118 <div class="wpc-term-item-content-wrapper">
51 - <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); ?>" />
52 - <label for="<?php flrt_term_id('checkbox', $filter, $id); ?>">
53 - <span class="wpc-filter-label-wrapper">
54 - <?php
55 - /**
56 - * Allow developers to change filter terms html
57 - */
58 - echo apply_filters( 'wpc_filters_label_term_html', '<a '.$link_attributes.'>'.$term_object->name.'</a>', $link_attributes, $term_object, $filter );
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 );
59 124
60 - ?>&nbsp;<?php flrt_count( $term_object, $set['show_count']['value'] ); // Safe, escaped?>
61 - </span>
62 - </label>
125 + ?><?php flrt_filter_count( $term_object, $set['show_count']['value'] ); // Safe, escaped?></span></label>
63 126 </div>
64 127 </li>
65 - <?php } ?><!-- end foreach -->
66 - <?php } ?>
128 + <?php } /* end foreach */ ?>
129 + <?php } /* end if ask to select parent */ ?>
67 130 <?php else:
68 - if( ! flrt_is_filter_request() ){
69 - ?><li><?php esc_html_e('There are no terms yet', 'filter-everything' );
70 - if( flrt_is_debug_mode() ){
71 - echo '&nbsp;'.flrt_help_tip(
72 - esc_html__('Possible reasons: 1) Filter\'s criteria doesn\'t contain any terms yet and you have to add them 2) Terms may be created, but no one post that should be filtered attached to these terms 3) You excluded all possible terms in Filter\'s options.', 'filter-everything')
73 - );
74 - }
75 - ?></li><?php
76 - }else{
77 - esc_html_e('N/A', 'filter-everything' );
78 - }
79 - ?>
80 - <?php endif; ?><!-- end if -->
81 - </ul>
131 + flrt_filter_no_terms_message();
132 + endif;
133 +?> </ul>
134 + <?php flrt_filter_more_less( $filter ); ?>
82 135 </div>
83 136 </div>