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 +77 -10 1.1.6 → 1.5.9 View file →
@@ -14,8 +14,11 @@
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
20 +$placeholder = esc_html__($placeholder,'wpdirectorykit');
18 21
19 22 $filter_ids = array();
20 23 if(isset($predefinedfields_query) && !empty($predefinedfields_query[$field_key])) {
21 24 $field_value = intval($predefinedfields_query[$field_key]);
@@ -20,8 +23,12 @@
20 23 if(isset($predefinedfields_query) && !empty($predefinedfields_query[$field_key])) {
21 24 $field_value = intval($predefinedfields_query[$field_key]);
22 25 }
23 26
27 +if(isset($_GET['category_root'])) {
28 + $predefinedfields_query['custom_category_root'] = sanitize_text_field(wp_unslash($_GET['category_root']));
29 +}
30 +
24 31 if(isset($predefinedfields_query) && !empty($predefinedfields_query['custom_category_root'])) {
25 32 $custom_field_value = intval($predefinedfields_query['custom_category_root']);
26 33 global $Winter_MVC_WDK;
27 34 $Winter_MVC_WDK->load_helper('listing');
@@ -26,19 +33,22 @@
26 33 global $Winter_MVC_WDK;
27 34 $Winter_MVC_WDK->load_helper('listing');
28 35 $Winter_MVC_WDK->model('category_m');
29 36 $category = $Winter_MVC_WDK->category_m->get($custom_field_value, TRUE);
30 -
37 +
31 38 /* if root search childs */
32 - if(empty(wmvc_show_data('parent_id', $category, false, TRUE, TRUE))) {
39 + if($category) {
33 40 $filter_ids = wdk_category_get_all_childs($custom_field_value);
34 41 if(!empty($filter_ids)) {
35 - $filter_ids[] = $custom_field_value;
36 -
37 42 if(in_array($field_value, $filter_ids) === FALSE) {
38 43 $field_value = $custom_field_value;
39 44 }
45 + } else {
46 + $filter_ids[] = $custom_field_value;
40 47 }
48 + } else {
49 + /* category missing */
50 + $custom_field_value = null;
41 51 }
42 52 }
43 53
44 54 if(isset($_GET[$field_key])) {
@@ -44,11 +54,17 @@
44 54 if(isset($_GET[$field_key])) {
45 55 $field_value = ($_GET[$field_key]);
46 56 }
47 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 +}
48 62 wdk_search_fields_toggle();
49 63 ?>
50 -
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;?>
51 67 <?php if(wdk_get_option('wdk_multi_categories_search_field_type') == 'wdk_treefield_dropdown'):?>
52 68 <?php
53 69 global $Winter_MVC_WDK;
54 70 $Winter_MVC_WDK->load_helper('listing');
@@ -109,9 +125,29 @@
109 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)); ?>
110 126 wdk_field_id_category">
111 127 <label class="wdk-field-label"><?php echo esc_html(wmvc_show_data('field_label', $field_data)); ?></label>
112 128 <div class="wdk-field-group">
113 - <?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 +
114 150 </div>
115 151 </div>
116 152
117 153 <?php
@@ -131,9 +167,29 @@
131 167
132 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)); ?>">
133 169 <label class="wdk-field-label"><?php echo esc_html(wmvc_show_data('field_label', $field_data)); ?></label>
134 170 <div class="wdk-field-group">
135 - <?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 +
136 192 </div>
137 193 </div>
138 194
139 195 <?php
@@ -145,17 +201,28 @@
145 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)); ?>">
146 202 <label class="wdk-field-label"><?php echo esc_html(wmvc_show_data('field_label', $field_data)); ?></label>
147 203 <div class="wdk-field-group">
148 204 <?php if(wdk_get_option('wdk_multi_categories_search_field_type') == 'select2'):?>
149 - <?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);?>
150 208 <?php elseif(wdk_get_option('wdk_multi_categories_search_field_type') == 'wdk_treefield_checkboxes'):?>
151 209 <?php
152 210 wp_enqueue_style( 'wdk-treefield-checkboxes');
153 211 wp_enqueue_script( 'wdk-treefield-checkboxes');
154 212 ?>
155 - <?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 +
156 219 <?php else:?>
157 - <?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 +
158 225 <?php endif;?>
159 226 </div>
160 227 </div>
161 228 <?php endif;?>