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 | src/Walkers/WalkerCheckbox.php +88 -5 1.9.2.11.9.7 View file →
@@ -86,9 +86,8 @@
86 86 * @param array $args Optional. An array of arguments. See wp_list_categories(). Default empty array.
87 87 * @param int $id Optional. ID of the current category. Default 0.
88 88 */
89 89 public function start_el( &$output, $term, $depth = 0, $args = array(), $id = 0 ) {
90 -
91 90 $term_name = esc_attr( $term->name );
92 91 $url_manager = $args['url_manager'];
93 92 $filter = $args['filter'];
94 93 $checked = ( in_array( $term->slug, $filter['values'] ) ) ? 1 : 0;
@@ -108,9 +107,10 @@
108 107 return;
109 108 }
110 109
111 110 $atts = array();
112 - $atts['href'] = $url_manager->getTermUrl( $term->slug, $filter['e_name'], $filter['entity'] );
111 + $atts['href'] = flrt_get_filtered_term_url($term, $filter, $url_manager);
112 +
113 113 $atts['class'] = 'wpc-filter-link';
114 114
115 115 $attributes = '';
116 116 foreach ( $atts as $attr => $value ) {
@@ -124,9 +124,45 @@
124 124
125 125 if ( isset( $args['set']['show_count']['value'] ) && $args['set']['show_count']['value'] === 'yes' ) {
126 126 $link .= flrt_filter_get_count( $term );
127 127 }
128 + $is_hide_empty_terms = (isset($args['set']['hide_empty']['value']) && $args['set']['hide_empty']['value'] === 'yes');
129 + $hide_for_apply_button_mode = flrt_check_apply_buttom_mode($args['set']);
128 130
131 + $show_with_parent_class = '';
132 + $isShowWithParentClass = false;
133 + if(isset($term->show_with_parent)) {
134 + if($term->show_with_parent === true){
135 + $isShowWithParentClass = true;
136 + $show_with_parent_class = 'wpc-show-with-parent-true';
137 + }else{
138 + $show_with_parent_class = 'wpc-show-with-parent-false';
139 + }
140 + }
141 +
142 + if (!isset($term->show_with_parent)) {
143 + if ($args['ask_to_select_parent'] !== false && $args['use_apply_button']) {
144 + if ((!$checked)) {
145 + $show_with_parent_class = 'wpc-show-with-parent-false';
146 + }
147 + }
148 + }
149 +
150 +
151 + $hidden_class_for_apply_button_mode = '';
152 + $more_less_hidden_class = '';
153 + if ($args['isMoreLess']) {
154 + if (!empty($term->apply_button_style) && $term->apply_button_style === true) {
155 + $more_less_hidden_class = 'wpc-not-hidden-term';
156 + }
157 + }
158 + if($hide_for_apply_button_mode){
159 + $hidden_class_for_apply_button_mode = ($term->cross_count <= 0 && $is_hide_empty_terms) ? esc_attr(' wpc-term-count-hidden-0') : '';
160 + if($checked){
161 + $hidden_class_for_apply_button_mode .= esc_attr('wpc-term-count-hidden-checked-0');
162 + }
163 + }
164 +
129 165 $output .= "\t<li";
130 166 $cross_count = isset( $term->cross_count ) ? esc_attr( $term->cross_count ) : '';
131 167
132 168 $css_classes = array(
@@ -132,9 +168,12 @@
132 168 $css_classes = array(
133 169 0 => 'wpc-checkbox-item',
134 170 1 => 'wpc-term-item',
135 171 3 => 'wpc-term-count-' . $cross_count,
136 - 4 => 'wpc-term-id-'.$id
172 + 4 => 'wpc-term-id-'.$id,
173 + 5 => $hidden_class_for_apply_button_mode,
174 + 6 => $more_less_hidden_class,
175 + 7 => esc_attr($show_with_parent_class),
137 176 );
138 177
139 178 if( $this->max_depth > 0 ) {
140 179 $visibility_class = flrt_get_status_css_class( $id, FLRT_HIERARCHY_LIST_COOKIE_NAME );
@@ -176,12 +215,16 @@
176 215
177 216 $css_classes = implode( ' ', $css_classes );
178 217 $css_classes = $css_classes ? ' class="' . esc_attr( $css_classes ) . '"' : '';
179 218
219 + $rating_slugs = flrt_rating_slugs();
220 +
221 + $rating_data = (isset($rating_slugs[$term->slug])) ? ' data-rating-num="' . esc_attr($rating_slugs[$term->slug]) . '" ' : '';
222 +
180 223 $output .= $css_classes;
181 224 $output .= ' id="'.flrt_term_id('term', $filter, $id, false).'">';
182 - $output .= '<div class="wpc-term-item-content-wrapper"><input '.checked( 1, $checked, false ).' '.disabled( 1, $disabled, false ).' type="checkbox" data-wpc-link="'.esc_url($atts['href']).'"';
183 - $output .= ' id="'.flrt_term_id('checkbox', $filter, $id, false).'" />'."\n";
225 + $output .= '<div class="wpc-term-item-content-wrapper"><input '.checked( 1, $checked, false ).' '.disabled( 1, $disabled, false ).' type="checkbox" data-wpc-link="'.esc_url($atts['href']).'" data-wpc-e-name="'.esc_attr($filter['e_name']).'" data-wpc-slug="'.esc_attr($term->slug).'" data-term-id="' . esc_attr($id) . '"';
226 + $output .= ' id="'.flrt_term_id('checkbox', $filter, $id, false).'"' . $rating_data .' />'."\n";
184 227 $output .= '<label for="'.flrt_term_id('checkbox', $filter, $id, false).'">';
185 228 $output .= "$link\n";
186 229 $output .= "</label>\n";
187 230 $output .= $toggleButton;
@@ -218,11 +261,28 @@
218 261
219 262 $parent_field = $this->db_fields['parent'];
220 263
221 264 // Flat display.
265 + $flrt_more_less_count = flrt_more_less_count();
266 + $isParentFilter = flrtParentFilter($args[0]['filter']);
267 + $hidden_terms_count = 1;
222 268 if ( -1 == $max_depth ) {
223 269 $empty_array = array();
270 +
224 271 foreach ( $elements as $e ) {
272 + if ( $args[0]['isMoreLess'] ) {
273 +
274 + $is_visible = !$isParentFilter || ( isset( $e->show_with_parent ) && $e->show_with_parent === true ) || !isset( $e->show_with_parent );
275 + $has_results = !$args[0]['is_hide_empty_terms'] || $e->cross_count > 0;
276 +
277 + if ( $is_visible && $has_results ) {
278 + if ( $hidden_terms_count <= $flrt_more_less_count ) {
279 + $e->apply_button_style = true;
280 + }
281 + $hidden_terms_count++;
282 + }
283 + }
284 +
225 285 $this->display_element( $e, $empty_array, 1, 0, $args, $output );
226 286 }
227 287 return $output;
228 288 }
@@ -271,8 +331,31 @@
271 331 if ( $root->$parent_field == $e->$parent_field ) {
272 332 $top_level_elements[] = $e;
273 333 } else {
274 334 $children_elements[ $e->$parent_field ][] = $e;
335 + }
336 + }
337 + }
338 +
339 + /*
340 + * Same More/Less marking as in the flat branch above. Only top-level terms
341 + * are counted: the reveal CSS (.wpc-filters-ul-list > li.wpc-not-hidden-term)
342 + * targets direct children of the list, nested children follow their parent.
343 + * Without this, a hierarchical More/Less list renders with all terms hidden
344 + * until JS re-marks them.
345 + */
346 + if ( $args[0]['isMoreLess'] ) {
347 + $has_not_empty_children_flipped = array_flip( $this->has_not_empty_children );
348 +
349 + foreach ( $top_level_elements as $e ) {
350 + $is_visible = !$isParentFilter || ( isset( $e->show_with_parent ) && $e->show_with_parent === true ) || !isset( $e->show_with_parent );
351 + $has_results = !$args[0]['is_hide_empty_terms'] || $e->cross_count > 0 || isset( $has_not_empty_children_flipped[ $e->term_id ] );
352 +
353 + if ( $is_visible && $has_results ) {
354 + if ( $hidden_terms_count <= $flrt_more_less_count ) {
355 + $e->apply_button_style = true;
356 + }
357 + $hidden_terms_count++;
275 358 }
276 359 }
277 360 }
278 361