| @@ -21,9 +21,9 @@ | ||
| 21 | 21 | $field_value = intval($predefinedfields_query[$field_key]); |
| 22 | 22 | } |
| 23 | 23 | |
| 24 | 24 | if(isset($_GET['location_root'])) { |
| 25 | - $predefinedfields_query['custom_location_root'] = sanitize_text_field($_GET['location_root']); | |
| 25 | + $predefinedfields_query['custom_location_root'] = sanitize_text_field(wp_unslash($_GET['location_root'])); | |
| 26 | 26 | } |
| 27 | 27 | |
| 28 | 28 | if(isset($predefinedfields_query) && !empty($predefinedfields_query['custom_location_root'])) { |
| 29 | 29 | $custom_field_value = intval($predefinedfields_query['custom_location_root']); |
| @@ -32,9 +32,9 @@ | ||
| 32 | 32 | $Winter_MVC_WDK->model('location_m'); |
| 33 | 33 | $location = $Winter_MVC_WDK->location_m->get($custom_field_value, TRUE); |
| 34 | 34 | |
| 35 | 35 | /* if root search childs */ |
| 36 | - if(isset($_GET['location_root']) || empty(wmvc_show_data('parent_id', $location, false, TRUE, TRUE))) { | |
| 36 | + if($location) { | |
| 37 | 37 | $filter_ids = wdk_location_get_all_childs($custom_field_value); |
| 38 | 38 | if(!empty($filter_ids)) { |
| 39 | 39 | if(in_array($field_value, $filter_ids) === FALSE) { |
| 40 | 40 | $field_value = $custom_field_value; |
| @@ -41,8 +41,11 @@ | ||
| 41 | 41 | } |
| 42 | 42 | } else { |
| 43 | 43 | $filter_ids[] = $custom_field_value; |
| 44 | 44 | } |
| 45 | + } else { | |
| 46 | + /* location missing */ | |
| 47 | + $custom_field_value = null; | |
| 45 | 48 | } |
| 46 | 49 | } |
| 47 | 50 | |
| 48 | 51 | if(isset($_GET[$field_key])) { |
| @@ -126,9 +129,11 @@ | ||
| 126 | 129 | |
| 127 | 130 | <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)); ?>"> |
| 128 | 131 | <label class="wdk-field-label"><?php echo esc_html(wmvc_show_data('field_label', $field_data)); ?></label> |
| 129 | 132 | <div class="wdk-field-group"> |
| 130 | - <?php echo wmvc_select_option('location_'.$level, $values_list, $location, 'class="wdk-control"');?> | |
| 133 | + <?php | |
| 134 | + // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped, WordPress.WP.I18n.NonSingularStringLiteralText | |
| 135 | + echo wmvc_select_option('location_'.$level, $values_list, $location, 'class="wdk-control"');?> | |
| 131 | 136 | </div> |
| 132 | 137 | </div> |
| 133 | 138 | |
| 134 | 139 | <?php |
| @@ -148,9 +153,11 @@ | ||
| 148 | 153 | |
| 149 | 154 | <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)); ?>"> |
| 150 | 155 | <label class="wdk-field-label"><?php echo esc_html(wmvc_show_data('field_label', $field_data)); ?></label> |
| 151 | 156 | <div class="wdk-field-group"> |
| 152 | - <?php echo wmvc_select_option('location_'.$level, $values_list, NULL, 'class="wdk-control"');?> | |
| 157 | + <?php | |
| 158 | + // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped, WordPress.WP.I18n.NonSingularStringLiteralText | |
| 159 | + echo wmvc_select_option('location_'.$level, $values_list, NULL, 'class="wdk-control"');?> | |
| 153 | 160 | </div> |
| 154 | 161 | </div> |
| 155 | 162 | |
| 156 | 163 | <?php |
| @@ -163,18 +170,24 @@ | ||
| 163 | 170 | <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)); ?>"> |
| 164 | 171 | <label class="wdk-field-label"><?php echo esc_html(wmvc_show_data('field_label', $field_data)); ?></label> |
| 165 | 172 | <div class="wdk-field-group"> |
| 166 | 173 | <?php if(wdk_get_option('wdk_multi_locations_search_field_type') == 'select2'):?> |
| 167 | - <?php echo wdk_treefield_select_ajax ($field_key.'[]', 'location_m', $field_value, 'location_title','idlocation', '', __('All Locations', 'wpdirectorykit'), $filter_ids);?> | |
| 174 | + <?php | |
| 175 | + // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped, WordPress.WP.I18n.NonSingularStringLiteralText | |
| 176 | + echo wdk_treefield_select_ajax ($field_key.'[]', 'location_m', $field_value, 'location_title','idlocation', '', __('All Locations', 'wpdirectorykit'), $filter_ids);?> | |
| 168 | 177 | <?php elseif(wdk_get_option('wdk_multi_locations_search_field_type') == 'wdk_treefield_checkboxes'):?> |
| 169 | 178 | <?php |
| 170 | 179 | wp_enqueue_style( 'wdk-treefield-checkboxes'); |
| 171 | 180 | wp_enqueue_script( 'wdk-treefield-checkboxes'); |
| 172 | 181 | ?> |
| 173 | - <?php echo wdk_treefield_option_checkboxes ('search_location', 'location_m', $field_value, 'location_title', '', __('All Locations', 'wpdirectorykit'), $filter_ids);?> | |
| 182 | + <?php | |
| 183 | + // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped, WordPress.WP.I18n.NonSingularStringLiteralText | |
| 184 | + echo wdk_treefield_option_checkboxes ('search_location', 'location_m', $field_value, 'location_title', '', __('All Locations', 'wpdirectorykit'), $filter_ids);?> | |
| 174 | 185 | <?php else:?> |
| 175 | - <?php echo wdk_treefield_option ('search_location', 'location_m', $field_value, 'location_title', '', __('All Locations', 'wpdirectorykit'), $filter_ids, FALSE, '', $hide_fields);?> | |
| 186 | + <?php | |
| 187 | + // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped, WordPress.WP.I18n.NonSingularStringLiteralText | |
| 188 | + echo wdk_treefield_option ('search_location', 'location_m', $field_value, 'location_title', '', __('All Locations', 'wpdirectorykit'), $filter_ids, FALSE, '', $hide_fields);?> | |
| 176 | 189 | <?php endif;?> |
| 177 | 190 | </div> |
| 178 | 191 | </div> |
| 179 | 192 | |
| 180 | 193 | <?php endif;?> |