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 / radio.php

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

122 lines 7.9 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 radio buttons.
4 *
5 * This template can be overridden by copying it to yourtheme/filters/radio.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 $rating_slugs = flrt_rating_slugs();
26 $hide_for_apply_button_mode = flrt_check_apply_buttom_mode($set);
27 $is_hide_empty_terms = (isset($set['hide_empty']['value']) && $set['hide_empty']['value'] === 'yes');
28 $parent_filter_apply_button_data = flrt_parent_filter_apply_button_data($filter, $view_args);
29 $parent_filter_apply_class = flrt_parent_filter_apply_class($filter, $view_args, $terms);
30 $isMoreLess = flrtIsMoreLess($filter);
31 $flrt_more_less_count = flrt_more_less_count();
32 $isParentFilter = flrtParentFilter($filter);
33 ?>
34 <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; ?>>
35 <?php flrt_filter_header( $filter, $terms ); // Safe, escaped ?>
36 <div class="<?php echo esc_attr( flrt_filter_content_class( $filter ) ); ?>">
37 <?php flrt_filter_search_field( $filter, $view_args, $terms ); ?>
38 <ul class="wpc-filters-ul-list wpc-filters-radio wpc-filters-list-<?php echo esc_attr( $filter['ID'] ); ?>">
39 <?php if( ! empty( $terms ) || $view_args['ask_to_select_parent'] ):
40 if( $view_args['ask_to_select_parent'] !== false && !$view_args['use_apply_button']) { ?>
41 <li class="wpc-ask-to-parent-display"><?php echo esc_html( $view_args['ask_to_select_parent'] ); ?></li>
42 <?php } else {
43 if( $view_args['ask_to_select_parent'] !== false && $view_args['use_apply_button'] ) { ?>
44 <li class="wpc-ask-to-parent-display"><?php echo esc_html( $view_args['ask_to_select_parent'] ); ?></li>
45 <?php }
46 $hidden_terms_count = 1;
47 foreach ( $terms as $id => $term_object ) {
48 $disabled = 0;
49 $checked = ( in_array( $term_object->slug, $filter['values'] ) ) ? 1 : 0;
50 if ( isset( $term_object->wp_queried ) && $term_object->wp_queried ) {
51 $checked = 1;
52 $disabled = 1;
53 }
54
55 $active_class = $checked ? ' wpc-term-selected' : '';
56 $disabled_class = $disabled ? ' wpc-term-disabled' : '';
57 $link = flrt_get_filtered_term_url($term_object, $filter, $url_manager);
58 $link_attributes = 'href="'.esc_url($link).'"';
59 $link_attributes .= ' class="wpc-filter-link"';
60 $name = ( $disabled > 0 ) ? $filter['e_name'] . '-disabled' : $filter['e_name'];
61 $rating_data = (isset($rating_slugs[$term_object->slug])) ? ' data-rating-num="' . esc_attr($rating_slugs[$term_object->slug]) . '" ' : '';
62 $hidden_class_for_apply_button_mode = '';
63 if($hide_for_apply_button_mode){
64 $hidden_class_for_apply_button_mode = ($term_object->cross_count <= 0 && $is_hide_empty_terms) ? esc_attr(' wpc-term-count-hidden-0') : '';
65 if($term_object->cross_count > 0){
66 $hidden_class_for_apply_button_mode .= esc_attr(' wpc-has-terms');
67 }
68 if($checked){
69 $hidden_class_for_apply_button_mode .= esc_attr(' wpc-term-count-hidden-checked-0');
70 }
71 }
72 $checked_data = ($checked) ? ' data-wpc-was-checked=true' : ' data-wpc-was-checked=false';
73 $show_with_parent_class = '';
74 if (isset($term_object->show_with_parent)) {
75 if ($term_object->show_with_parent === true) {
76 $show_with_parent_class = ' wpc-show-with-parent-true';
77 } else {
78 $show_with_parent_class = ' wpc-show-with-parent-false';
79 }
80 }
81
82 if (!isset($term_object->show_with_parent)) {
83 if ($view_args['ask_to_select_parent'] !== false && $view_args['use_apply_button']) {
84 if ((!$checked)) {
85 $show_with_parent_class = ' wpc-show-with-parent-false';
86 }
87 }
88 }
89 $more_less_hidden_class = '';
90 if ( $isMoreLess ) {
91 $is_visible = ! $isParentFilter || ( isset( $term_object->show_with_parent ) && $term_object->show_with_parent === true ) || !isset( $term_object->show_with_parent );
92 $has_results = ! $is_hide_empty_terms || $term_object->cross_count > 0;
93
94 if ( $is_visible && $has_results ) {
95 if ( $hidden_terms_count <= $flrt_more_less_count ) {
96 $more_less_hidden_class = ' wpc-not-hidden-term';
97 }
98 $hidden_terms_count++;
99 }
100 }
101 ?>
102 <li class="wpc-radio-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); ?><?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); ?>">
103 <div class="wpc-term-item-content-wrapper">
104 <input <?php checked( 1, $checked ); disabled( 1, $disabled ) ?> type="radio" data-wpc-link="<?php echo esc_url( $link ); ?>" name="<?php echo esc_attr( $name ); ?>" id="<?php flrt_term_id('radio', $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;?><?php echo esc_attr($checked_data);?> />
105 <label for="<?php flrt_term_id('radio', $filter, $id); ?>">
106 <?php
107
108 /**
109 * Allow developers to change filter terms html
110 */
111 echo apply_filters( 'wpc_filters_radio_term_html', '<a '.$link_attributes.'>'.$term_object->name.'</a>', $link_attributes, $term_object, $filter );
112
113 ?><?php flrt_filter_count( $term_object, $set['show_count']['value'] ); ?></label></div></li>
114 <?php } /* end foreach */ ?>
115 <?php } /* end if ask to select parent */ ?>
116 <?php else:
117 flrt_filter_no_terms_message();
118 endif;
119 ?> </ul>
120 <?php flrt_filter_more_less( $filter ); ?>
121 </div>
122 </div>