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 / elementor-elements / views / wdk-listing-map.php

wdk-listing-map.php in WP Directory Kit 1.2.7, at elementor-elements/views/wdk-listing-map.php

145 lines 6.4 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 Element Listing Map.
4 * This is the template that elementor element map
5 *
6 */
7
8 if ( ! defined( 'ABSPATH' ) ) {
9 exit; // Exit if accessed directly.
10 }
11
12 ?>
13
14 <?php
15 if(empty($lng) || empty($lat)) {
16 ?>
17 <div class="">
18 <p class="wdk_alert wdk_alert-danger"><?php echo esc_html__('Missing address', 'wpdirectorykit');?></p>
19 </div>
20 <?php
21 return false;
22 }
23 ?>
24
25 <div class="wdk-element" id="wdk_el_<?php echo esc_html($id_element);?>">
26 <div class="wdk-map infobox-basic">
27 <div id="wdk_map_results_<?php echo esc_html($id_element);?>" style="height:<?php echo esc_attr($settings['conf_custom_map_height']['size']);?>px" ></div>
28 </div>
29 </div>
30 <?php
31 $zoom_index = $settings['conf_custom_map_zoom_index']['size'];
32 ?>
33
34 <?php
35 $WMVC = &wdk_get_instance();
36 $WMVC->model('category_m');
37 if (!$is_edit_mode)
38 ob_start();
39 ?>
40 <script>
41 var wdk_map ='';
42 var wdk_markers = [];
43 var wdk_clusters ='';
44 var wdk_jpopup_customOptions =
45 {
46 'maxWidth': 'initial',
47 'width': 'initial',
48 'className' : 'popupCustom'
49 };
50 jQuery(document).ready(function($) {
51 if(wdk_clusters=='')
52 wdk_clusters = L.markerClusterGroup({spiderfyOnMaxZoom: true, showCoverageOnHover: false, zoomToBoundsOnClick: true});
53 wdk_map = L.map('wdk_map_results_<?php echo esc_html($id_element);?>', {
54 center: ["<?php echo esc_js($lat);?>","<?php echo esc_js($lng);?>"],
55 zoom: "<?php echo esc_js($zoom_index);?>",
56 scrollWheelZoom: false,
57 <?php if($settings['conf_custom_dragging'] == 'yes'):?>
58 dragging: true,
59 <?php else:?>
60 dragging: false,
61 <?php endif;?>
62 tap: !L.Browser.mobile,
63 fullscreenControl: true,
64 fullscreenControlOptions: {
65 position: 'topleft'
66 }
67 });
68
69 L.tileLayer('https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png', {
70 attribution: '&copy; <a href="https://www.openstreetmap.org/copyright">OpenStreetMap</a> contributors'
71 }).addTo(wdk_map);
72
73 <?php if(!empty($settings['conf_custom_map_style']) && $settings['conf_custom_map_style'] =='custom' && !empty($settings['conf_custom_map_style_self'])):?>
74 var positron = L.tileLayer('<?php echo esc_js($settings['conf_custom_map_style_self']);?>').addTo(wdk_map);
75 <?php elseif(!empty($settings['conf_custom_map_style']) && $settings['conf_custom_map_style'] !='custom'):?>
76 var positron = L.tileLayer('<?php echo esc_js($settings['conf_custom_map_style']);?>').addTo(wdk_map);
77 <?php endif;?>
78
79 <?php if(is_numeric($lng)):?>
80 <?php
81 $font_class = "fa fa-home";
82 $font_icon = $this->generate_icon($settings['conf_custom_map_pin_icon']);
83 $pin_icon = $settings['conf_custom_map_pin']['url'];
84
85 if(!empty(wdk_field_value('category_id', $wdk_listing_id))){
86 $category = $WMVC->category_m->get_data(wdk_field_value('category_id', $wdk_listing_id));
87 if(wmvc_show_data('marker_image_id', $category, false, TRUE, TRUE)){
88 $pin_icon = wdk_image_src($category, 'full', NULL,'marker_image_id');
89 } else if(!empty(wmvc_show_data('font_icon_code', $category))) {
90 $font_class = wmvc_show_data('font_icon_code', $category);
91 }
92 } else {
93 $font_class = "";
94 }
95
96 $wdk_popup_content = '<div class="infobox map-box wdk-infobox-basic">'
97 .'<h3 class="title">'.esc_html(wdk_field_value('post_title', $wdk_listing_id)).'</h3>'
98 .'<p>'.esc_html(wdk_field_value('address', $wdk_listing_id)).'</p>'
99 .'</div>';
100
101 if($settings['puopup_custom_content'] == 'yes') {
102 $title_field_id = substr($settings['title_field_id'], strpos($settings['title_field_id'],'__')+2);
103 $content_field_id = substr($settings['content_field_id'], strpos($settings['content_field_id'],'__')+2);
104
105 $wdk_popup_content = '<div class="infobox map-box wdk-infobox-basic">'
106 .'<h3 class="title">'.esc_html(wdk_field_value($title_field_id, $wdk_listing_id)).'</h3>'
107 .'<p>'.esc_html(wdk_field_value($content_field_id, $wdk_listing_id)).'</p>'
108 .'</div>';
109
110 }
111
112
113 $wdk_popup_content = str_replace("'", "\'", $wdk_popup_content);
114 $wdk_popup_content = str_replace("\n", "", $wdk_popup_content);
115 $wdk_popup_content = str_replace("\r", "", $wdk_popup_content);
116
117 ?>
118 <?php if($pin_icon):?>
119 var image = '<?php echo esc_html($pin_icon);?>'; var innerMarker = '<div class="wdk_marker-container wdk_marker-container-image category_id_<?php echo esc_js(wdk_field_value('category_id', $wdk_listing_id));?>""><img src='+image+'></img></div>';
120 <?php elseif($font_icon && empty($font_class)):?>
121 var innerMarker = '<div class="wdk_marker-container category_id_<?php echo esc_js(wdk_field_value('category_id', $wdk_listing_id));?>""><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>';
122 <?php else:?>
123 var innerMarker = '<div class="wdk_marker-container category_id_<?php echo esc_js(wdk_field_value('category_id', $wdk_listing_id));?>""><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>';
124 <?php endif;?>
125
126 <?php if($settings['conf_custom_popup_enable'] == 'yes'):?>
127 wdk_markers.push(wdk_generate_marker_basic_popup('<?php echo esc_html($lat);?>','<?php echo esc_html($lng);?>',innerMarker,'<?php echo $wdk_popup_content;?>', wdk_jpopup_customOptions));
128 <?php else:?>
129 wdk_markers.push(wdk_generate_marker_nopopup('<?php echo esc_html($lat);?>','<?php echo esc_html($lng);?>',innerMarker));
130 <?php endif;?>
131 wdk_map.addLayer(wdk_clusters);
132 <?php endif;?>
133 /* set center */
134 })
135 </script>
136
137 <?php
138 if (!$is_edit_mode) {
139 $js_content = ob_get_clean();
140 $js_content = str_replace(array('</script>','<script>'),'',$js_content );
141 wp_add_inline_script( 'wdk-elementor-main', $js_content );
142 }
143 ?>
144
145