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 +209 -22 1.2.7 → 1.5.9 View file →
@@ -7,14 +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 - <?php if($settings['conf_custom_dragging_mobile'] == 'yes'):?> <div class="map-hint"><?php echo esc_html__( 'Require 2 finger for map movement', 'wpdirectorykit' );?></div><?php endif;?>
16 - <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>
17 44 </div>
18 45 </div>
19 46 <?php
20 47 $zoom_index = $settings['conf_custom_map_zoom_index']['size'];
@@ -28,8 +55,9 @@
28 55 ?>
29 56 <?php
30 57 $WMVC = &wdk_get_instance();
31 58 $WMVC->model('category_m');
59 +
32 60 if (!$is_edit_mode)
33 61 ob_start();
34 62 ?>
35 63 <script>
@@ -45,29 +73,190 @@
45 73 jQuery(document).ready(function($) {
46 74 if(wdk_clusters=='')
47 75 wdk_clusters = L.markerClusterGroup({spiderfyOnMaxZoom: true, showCoverageOnHover: false, zoomToBoundsOnClick: true});
48 76 wdk_map = L.map('wdk_map_results_<?php echo esc_html($id_element);?>', {
49 - center: ["<?php echo esc_js($lat);?>","<?php echo esc_js($lng);?>"],
50 - zoom: "<?php echo esc_js($zoom_index);?>",
51 - scrollWheelZoom: false,
52 - dragging: ((!L.Browser.mobile) ? <?php if($settings['conf_custom_dragging'] == 'yes'):?> true <?php else:?> else <?php endif;?> : <?php if($settings['conf_custom_dragging_mobile'] == 'yes'):?> true <?php else:?> false <?php endif;?>),
53 - tap: !L.Browser.mobile,
54 - fullscreenControl: true,
55 - fullscreenControlOptions: {
56 - position: 'topleft'
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 + });
59 87
60 -
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 +
61 106 L.tileLayer('https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png', {
62 107 attribution: '&copy; <a href="https://www.openstreetmap.org/copyright">OpenStreetMap</a> contributors'
63 108 }).addTo(wdk_map);
64 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 +
65 122 <?php if(!empty($settings['conf_custom_map_style']) && $settings['conf_custom_map_style'] =='custom' && !empty($settings['conf_custom_map_style_self'])):?>
66 123 var positron = L.tileLayer('<?php echo esc_js($settings['conf_custom_map_style_self']);?>').addTo(wdk_map);
67 124 <?php elseif(!empty($settings['conf_custom_map_style']) && $settings['conf_custom_map_style'] !='custom'):?>
68 - 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;?>
69 257 <?php endif;?>
258 +
70 259 var auto_marker_size = false;
71 260 <?php foreach($results as $key=>$listing): ?>
72 261 <?php if(!is_numeric(wmvc_show_data('lng', $listing)))continue;?>
73 262 <?php
@@ -92,10 +281,8 @@
92 281 $listing_lng = wmvc_show_data('lng', $listing);
93 282
94 283 if(wmvc_show_data('conf_hide_real_location', $settings) == 'yes') {
95 284 $gps = wdk_get_near_location($listing_lat, $listing_lng);
96 - //$listing_lat = (wmvc_show_data('lat', $gps));
97 - //$listing_lng = (wmvc_show_data('lng', $gps));
98 285
99 286 $listing_lat = wdk_move_gps($listing_lat);
100 287 $listing_lng = wdk_move_gps($listing_lng);
101 288 }
@@ -121,9 +308,9 @@
121 308 } else {
122 309 $value = apply_filters( 'wpdirectorykit/listing/field/value', wdk_field_value_on_type($field_id, $listing), $field_id);
123 310 }
124 311
125 - $field_value = $value;
312 + $field_value = wdk_filter_decimal($value);
126 313
127 314 } else {
128 315 $field_value .= apply_filters( 'wpdirectorykit/listing/field/value', wdk_field_value_on_type($field_id, $listing), $field_id);
129 316 }
@@ -130,19 +317,19 @@
130 317
131 318 $field_value .= apply_filters( 'wpdirectorykit/listing/field/suffix',wdk_field_option ($field_id, 'suffix'), $field_id);
132 319 ?>
133 320 auto_marker_size = true;
134 - 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(strip_tags($field_value));?></div>';
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>';
135 322 <?php elseif($pin_icon):?>
136 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>';
137 324 <?php elseif($font_icon && empty($font_class)):?>
138 - 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);?></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>';
139 326 <?php else:?>
140 - 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_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>';
141 328 <?php endif;?>
142 329
143 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
144 - , <?php if(wmvc_show_data('disable_cluster', $settings) == 'yes'):?> false <?php endif;?>));
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;?>));
145 332 <?php endforeach; ?>
146 333 wdk_map.addLayer(wdk_clusters);
147 334 /* set center */
148 335 if(wdk_markers.length){