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/radio.php +92 -30 1.3.21.9.7 View file →
@@ -1,9 +1,9 @@
1 1 <?php
2 2 /**
3 3 * The Template for displaying filter radio buttons.
4 4 *
5 - * This template can be overridden by copying it to yourtheme/filter/radio.php
5 + * This template can be overridden by copying it to yourtheme/filters/radio.php
6 6 *
7 7 * $set - array, with the Filter Set parameters
8 8 * $filter - array, with the Filter parameters
9 9 * $url_manager - object, of the UrlManager PHP class
@@ -11,30 +11,100 @@
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 +$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);
19 33 ?>
20 -<div class="<?php echo flrt_filter_class( $filter ); // Already escaped ?>" data-fid="<?php echo esc_attr( $filter['ID'] ); ?>">
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; ?>>
21 35 <?php flrt_filter_header( $filter, $terms ); // Safe, escaped ?>
22 36 <div class="<?php echo esc_attr( flrt_filter_content_class( $filter ) ); ?>">
23 - <ul class="wpc-filters-ul-list wpc-filters-radio">
24 - <?php if( ! empty( $terms ) ): ?>
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 + }
25 54
26 - <?php foreach ( $terms as $id => $term_object ){
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 + }
27 81
28 - $checked = ( in_array( $term_object->slug, $filter['values'] ) ) ? 1 : 0;
29 - $active_class = $checked ? ' wpc-term-selected' : '';
30 - $link = $url_manager->getTermUrl( $term_object->slug, $filter['e_name'] );
31 - $link_attributes = 'href="'.esc_url($link).'"';
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 + }
32 101 ?>
33 - <li class="wpc-radio-item wpc-term-item<?php echo esc_attr( $active_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); ?>">
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); ?>">
34 103 <div class="wpc-term-item-content-wrapper">
35 - <input <?php checked( 1, $checked ); ?> type="radio" data-wpc-link="<?php echo esc_url( $link ); ?>" name="<?php echo esc_attr($filter['e_name']); ?>" id="<?php flrt_term_id('radio', $filter, $id); ?>"/>
36 - <label for="<?php flrt_term_id('radio', $filter, $id); ?>"><?php
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
37 107
38 108 /**
39 109 * Allow developers to change filter terms html
40 110 */
@@ -39,22 +109,14 @@
39 109 * Allow developers to change filter terms html
40 110 */
41 111 echo apply_filters( 'wpc_filters_radio_term_html', '<a '.$link_attributes.'>'.$term_object->name.'</a>', $link_attributes, $term_object, $filter );
42 112
43 - ?>&nbsp;<?php flrt_count( $term_object, $set['show_count']['value'] ); ?>
44 - </label>
45 - </div>
46 - </li>
47 - <?php } ?><!-- end foreach -->
48 -
49 - <?php else: ?>
50 - <li><?php esc_html_e('There are no terms yet', 'filter-everything' );
51 - if( flrt_is_debug_mode() ){
52 - echo '&nbsp;'.flrt_help_tip(
53 - 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')
54 - );
55 - }
56 - ?></li>
57 - <?php endif; ?><!-- end if -->
58 - </ul>
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 ); ?>
59 121 </div>
60 122 </div>