| @@ -7,15 +7,41 @@ | ||
| 7 | 7 | |
| 8 | 8 | if ( ! defined( 'ABSPATH' ) ) { |
| 9 | 9 | exit; // Exit if accessed directly. |
| 10 | 10 | } |
| 11 | - | |
| 12 | 11 | ?> |
| 13 | 12 | |
| 14 | 13 | <div class="wdk-element" id="wdk_el_<?php echo esc_html($id_element);?>"> |
| 15 | 14 | <div class="wdk-map" class="wdk_map_results"> |
| 16 | - <?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;?> | |
| 17 | - <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> | |
| 18 | 44 | </div> |
| 19 | 45 | </div> |
| 20 | 46 | <?php |
| 21 | 47 | $zoom_index = $settings['conf_custom_map_zoom_index']['size']; |
| @@ -29,8 +55,9 @@ | ||
| 29 | 55 | ?> |
| 30 | 56 | <?php |
| 31 | 57 | $WMVC = &wdk_get_instance(); |
| 32 | 58 | $WMVC->model('category_m'); |
| 59 | + | |
| 33 | 60 | if (!$is_edit_mode) |
| 34 | 61 | ob_start(); |
| 35 | 62 | ?> |
| 36 | 63 | <script> |
| @@ -46,26 +73,53 @@ | ||
| 46 | 73 | jQuery(document).ready(function($) { |
| 47 | 74 | if(wdk_clusters=='') |
| 48 | 75 | wdk_clusters = L.markerClusterGroup({spiderfyOnMaxZoom: true, showCoverageOnHover: false, zoomToBoundsOnClick: true}); |
| 49 | 76 | wdk_map = L.map('wdk_map_results_<?php echo esc_html($id_element);?>', { |
| 50 | - center: ["<?php echo esc_js($lat);?>","<?php echo esc_js($lng);?>"], | |
| 51 | - zoom: "<?php echo esc_js($zoom_index);?>", | |
| 52 | - scrollWheelZoom: false, | |
| 53 | - 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;?>), | |
| 54 | - tap: !L.Browser.mobile, | |
| 55 | - fullscreenControl: true, | |
| 56 | - fullscreenControlOptions: { | |
| 57 | - position: 'topleft' | |
| 58 | - } | |
| 59 | - }); | |
| 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 | + }); | |
| 60 | 87 | |
| 61 | - | |
| 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 | + | |
| 62 | 106 | L.tileLayer('https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png', { |
| 63 | 107 | attribution: '© <a href="https://www.openstreetmap.org/copyright">OpenStreetMap</a> contributors' |
| 64 | 108 | }).addTo(wdk_map); |
| 65 | 109 | |
| 66 | - | |
| 67 | - | |
| 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 | + | |
| 68 | 122 | <?php if(!empty($settings['conf_custom_map_style']) && $settings['conf_custom_map_style'] =='custom' && !empty($settings['conf_custom_map_style_self'])):?> |
| 69 | 123 | var positron = L.tileLayer('<?php echo esc_js($settings['conf_custom_map_style_self']);?>').addTo(wdk_map); |
| 70 | 124 | <?php elseif(!empty($settings['conf_custom_map_style']) && $settings['conf_custom_map_style'] !='custom'):?> |
| 71 | 125 | <?php if($settings['conf_custom_map_style']=='google_map'):?> |
| @@ -163,8 +217,25 @@ | ||
| 163 | 217 | } |
| 164 | 218 | ).addTo(wdk_map); |
| 165 | 219 | |
| 166 | 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: '© <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( | |
| 167 | 238 | 'https://{s}.tile.thunderforest.com/mobile-atlas/{z}/{x}/{y}.png', |
| 168 | 239 | 'https://{s}.tile.thunderforest.com/cycle/{z}/{x}/{y}.png', |
| 169 | 240 | 'https://{s}.tile.thunderforest.com/transport-dark/{z}/{x}/{y}.png', |
| 170 | 241 | 'https://{s}.tile.thunderforest.com/landscape/{z}/{x}/{y}.png', |
| @@ -180,9 +251,9 @@ | ||
| 180 | 251 | 'https://{s}.tile.jawg.io/jawg-light/{z}/{x}/{y}{r}.png', |
| 181 | 252 | ))):?> |
| 182 | 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); |
| 183 | 254 | <?php else:?> |
| 184 | - var positron = L.tileLayer('<?php echo esc_js($settings['conf_custom_map_style']);?>').addTo(wdk_map); | |
| 255 | + var positron = L.tileLayer('<?php echo esc_js($settings['conf_custom_map_style']);?>').addTo(wdk_map); | |
| 185 | 256 | <?php endif;?> |
| 186 | 257 | <?php endif;?> |
| 187 | 258 | |
| 188 | 259 | var auto_marker_size = false; |
| @@ -210,10 +281,8 @@ | ||
| 210 | 281 | $listing_lng = wmvc_show_data('lng', $listing); |
| 211 | 282 | |
| 212 | 283 | if(wmvc_show_data('conf_hide_real_location', $settings) == 'yes') { |
| 213 | 284 | $gps = wdk_get_near_location($listing_lat, $listing_lng); |
| 214 | - //$listing_lat = (wmvc_show_data('lat', $gps)); | |
| 215 | - //$listing_lng = (wmvc_show_data('lng', $gps)); | |
| 216 | 285 | |
| 217 | 286 | $listing_lat = wdk_move_gps($listing_lat); |
| 218 | 287 | $listing_lng = wdk_move_gps($listing_lng); |
| 219 | 288 | } |
| @@ -239,9 +308,9 @@ | ||
| 239 | 308 | } else { |
| 240 | 309 | $value = apply_filters( 'wpdirectorykit/listing/field/value', wdk_field_value_on_type($field_id, $listing), $field_id); |
| 241 | 310 | } |
| 242 | 311 | |
| 243 | - $field_value = $value; | |
| 312 | + $field_value = wdk_filter_decimal($value); | |
| 244 | 313 | |
| 245 | 314 | } else { |
| 246 | 315 | $field_value .= apply_filters( 'wpdirectorykit/listing/field/value', wdk_field_value_on_type($field_id, $listing), $field_id); |
| 247 | 316 | } |
| @@ -248,19 +317,19 @@ | ||
| 248 | 317 | |
| 249 | 318 | $field_value .= apply_filters( 'wpdirectorykit/listing/field/suffix',wdk_field_option ($field_id, 'suffix'), $field_id); |
| 250 | 319 | ?> |
| 251 | 320 | auto_marker_size = true; |
| 252 | - 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>'; | |
| 253 | 322 | <?php elseif($pin_icon):?> |
| 254 | 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>'; |
| 255 | 324 | <?php elseif($font_icon && empty($font_class)):?> |
| 256 | - 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>'; | |
| 257 | 326 | <?php else:?> |
| 258 | - 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>'; | |
| 259 | 328 | <?php endif;?> |
| 260 | 329 | |
| 261 | 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 |
| 262 | - , <?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;?>)); | |
| 263 | 332 | <?php endforeach; ?> |
| 264 | 333 | wdk_map.addLayer(wdk_clusters); |
| 265 | 334 | /* set center */ |
| 266 | 335 | if(wdk_markers.length){ |