| 1 |
<?php |
| 2 |
/** |
| 3 |
* The template for Search field LOCATION. |
| 4 |
* |
| 5 |
* This is the template that field layout for search form |
| 6 |
* |
| 7 |
*/ |
| 8 |
|
| 9 |
if ( ! defined( 'ABSPATH' ) ) { |
| 10 |
exit; // Exit if accessed directly. |
| 11 |
} |
| 12 |
?> |
| 13 |
<?php |
| 14 |
|
| 15 |
$field_key = 'search_'.wmvc_show_data('idfield',$field_data); |
| 16 |
$field_attr_id = 'wdk_search_'.wmvc_show_data('idfield', $field_data); |
| 17 |
$placeholder = wmvc_show_data('field_label', $field_data); |
| 18 |
$field_value = ''; |
| 19 |
$filter_ids = array(); |
| 20 |
if(isset($predefinedfields_query) && !empty($predefinedfields_query[$field_key])) { |
| 21 |
$field_value = intval($predefinedfields_query[$field_key]); |
| 22 |
} |
| 23 |
|
| 24 |
if(isset($predefinedfields_query) && !empty($predefinedfields_query['custom_location_root'])) { |
| 25 |
$custom_field_value = intval($predefinedfields_query['custom_location_root']); |
| 26 |
global $Winter_MVC_WDK; |
| 27 |
$Winter_MVC_WDK->load_helper('listing'); |
| 28 |
$Winter_MVC_WDK->model('location_m'); |
| 29 |
$location = $Winter_MVC_WDK->location_m->get($custom_field_value, TRUE); |
| 30 |
|
| 31 |
/* if root search childs */ |
| 32 |
if(empty(wmvc_show_data('parent_id', $location, false, TRUE, TRUE))) { |
| 33 |
$filter_ids = $Winter_MVC_WDK->location_m->get_all_childs($custom_field_value); |
| 34 |
if(!empty($filter_ids)) { |
| 35 |
$filter_ids[] = $custom_field_value; |
| 36 |
if(in_array($field_value, $filter_ids) === FALSE) { |
| 37 |
$field_value = $custom_field_value; |
| 38 |
} |
| 39 |
} |
| 40 |
} |
| 41 |
} |
| 42 |
|
| 43 |
|
| 44 |
if(isset($_GET[$field_key])) { |
| 45 |
$field_value = sanitize_text_field($_GET[$field_key]); |
| 46 |
} |
| 47 |
|
| 48 |
|
| 49 |
wdk_search_fields_toggle(); |
| 50 |
?> |
| 51 |
|
| 52 |
<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)); ?>"> |
| 53 |
<label class="wdk-field-label"><?php echo esc_html(wmvc_show_data('field_label', $field_data)); ?></label> |
| 54 |
<div class="wdk-field-group"> |
| 55 |
<?php echo wdk_treefield_option ('search_location', 'location_m', $field_value, 'location_title', '', __('All Locations', 'wpdirectorykit'), $filter_ids);?> |
| 56 |
</div> |
| 57 |
</div> |