| @@ -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])) { |
| @@ -22,9 +24,9 @@ | ||
| 22 | 24 | $field_value = intval($predefinedfields_query[$field_key]); |
| 23 | 25 | } |
| 24 | 26 | |
| 25 | 27 | if(isset($_GET['category_root'])) { |
| 26 | - $predefinedfields_query['custom_category_root'] = sanitize_text_field($_GET['category_root']); | |
| 28 | + $predefinedfields_query['custom_category_root'] = sanitize_text_field(wp_unslash($_GET['category_root'])); | |
| 27 | 29 | } |
| 28 | 30 | |
| 29 | 31 | if(isset($predefinedfields_query) && !empty($predefinedfields_query['custom_category_root'])) { |
| 30 | 32 | $custom_field_value = intval($predefinedfields_query['custom_category_root']); |
| @@ -31,10 +33,11 @@ | ||
| 31 | 33 | global $Winter_MVC_WDK; |
| 32 | 34 | $Winter_MVC_WDK->load_helper('listing'); |
| 33 | 35 | $Winter_MVC_WDK->model('category_m'); |
| 34 | 36 | $category = $Winter_MVC_WDK->category_m->get($custom_field_value, TRUE); |
| 37 | + | |
| 35 | 38 | /* if root search childs */ |
| 36 | - if(isset($_GET['category_root']) || empty(wmvc_show_data('parent_id', $category, false, TRUE, TRUE))) { | |
| 39 | + if($category) { | |
| 37 | 40 | $filter_ids = wdk_category_get_all_childs($custom_field_value); |
| 38 | 41 | if(!empty($filter_ids)) { |
| 39 | 42 | if(in_array($field_value, $filter_ids) === FALSE) { |
| 40 | 43 | $field_value = $custom_field_value; |
| @@ -41,8 +44,11 @@ | ||
| 41 | 44 | } |
| 42 | 45 | } else { |
| 43 | 46 | $filter_ids[] = $custom_field_value; |
| 44 | 47 | } |
| 48 | + } else { | |
| 49 | + /* category missing */ | |
| 50 | + $custom_field_value = null; | |
| 45 | 51 | } |
| 46 | 52 | } |
| 47 | 53 | |
| 48 | 54 | if(isset($_GET[$field_key])) { |
| @@ -119,9 +125,29 @@ | ||
| 119 | 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)); ?> |
| 120 | 126 | wdk_field_id_category"> |
| 121 | 127 | <label class="wdk-field-label"><?php echo esc_html(wmvc_show_data('field_label', $field_data)); ?></label> |
| 122 | 128 | <div class="wdk-field-group"> |
| 123 | - <?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 | + | |
| 124 | 150 | </div> |
| 125 | 151 | </div> |
| 126 | 152 | |
| 127 | 153 | <?php |
| @@ -141,9 +167,29 @@ | ||
| 141 | 167 | |
| 142 | 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)); ?>"> |
| 143 | 169 | <label class="wdk-field-label"><?php echo esc_html(wmvc_show_data('field_label', $field_data)); ?></label> |
| 144 | 170 | <div class="wdk-field-group"> |
| 145 | - <?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 | + | |
| 146 | 192 | </div> |
| 147 | 193 | </div> |
| 148 | 194 | |
| 149 | 195 | <?php |
| @@ -155,17 +201,28 @@ | ||
| 155 | 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)); ?>"> |
| 156 | 202 | <label class="wdk-field-label"><?php echo esc_html(wmvc_show_data('field_label', $field_data)); ?></label> |
| 157 | 203 | <div class="wdk-field-group"> |
| 158 | 204 | <?php if(wdk_get_option('wdk_multi_categories_search_field_type') == 'select2'):?> |
| 159 | - <?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);?> | |
| 160 | 208 | <?php elseif(wdk_get_option('wdk_multi_categories_search_field_type') == 'wdk_treefield_checkboxes'):?> |
| 161 | 209 | <?php |
| 162 | 210 | wp_enqueue_style( 'wdk-treefield-checkboxes'); |
| 163 | 211 | wp_enqueue_script( 'wdk-treefield-checkboxes'); |
| 164 | 212 | ?> |
| 165 | - <?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 | + | |
| 166 | 219 | <?php else:?> |
| 167 | - <?php echo wdk_treefield_option ('search_category', 'category_m', $field_value, 'category_title', '', __('All Categories', 'wpdirectorykit'), $filter_ids, FALSE, '', $hide_fields);?> | |
| 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 | + | |
| 168 | 225 | <?php endif;?> |
| 169 | 226 | </div> |
| 170 | 227 | </div> |
| 171 | 228 | <?php endif;?> |