PluginProbe
WP Directory Kit / 1.2.7
WP Directory Kit v1.2.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 1.4.0 1.4.1 All 35 releases
wpdirectorykit / application / views / search_fields / LOCATION.php

LOCATION.php in WP Directory Kit 1.2.7, at application/views/search_fields/LOCATION.php

164 lines 7.0 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
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_location';
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 = wdk_location_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 if(isset($_GET[$field_key])) {
44 $field_value = ($_GET[$field_key]);
45 } else {
46 if(function_exists('run_wdk_geo') && (get_option('wdk_geo_autodetect_by_ip_enable') && !get_option('wdk_geo_autodetect_by_google_js_enable'))) {
47 $field_value = wdk_geo_get_location_id();
48 }
49 }
50 wdk_search_fields_toggle();
51 ?>
52
53 <?php if(wdk_get_option('wdk_multi_locations_search_field_type') == 'wdk_treefield_dropdown'):?>
54 <?php
55 global $Winter_MVC_WDK;
56 $Winter_MVC_WDK->load_helper('listing');
57 $Winter_MVC_WDK->model('location_m');
58
59 $locations = array();
60 if(!empty($field_value)) {
61 $locations[] = $field_value;
62 $location = $Winter_MVC_WDK->location_m->get($field_value, TRUE);
63
64 while(!empty($location->parent_id)) {
65 $location = $Winter_MVC_WDK->location_m->get($location->parent_id, TRUE);
66 $locations[] = $location->idlocation;
67 }
68 krsort($locations);
69 } else {
70 $locations[] = 0;
71 }
72
73 wp_enqueue_style('wdk-treefield-dropdown');
74 wp_enqueue_script('wdk-treefield-dropdown');
75 wp_enqueue_style( 'dashicons' );
76
77 $level_max = $Winter_MVC_WDK->location_m->get_max_level();
78
79 $placeholder = [
80 0 => esc_html__('Select Country','wpdirectorykit'),
81 1 => esc_html__('Select City','wpdirectorykit'),
82 2 => esc_html__('Select Neighborhood','wpdirectorykit'),
83 3 => esc_html__('Select Sub Area','wpdirectorykit'),
84 4 => esc_html__('Select Sub Area','wpdirectorykit'),
85 5 => esc_html__('Select Sub Area','wpdirectorykit'),
86 ];
87
88
89 ?>
90
91 <input name="<?php echo esc_attr($field_key); ?>" type="hidden" value="<?php echo esc_attr($field_value); ?>" class="wdk_field_id_location">
92 <?php
93 $level = 0;
94 foreach ($locations as $location) {
95 $current = $Winter_MVC_WDK->location_m->get($location, TRUE);
96
97 $list = $Winter_MVC_WDK->location_m->get_by(array('parent_id = '.$current->parent_id => NULL));
98
99
100 if(isset($placeholder[$level])) {
101 $values_list = array(''=> $placeholder[$level]);
102 } else {
103 $values_list = array(''=> esc_html__('Select Sub Categories','wpdirectorykit'));
104 }
105
106 foreach ($list as $list_value) {
107 $values_list[$list_value->idlocation] = $list_value->location_title;
108 }
109 ?>
110
111 <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)); ?>">
112 <label class="wdk-field-label"><?php echo esc_html(wmvc_show_data('field_label', $field_data)); ?></label>
113 <div class="wdk-field-group">
114 <?php echo wmvc_select_option('location_'.$level, $values_list, $location, 'class="wdk-control"');?>
115 </div>
116 </div>
117
118 <?php
119 $level++;
120 }
121
122 if($level<$level_max ) {
123 for (; $level<$level_max;) {
124
125 if(isset($placeholder[$level])) {
126 $values_list = array(''=> $placeholder[$level]);
127 } else {
128 $values_list = array(''=> esc_html__('Select Sub Categories','wpdirectorykit'));
129 }
130
131 ?>
132
133 <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 <label class="wdk-field-label"><?php echo esc_html(wmvc_show_data('field_label', $field_data)); ?></label>
135 <div class="wdk-field-group">
136 <?php echo wmvc_select_option('location_'.$level, $values_list, NULL, 'class="wdk-control"');?>
137 </div>
138 </div>
139
140 <?php
141 $level++;
142 }
143 }
144 ?>
145 <?php else:?>
146
147 <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)); ?>">
148 <label class="wdk-field-label"><?php echo esc_html(wmvc_show_data('field_label', $field_data)); ?></label>
149 <div class="wdk-field-group">
150 <?php if(wdk_get_option('wdk_multi_locations_search_field_type') == 'select2'):?>
151 <?php echo wdk_treefield_select_ajax ($field_key.'[]', 'location_m', $field_value, 'location_title','idlocation', '', __('All Locations', 'wpdirectorykit'), $filter_ids);?>
152 <?php elseif(wdk_get_option('wdk_multi_locations_search_field_type') == 'wdk_treefield_checkboxes'):?>
153 <?php
154 wp_enqueue_style( 'wdk-treefield-checkboxes');
155 wp_enqueue_script( 'wdk-treefield-checkboxes');
156 ?>
157 <?php echo wdk_treefield_option_checkboxes ('search_location', 'location_m', $field_value, 'location_title', '', __('All Locations', 'wpdirectorykit'), $filter_ids);?>
158 <?php else:?>
159 <?php echo wdk_treefield_option ('search_location', 'location_m', $field_value, 'location_title', '', __('All Locations', 'wpdirectorykit'), $filter_ids);?>
160 <?php endif;?>
161 </div>
162 </div>
163
164 <?php endif;?>