PluginProbe
WP Directory Kit / 1.5.9
WP Directory Kit v1.5.9
1.5.9 1.5.7 1.5.6 1.5.5 1.5.4 1.5.3 trunk 1.1.0 1.1.6 1.1.8 1.2.3 1.2.4 1.2.5 1.2.6 1.2.7 1.2.8 1.2.9 1.3.0 1.3.1 1.3.2 1.3.3 1.3.4 1.3.5 1.3.6 1.3.8 All 37 releases
← All changes | application/views/search_fields/CATEGORY.php +76 -10 1.2.3 → 1.5.9 View file →
@@ -14,8 +14,10 @@
14 14 $field_key = 'search_category';
15 15 $field_attr_id = 'wdk_search_'.wmvc_show_data('idfield', $field_data);
16 16 $placeholder = wmvc_show_data('field_label', $field_data);
17 17 $field_value = '';
18 +// Dynamic field values are registered in the translation catalog separately.
19 +// phpcs:ignore WordPress.WP.I18n.NonSingularStringLiteralText
18 20 $placeholder = esc_html__($placeholder,'wpdirectorykit');
19 21
20 22 $filter_ids = array();
21 23 if(isset($predefinedfields_query) && !empty($predefinedfields_query[$field_key])) {
@@ -21,8 +23,12 @@
21 23 if(isset($predefinedfields_query) && !empty($predefinedfields_query[$field_key])) {
22 24 $field_value = intval($predefinedfields_query[$field_key]);
23 25 }
24 26
27 +if(isset($_GET['category_root'])) {
28 + $predefinedfields_query['custom_category_root'] = sanitize_text_field(wp_unslash($_GET['category_root']));
29 +}
30 +
25 31 if(isset($predefinedfields_query) && !empty($predefinedfields_query['custom_category_root'])) {
26 32 $custom_field_value = intval($predefinedfields_query['custom_category_root']);
27 33 global $Winter_MVC_WDK;
28 34 $Winter_MVC_WDK->load_helper('listing');
@@ -27,19 +33,22 @@
27 33 global $Winter_MVC_WDK;
28 34 $Winter_MVC_WDK->load_helper('listing');
29 35 $Winter_MVC_WDK->model('category_m');
30 36 $category = $Winter_MVC_WDK->category_m->get($custom_field_value, TRUE);
31 -
37 +
32 38 /* if root search childs */
33 - if(empty(wmvc_show_data('parent_id', $category, false, TRUE, TRUE))) {
39 + if($category) {
34 40 $filter_ids = wdk_category_get_all_childs($custom_field_value);
35 41 if(!empty($filter_ids)) {
36 - $filter_ids[] = $custom_field_value;
37 -
38 42 if(in_array($field_value, $filter_ids) === FALSE) {
39 43 $field_value = $custom_field_value;
40 44 }
45 + } else {
46 + $filter_ids[] = $custom_field_value;
41 47 }
48 + } else {
49 + /* category missing */
50 + $custom_field_value = null;
42 51 }
43 52 }
44 53
45 54 if(isset($_GET[$field_key])) {
@@ -45,11 +54,17 @@
45 54 if(isset($_GET[$field_key])) {
46 55 $field_value = ($_GET[$field_key]);
47 56 }
48 57
58 +$hide_fields = '';
59 +if(wmvc_show_data('search_type_tree_hide', $field_data)) {
60 + $hide_fields = wmvc_show_data('search_type_tree_hide', $field_data);
61 +}
49 62 wdk_search_fields_toggle();
50 63 ?>
51 -
64 + <?php if(isset($custom_field_value)):?>
65 + <input type="hidden" name="search_category[]" value="<?php echo esc_attr($custom_field_value);?>">
66 +<?php endif;?>
52 67 <?php if(wdk_get_option('wdk_multi_categories_search_field_type') == 'wdk_treefield_dropdown'):?>
53 68 <?php
54 69 global $Winter_MVC_WDK;
55 70 $Winter_MVC_WDK->load_helper('listing');
@@ -110,9 +125,29 @@
110 125 <div data-level="<?php echo esc_attr($level);?>" data-field="<?php echo esc_attr($field_key); ?>" class="wdk-field wdk-col wdk_treefield_dropdown <?php echo esc_attr(wmvc_show_data('field_type', $field_data)); ?> <?php echo esc_attr(wmvc_show_data('class', $field_data)); ?>
111 126 wdk_field_id_category">
112 127 <label class="wdk-field-label"><?php echo esc_html(wmvc_show_data('field_label', $field_data)); ?></label>
113 128 <div class="wdk-field-group">
114 - <?php echo wmvc_select_option('category_'.$level, $values_list, $category, 'class="wdk-control"');?>
129 + <?php
130 + echo wp_kses(
131 + wmvc_select_option('category_'.$level, $values_list, $category, 'class="wdk-control"'),
132 + array(
133 + 'select' => array(
134 + 'id' => true,
135 + 'name' => true,
136 + 'class' => true,
137 + 'style' => true,
138 + 'multiple' => true,
139 + 'size' => true,
140 + ),
141 + 'option' => array(
142 + 'value' => true,
143 + 'selected' => true,
144 + 'disabled' => true,
145 + ),
146 + )
147 + );
148 + ?>
149 +
115 150 </div>
116 151 </div>
117 152
118 153 <?php
@@ -132,9 +167,29 @@
132 167
133 168 <div data-level="<?php echo esc_attr($level);?>" data-field="<?php echo esc_attr($field_key); ?>" class="wdk-field wdk-col wdk_treefield_dropdown <?php echo esc_attr(wmvc_show_data('field_type', $field_data)); ?> <?php echo esc_attr(wmvc_show_data('class', $field_data)); ?>">
134 169 <label class="wdk-field-label"><?php echo esc_html(wmvc_show_data('field_label', $field_data)); ?></label>
135 170 <div class="wdk-field-group">
136 - <?php echo wmvc_select_option('category_'.$level, $values_list, NULL, 'class="wdk-control"');?>
171 + <?php
172 + echo wp_kses(
173 + wmvc_select_option('category_'.$level, $values_list, NULL, 'class="wdk-control"'),
174 + array(
175 + 'select' => array(
176 + 'id' => true,
177 + 'name' => true,
178 + 'class' => true,
179 + 'style' => true,
180 + 'multiple' => true,
181 + 'size' => true,
182 + ),
183 + 'option' => array(
184 + 'value' => true,
185 + 'selected' => true,
186 + 'disabled' => true,
187 + ),
188 + )
189 + );
190 + ?>
191 +
137 192 </div>
138 193 </div>
139 194
140 195 <?php
@@ -146,17 +201,28 @@
146 201 <div class="wdk-field wdk-col <?php echo esc_attr(wmvc_show_data('field_type', $field_data)); ?> <?php echo esc_attr(wmvc_show_data('class', $field_data)); ?>">
147 202 <label class="wdk-field-label"><?php echo esc_html(wmvc_show_data('field_label', $field_data)); ?></label>
148 203 <div class="wdk-field-group">
149 204 <?php if(wdk_get_option('wdk_multi_categories_search_field_type') == 'select2'):?>
150 - <?php echo wdk_treefield_select_ajax ($field_key.'[]', 'category_m', $field_value, 'category_title','idcategory', '', __('All Categories', 'wpdirectorykit'), $filter_ids);?>
205 + <?php
206 + // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped, WordPress.WP.I18n.NonSingularStringLiteralText
207 + echo wdk_treefield_select_ajax ($field_key.'[]', 'category_m', $field_value, 'category_title','idcategory', '', __('All Categories', 'wpdirectorykit'), $filter_ids);?>
151 208 <?php elseif(wdk_get_option('wdk_multi_categories_search_field_type') == 'wdk_treefield_checkboxes'):?>
152 209 <?php
153 210 wp_enqueue_style( 'wdk-treefield-checkboxes');
154 211 wp_enqueue_script( 'wdk-treefield-checkboxes');
155 212 ?>
156 - <?php echo wdk_treefield_option_checkboxes ('search_category', 'category_m', $field_value, 'category_title', '', __('All Categories', 'wpdirectorykit'), $filter_ids);?>
213 + <?php
214 + // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped, WordPress.WP.I18n.NonSingularStringLiteralText
215 + echo wdk_treefield_option_checkboxes('search_category', 'category_m', $field_value, 'category_title', '', __('All Categories', 'wpdirectorykit'), $filter_ids);
216 +
217 + ?>
218 +
157 219 <?php else:?>
158 - <?php echo wdk_treefield_option ('search_category', 'category_m', $field_value, 'category_title', '', __('All Categories', 'wpdirectorykit'), $filter_ids);?>
220 + <?php
221 + // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped, WordPress.WP.I18n.NonSingularStringLiteralText
222 + echo wdk_treefield_option('search_category', 'category_m', $field_value, 'category_title', '', __('All Categories', 'wpdirectorykit'), $filter_ids, FALSE, '', $hide_fields);
223 + ?>
224 +
159 225 <?php endif;?>
160 226 </div>
161 227 </div>
162 228 <?php endif;?>