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 | elementor-elements/views/wdk-map.php +257 -21 1.1.0 → 1.5.9 View file →
@@ -7,13 +7,41 @@
7 7
8 8 if ( ! defined( 'ABSPATH' ) ) {
9 9 exit; // Exit if accessed directly.
10 10 }
11 +?>
11 12
12 -?>
13 13 <div class="wdk-element" id="wdk_el_<?php echo esc_html($id_element);?>">
14 14 <div class="wdk-map" class="wdk_map_results">
15 - <div id="wdk_map_results_<?php echo esc_html($id_element);?>" style="height:<?php echo esc_attr($settings['conf_custom_map_height']['size']);?>px" class="wdk_map_results <?php echo wmvc_show_data('styles_thmbn_des_type',$settings, '');?> " ></div>
15 + <div id="wdk_map_results_<?php echo esc_html($id_element);?>" data-auto-search="enable" style="height:<?php echo esc_attr($settings['conf_custom_map_height']['size']);?>px"
16 + data-el_id="<?php echo esc_attr($this->get_id());?>"
17 + data-el_type="<?php echo esc_attr($this->get_name());?>"
18 + <?php
19 + $post_id = get_the_ID();
20 + $post_object_id = get_queried_object_id();
21 + if($post_object_id)
22 + $post_id = $post_object_id;
23 +
24 + global $wdk_listing_page_id;
25 + if(!empty($wdk_listing_page_id))
26 + $post_id = $wdk_listing_page_id;
27 + ?>
28 + data-el_page_id="<?php echo esc_attr($post_id);?>"
29 +
30 + class="wdk_map_results <?php echo esc_attr(wmvc_show_data('styles_thmbn_des_type',$settings, ''));?>
31 + <?php if
32 + (
33 + wdk_get_option('wdk_experimental_features') && wdk_get_option('wdk_experimental_ajax_results') &&
34 + isset($settings['is_ajax_enable']) && $settings['is_ajax_enable'] == 'yes'
35 + ):?>
36 + ajax_results_enabled
37 + <?php endif;?>
38 + " >
39 + </div>
40 + <form action="" class="wdk-search-form map" style="wdk-hidden">
41 + <input name="rectangle_ne" type="hidden" class="wdk-hidden" value="<?php echo isset($_GET['rectangle_ne']) ? esc_attr(sanitize_text_field(wp_unslash($_GET['rectangle_ne']))) : '';?>"/>
42 + <input name="rectangle_sw" type="hidden" class="wdk-hidden" value="<?php echo isset($_GET['rectangle_sw']) ? esc_attr(sanitize_text_field(wp_unslash($_GET['rectangle_sw']))) : '';?>"/>
43 + </form>
16 44 </div>
17 45 </div>
18 46 <?php
19 47 $zoom_index = $settings['conf_custom_map_zoom_index']['size'];
@@ -27,8 +55,9 @@
27 55 ?>
28 56 <?php
29 57 $WMVC = &wdk_get_instance();
30 58 $WMVC->model('category_m');
59 +
31 60 if (!$is_edit_mode)
32 61 ob_start();
33 62 ?>
34 63 <script>
@@ -44,29 +73,191 @@
44 73 jQuery(document).ready(function($) {
45 74 if(wdk_clusters=='')
46 75 wdk_clusters = L.markerClusterGroup({spiderfyOnMaxZoom: true, showCoverageOnHover: false, zoomToBoundsOnClick: true});
47 76 wdk_map = L.map('wdk_map_results_<?php echo esc_html($id_element);?>', {
48 - center: ["<?php echo esc_js($lat);?>","<?php echo esc_js($lng);?>"],
49 - zoom: "<?php echo esc_js($zoom_index);?>",
50 - scrollWheelZoom: false,
51 - <?php if($settings['conf_custom_dragging'] == 'yes'):?>
52 - dragging: true,
53 - <?php else:?>
54 - dragging: false,
55 - <?php endif;?>
56 - tap: !L.Browser.mobile
57 - });
58 -
77 + center: ["<?php echo esc_js($lat);?>","<?php echo esc_js($lng);?>"],
78 + zoom: "<?php echo esc_js($zoom_index);?>",
79 + scrollWheelZoom: <?php echo (wmvc_show_data('enable_scrollWheelZoom', $settings, '') == 'yes') ? 'true' : 'false'; ?>,
80 + dragging: ((!L.Browser.mobile) ? (<?php if($settings['conf_custom_dragging'] == 'yes'):?> true <?php else:?> false <?php endif;?>) : (<?php if($settings['conf_custom_dragging_mobile'] == 'yes'):?> true <?php else:?> false <?php endif;?>)),
81 + tap: !L.Browser.mobile,
82 + fullscreenControl: true,
83 + fullscreenControlOptions: {
84 + position: 'topleft'
85 + },
86 + });
87 +
88 + // Custom info label control on the top left of the map
89 +
90 + <?php if($settings['conf_custom_dragging_mobile'] != 'yes'):?>
91 + var InfoLabelControl = L.Control.extend({
92 + options: {
93 + position: 'topright'
94 + },
95 +
96 + onAdd: function (map) {
97 + var container = L.DomUtil.create('div', 'wdk-map-info-label only_mobile');
98 + container.innerHTML = '<?php echo esc_html__( 'Require 2 finger for map movement', 'wpdirectorykit' );?>';
99 + return container;
100 + }
101 + });
102 +
103 + wdk_map.addControl(new InfoLabelControl());
104 + <?php endif;?>
105 +
59 106 L.tileLayer('https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png', {
60 107 attribution: '&copy; <a href="https://www.openstreetmap.org/copyright">OpenStreetMap</a> contributors'
61 108 }).addTo(wdk_map);
62 109
110 + <?php if(!isset($settings['disable_rectangle']) || $settings['disable_rectangle'] != 'yes'):?>
111 + let drawMap = wdk_map_draw(wdk_map, null, <?php if(isset($settings['enable_rectangle_auto_search']) && $settings['enable_rectangle_auto_search'] != 'yes'):?>false<?php else:?>true<?php endif;?>);
112 +
113 + // define rectangle geographical bounds
114 + <?php if(isset($_GET['rectangle_ne']) && isset($_GET['rectangle_sw'])) :?>
115 + <?php if(wdk_is_gps($_GET['rectangle_ne']) && wdk_is_gps($_GET['rectangle_sw'])) :?>
116 + var bounds = [[<?php echo isset($_GET['rectangle_ne']) ? esc_attr(sanitize_text_field(wp_unslash($_GET['rectangle_ne']))) : '';?>], [<?php echo isset($_GET['rectangle_sw']) ? esc_attr(sanitize_text_field(wp_unslash($_GET['rectangle_sw']))) : '';?>]];
117 + drawMap.drawOuther(bounds);
118 + <?php endif;?>
119 + <?php endif;?>
120 + <?php endif;?>
121 +
63 122 <?php if(!empty($settings['conf_custom_map_style']) && $settings['conf_custom_map_style'] =='custom' && !empty($settings['conf_custom_map_style_self'])):?>
64 123 var positron = L.tileLayer('<?php echo esc_js($settings['conf_custom_map_style_self']);?>').addTo(wdk_map);
65 124 <?php elseif(!empty($settings['conf_custom_map_style']) && $settings['conf_custom_map_style'] !='custom'):?>
66 - var positron = L.tileLayer('<?php echo esc_js($settings['conf_custom_map_style']);?>').addTo(wdk_map);
125 + <?php if($settings['conf_custom_map_style']=='google_map'):?>
126 + <?php
127 + wp_enqueue_script('google-map-api', 'https://maps.googleapis.com/maps/api/js?key='.wmvc_show_data('google_map_key', $settings, ''));
128 + ?>
129 + var roadMutant = L.gridLayer
130 + .googleMutant({
131 + type: "roadmap",
132 + });
133 +
134 + var satMutant = L.gridLayer.googleMutant({
135 + type: "satellite",
136 + });
137 +
138 + var terrainMutant = L.gridLayer.googleMutant({
139 + type: "terrain",
140 + });
141 +
142 + var hybridMutant = L.gridLayer.googleMutant({
143 + type: "hybrid",
144 + });
145 +
146 + var styleMutant = L.gridLayer.googleMutant({
147 + styles: [
148 + { elementType: "labels", stylers: [{ visibility: "off" }] },
149 + { featureType: "water", stylers: [{ color: "#444444" }] },
150 + { featureType: "landscape", stylers: [{ color: "#eeeeee" }] },
151 + { featureType: "road", stylers: [{ visibility: "off" }] },
152 + { featureType: "poi", stylers: [{ visibility: "off" }] },
153 + { featureType: "transit", stylers: [{ visibility: "off" }] },
154 + { featureType: "administrative", stylers: [{ visibility: "off" }] },
155 + {
156 + featureType: "administrative.locality",
157 + stylers: [{ visibility: "off" }],
158 + },
159 + ],
160 + maxZoom: 24,
161 + type: "roadmap",
162 + });
163 +
164 + var trafficMutant = L.gridLayer.googleMutant({
165 + type: "roadmap",
166 + });
167 + trafficMutant.addGoogleLayer("TrafficLayer");
168 +
169 + var transitMutant = L.gridLayer.googleMutant({
170 + type: "roadmap",
171 + });
172 +
173 + var satelliteMutant = L.gridLayer.googleMutant({
174 + type: "satellite",
175 + });
176 + transitMutant.addGoogleLayer("TransitLayer");
177 +
178 + var google_map_style = roadMutant;
179 + <?php switch (wmvc_show_data('google_map_default_type', $settings, 'roadMutant')){
180 + case 'roadmap':
181 + echo 'google_map_style=roadMutant';
182 + break;
183 + case 'aerial':
184 + echo 'google_map_style=satMutant';
185 + break;
186 + case 'terrain':
187 + echo 'google_map_style=terrainMutant';
188 + break;
189 + case 'hybrid':
190 + echo 'google_map_style=hybridMutant';
191 + break;
192 + case 'satellite':
193 + echo 'google_map_style=satelliteMutant';
194 + break;
195 + case 'styles':
196 + echo 'google_map_style=styleMutant';
197 + break;
198 + case 'traffic':
199 + echo 'google_map_style=trafficMutant';
200 + break;
201 + case 'transit':
202 + echo 'google_map_style=transitMutant';
203 + break;
204 + }
205 + ?>
206 +
207 + google_map_style.addTo(wdk_map);
208 + L.control.layers(
209 + {
210 + Roadmap: roadMutant,
211 + Aerial: satMutant,
212 + Terrain: terrainMutant,
213 + Hybrid: hybridMutant,
214 + Satellite: satelliteMutant,
215 + Traffic: trafficMutant,
216 + Transit: transitMutant,
217 + }
218 + ).addTo(wdk_map);
219 +
220 + <?php elseif(in_array($settings['conf_custom_map_style'], array(
221 + 'https://cartodb-basemaps-{s}.global.ssl.fastly.net/light_all/{z}/{x}/{y}{r}.png',
222 + 'https://{s}.basemaps.cartocdn.com/light_all/{z}/{x}/{y}{r}.png',
223 + 'https://{s}.basemaps.cartocdn.com/rastertiles/voyager/{z}/{x}/{y}{r}.png',
224 + 'https://cartodb-basemaps-{s}.global.ssl.fastly.net/dark_all/{z}/{x}/{y}{r}.png',
225 + ))):?>
226 +
227 + <?php
228 + // If no Carto key is provided, show default tile styling (fallback to OSM)
229 + if (!$is_edit_mode && empty($settings['carto_map_key'])): ?>
230 + var positron = L.tileLayer('https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png', {
231 + attribution: '&copy; <a href="https://www.openstreetmap.org/copyright">OpenStreetMap</a> contributors'
232 + }).addTo(wdk_map);
233 + <?php else: ?>
234 + var positron = L.tileLayer('<?php echo esc_js($settings['conf_custom_map_style']);?>?key=<?php echo esc_js($settings['carto_map_key']);?>').addTo(wdk_map);
235 + <?php endif; ?>
236 +
237 + <?php elseif(in_array($settings['conf_custom_map_style'], array(
238 + 'https://{s}.tile.thunderforest.com/mobile-atlas/{z}/{x}/{y}.png',
239 + 'https://{s}.tile.thunderforest.com/cycle/{z}/{x}/{y}.png',
240 + 'https://{s}.tile.thunderforest.com/transport-dark/{z}/{x}/{y}.png',
241 + 'https://{s}.tile.thunderforest.com/landscape/{z}/{x}/{y}.png',
242 + 'https://{s}.tile.thunderforest.com/outdoors/{z}/{x}/{y}.png',
243 + 'https://{s}.tile.thunderforest.com/pioneer/{z}/{x}/{y}.png',
244 + 'https://{s}.tile.thunderforest.com/neighbourhood/{z}/{x}/{y}.png',
245 + ))):?>
246 + var positron = L.tileLayer('<?php echo esc_js($settings['conf_custom_map_style']);?><?php echo (wmvc_show_data('thunderforest_map_key', $settings, false)) ? '?apikey='.esc_js(wmvc_show_data('thunderforest_map_key', $settings)) : '';?>').addTo(wdk_map);
247 + <?php elseif(in_array($settings['conf_custom_map_style'], array(
248 + 'https://{s}.tile.jawg.io/jawg-terrain/{z}/{x}/{y}{r}.png',
249 + 'https://{s}.tile.jawg.io/jawg-streets/{z}/{x}/{y}{r}.png',
250 + 'https://{s}.tile.jawg.io/jawg-dark/{z}/{x}/{y}{r}.png',
251 + 'https://{s}.tile.jawg.io/jawg-light/{z}/{x}/{y}{r}.png',
252 + ))):?>
253 + var positron = L.tileLayer('<?php echo esc_js($settings['conf_custom_map_style']);?><?php echo (wmvc_show_data('jawg_map_key', $settings, false)) ? '?access-token='.esc_js(wmvc_show_data('jawg_map_key', $settings)) : '';?>').addTo(wdk_map);
254 + <?php else:?>
255 + var positron = L.tileLayer('<?php echo esc_js($settings['conf_custom_map_style']);?>').addTo(wdk_map);
256 + <?php endif;?>
67 257 <?php endif;?>
68 258
259 + var auto_marker_size = false;
69 260 <?php foreach($results as $key=>$listing): ?>
70 261 <?php if(!is_numeric(wmvc_show_data('lng', $listing)))continue;?>
71 262 <?php
72 263 $pin_icon = "";
@@ -82,20 +273,63 @@
82 273 $font_class = wmvc_show_data('font_icon_code', $category);
83 274 }
84 275 } else {
85 276 $font_class = "";
86 - $font_icon = "";
87 277 }
88 278
279 + $listing_lat = $listing_lng = NULL;
280 + $listing_lat = wmvc_show_data('lat', $listing);
281 + $listing_lng = wmvc_show_data('lng', $listing);
282 +
283 + if(wmvc_show_data('conf_hide_real_location', $settings) == 'yes') {
284 + $gps = wdk_get_near_location($listing_lat, $listing_lng);
285 +
286 + $listing_lat = wdk_move_gps($listing_lat);
287 + $listing_lng = wdk_move_gps($listing_lng);
288 + }
289 +
89 290 ?>
90 - <?php if($pin_icon):?>
291 + <?php if(!empty($settings['custom_marker_fields']) && substr($this->data['settings']['custom_marker_fields'], strpos($this->data['settings']['custom_marker_fields'],'__')+2) == 'first_image'):?>
292 + auto_marker_size = true;
293 + var innerMarker = '<div class="wdk_marker-container wdk_marker_label wdk_marker_clear category_id_<?php echo esc_js(wmvc_show_data('category_id', $listing));?>"><img src="<?php echo esc_js(wdk_image_src($listing));?>"></img></div>';
294 +
295 + <?php elseif(!empty($settings['custom_marker_fields']) && wdk_field_value (substr($this->data['settings']['custom_marker_fields'], strpos($this->data['settings']['custom_marker_fields'],'__')+2), $listing)):?>
296 + <?php
297 + $field_id = substr($this->data['settings']['custom_marker_fields'], strpos($this->data['settings']['custom_marker_fields'],'__')+2);
298 +
299 + $field_value = '';
300 + $field_value .= apply_filters( 'wpdirectorykit/listing/field/prefix', wdk_field_option ($field_id, 'prefix'), $field_id);
301 +
302 + /* if price field use like 1l */
303 + if(wdk_field_option($field_id, 'is_price_format')) {
304 +
305 + $value = wdk_field_value($field_id, $listing);
306 + if($value>=1000) {
307 + $value = apply_filters( 'wpdirectorykit/listing/field/value', number_format_i18n(wdk_filter_decimal($value/1000)), $field_id).'k';
308 + } else {
309 + $value = apply_filters( 'wpdirectorykit/listing/field/value', wdk_field_value_on_type($field_id, $listing), $field_id);
310 + }
311 +
312 + $field_value = wdk_filter_decimal($value);
313 +
314 + } else {
315 + $field_value .= apply_filters( 'wpdirectorykit/listing/field/value', wdk_field_value_on_type($field_id, $listing), $field_id);
316 + }
317 +
318 + $field_value .= apply_filters( 'wpdirectorykit/listing/field/suffix',wdk_field_option ($field_id, 'suffix'), $field_id);
319 + ?>
320 + auto_marker_size = true;
321 + var innerMarker = '<div class="wdk_marker-container wdk_marker_label category_id_<?php echo esc_js(wmvc_show_data('category_id', $listing));?>"><?php echo esc_js(wp_strip_all_tags($field_value));?></div>';
322 + <?php elseif($pin_icon):?>
91 323 var image = '<?php echo esc_html($pin_icon);?>'; var innerMarker = '<div class="wdk_marker-container wdk_marker-container-image"><img src='+image+'></img></div>';
92 324 <?php elseif($font_icon && empty($font_class)):?>
93 - var innerMarker = '<div class="wdk_marker-container"><div class="front wdk_face"><?php echo wdk_viewe($font_icon);?></div><div class="wdk_marker-card"><div class="wdk_marker-arrow"></div></div></div>';
325 + var innerMarker = '<div class="wdk_marker-container category_id_<?php echo esc_js(wmvc_show_data('category_id', $listing));?>"><div class="front wdk_face"><?php echo wdk_viewe($font_icon);// phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped, WordPress.WP.I18n.NonSingularStringLiteralText?></div><div class="wdk_marker-card"><div class="wdk_marker-arrow"></div></div></div>';
94 326 <?php else:?>
95 - var innerMarker = '<div class="wdk_marker-container"><div class="front wdk_face"><i class="<?php echo esc_html($font_class);?>"></i></div><div class="wdk_marker-card"><div class="wdk_marker-arrow"></div></div></div>';
327 + var innerMarker = '<div class="wdk_marker-container category_id_<?php echo esc_js(wmvc_show_data('category_id', $listing));?>"><div class="front wdk_face"><i class="<?php echo esc_attr($font_class);?>"></i></div><div class="wdk_marker-card"><div class="wdk_marker-arrow"></div></div></div>';
96 328 <?php endif;?>
97 - wdk_markers.push(wdk_generate_marker_ajax_popup('<?php echo esc_url(admin_url('admin-ajax.php'));?>','<?php echo esc_html(wmvc_show_data('post_id', $listing));?>','<?php echo esc_html(wmvc_show_data('lat', $listing));?>','<?php echo esc_html(wmvc_show_data('lng', $listing));?>',innerMarker, wdk_jpopup_customOptions));
329 +
330 + wdk_markers.push(wdk_generate_marker_ajax_popup('<?php echo esc_url(admin_url('admin-ajax.php'));?>','<?php echo esc_html(wmvc_show_data('post_id', $listing));?>','<?php echo esc_html($listing_lat);?>','<?php echo esc_html($listing_lng);?>',innerMarker, wdk_jpopup_customOptions, auto_marker_size
331 + , <?php if(wmvc_show_data('disable_cluster', $settings) == 'yes'):?> false<?php else:?> true <?php endif;?> <?php if(wmvc_show_data('custom_layout_id', $settings)):?>, <?php echo esc_js(wmvc_show_data('custom_layout_id', $settings));?> <?php endif;?>));
98 332 <?php endforeach; ?>
99 333 wdk_map.addLayer(wdk_clusters);
100 334 /* set center */
101 335 if(wdk_markers.length){
@@ -104,10 +338,12 @@
104 338 var latLngs = [ wdk_markers[i].getLatLng() ];
105 339 limits_center.push(latLngs)
106 340 };
107 341 var bounds = L.latLngBounds(limits_center);
108 - <?php if($settings['conf_custom_map_auto_center'] != 'yes'): ?>
109 - wdk_map.setView(bounds.getCenter());
342 + <?php if(wdk_get_option('wdk_fixed_map_results_position') && wdk_get_option('wdk_default_lat') && wdk_get_option('wdk_default_lng')): ?>
343 + wdk_map.setView(["<?php echo esc_js(wdk_get_option('wdk_default_lat'));?>","<?php echo esc_js(wdk_get_option('wdk_default_lng'));?>"]);
344 + <?php elseif($settings['enable_custom_gps_center'] == 'yes'): ?>
345 + wdk_map.setView(["<?php echo esc_js($settings['conf_custom_map_center_gps_lat']);?>","<?php echo esc_js($settings['conf_custom_map_center_gps_lng']);?>"]);
110 346 <?php else: ?>
111 347 wdk_map.fitBounds(bounds);
112 348 <?php endif; ?>
113 349 }