PluginProbe
WP Directory Kit / 1.2.3
WP Directory Kit v1.2.3
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 / classes / wdk-listing-map.php

wdk-listing-map.php in WP Directory Kit 1.2.3, at elementor-elements/classes/wdk-listing-map.php

571 lines 21.2 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 namespace Wdk\Elementor\Widgets;
4
5 use Wdk\Elementor\Widgets\WdkElementorBase;
6 use Elementor\Widget_Base;
7 use Elementor\Controls_Manager;
8 use Elementor\Utils;
9 use Elementor\Typography;
10 use Elementor\Editor;
11 use Elementor\Plugin;
12 use Elementor\Repeater;
13 use Elementor\Core\Schemes;
14 use Elementor\Icons_Manager;
15 use Elementor\Group_Control_Typography;
16 use Elementor\Group_Control_Border;
17 use Elementor\Group_Control_Box_Shadow;
18
19 if (!defined('ABSPATH'))
20 exit; // Exit if accessed directly
21
22 /**
23 * @since 1.1.0
24 */
25 class WdkListingMap extends WdkElementorBase {
26
27 public function __construct($data = array(), $args = null) {
28
29 \Elementor\Controls_Manager::add_tab(
30 'tab_conf',
31 esc_html__('Settings', 'wpdirectorykit')
32 );
33
34 \Elementor\Controls_Manager::add_tab(
35 'tab_layout',
36 esc_html__('InfoWindow', 'wpdirectorykit')
37 );
38
39 \Elementor\Controls_Manager::add_tab(
40 'tab_content',
41 esc_html__('Main', 'wpdirectorykit')
42 );
43
44 if ($this->is_edit_mode_load()) {
45 $this->enqueue_styles_scripts();
46 }
47
48 parent::__construct($data, $args);
49 }
50
51 /**
52 * Retrieve the list of categories the widget belongs to.
53 *
54 * Used to determine where to display the widget in the editor.
55 *
56 * Note that currently Elementor supports only one category.
57 * When multiple categories passed, Elementor uses the first one.
58 *
59 * @since 1.1.0
60 *
61 * @access public
62 *
63 * @return array Widget categories.
64 */
65 public function get_categories() {
66 return [ 'wdk-elementor-listing-preview' ];
67 }
68
69 /**
70 * Retrieve the widget name.
71 *
72 * @since 1.1.0
73 *
74 * @access public
75 *
76 * @return string Widget name.
77 */
78 public function get_name() {
79 return 'wdk-listing-map';
80 }
81
82 /**
83 * Retrieve the widget title.
84 *
85 * @since 1.1.0
86 *
87 * @access public
88 *
89 * @return string Widget title.
90 */
91 public function get_title() {
92 return esc_html__('Wdk Listing Map', 'wpdirectorykit');
93 }
94
95 /**
96 * Retrieve the widget icon.
97 *
98 * @since 1.1.0
99 *
100 * @access public
101 *
102 * @return string Widget icon.
103 */
104 public function get_icon() {
105 return 'eicon-google-maps';
106 }
107
108 /**
109 * Register the widget controls.
110 *
111 * Adds different input fields to allow the user to change and customize the widget settings.
112 *
113 * @since 1.1.0
114 *
115 * @access protected
116 */
117 protected function register_controls() {
118 $this->generate_controls_conf();
119 $this->generate_controls_layout();
120 $this->generate_controls_styles();
121 $this->generate_controls_content();
122
123 $this->insert_pro_message('1');
124 parent::register_controls();
125 }
126
127 /**
128 * Render the widget output on the frontend.
129 *
130 * Written in PHP and used to generate the final HTML.
131 *
132 * @since 1.1.0
133 *
134 * @access protected
135 */
136
137 protected function render() {
138 parent::render();
139 global $wdk_listing_id;
140
141 $this->data['id_element'] = $this->get_id();
142 $this->data['settings'] = $this->get_settings();
143
144 /* default from settings */
145 $this->data['lat'] = wdk_get_option('wdk_default_lat', 51.505);
146 $this->data['lng'] = wdk_get_option('wdk_default_lng', -0.09);
147 $this->data['wdk_listing_id'] = $wdk_listing_id;
148
149 if(!Plugin::$instance->editor->is_edit_mode() && !empty($wdk_listing_id)) {
150 $this->data['lat'] = wdk_field_value ('lat', $wdk_listing_id);
151 $this->data['lng'] = wdk_field_value ('lng', $wdk_listing_id);
152 } else {
153
154 }
155
156 $this->data['is_edit_mode']= false;
157 if(Plugin::$instance->editor->is_edit_mode() || empty($wdk_listing_id)) {
158 $this->data['is_edit_mode']= true;
159 }
160
161 echo $this->view('wdk-listing-map', $this->data);
162 }
163
164 private function generate_controls_conf() {
165 if(true){
166 $this->start_controls_section(
167 'conf_custom_map',
168 [
169 'label' => esc_html__('Map', 'wpdirectorykit'),
170 'tab' => '1',
171 ]
172 );
173
174 $this->add_responsive_control(
175 'conf_custom_map_height',
176 [
177 'label' => esc_html__('Height', 'wpdirectorykit'),
178 'type' => Controls_Manager::SLIDER,
179 'range' => [
180 'px' => [
181 'min' => 100,
182 'max' => 1500,
183 ],
184 ],
185 'render_type' => 'template',
186 'default' => [
187 'size' => 350,
188 ],
189 'selectors' => [
190 '{{WRAPPER}} .wdk-element #wdk_map_results' => 'height: {{SIZE}}px !important',
191 ],
192 'separator' => 'after',
193 ]
194 );
195
196 $this->add_control(
197 'conf_custom_map_zoom_index',
198 [
199 'label' => esc_html__('Zoom Index', 'wpdirectorykit'),
200 'description' => esc_html__( 'Only active if auto centering is disabled', 'wpdirectorykit' ),
201 'type' => Controls_Manager::SLIDER,
202 'range' => [
203 'px' => [
204 'min' => 1,
205 'max' => 18,
206 ],
207 ],
208 'render_type' => 'template',
209 'default' => [
210 'size' => 7,
211 ],
212 ]
213 );
214
215 $this->add_responsive_control(
216 'conf_custom_dragging',
217 [
218 'label' => esc_html__( 'Dragging', 'wpdirectorykit' ),
219 'type' => Controls_Manager::SWITCHER,
220 'none' => esc_html__( 'True', 'wpdirectorykit' ),
221 'block' => esc_html__( 'False', 'wpdirectorykit' ),
222 'render_type' => 'template',
223 'return_value' => 'yes',
224 'default' => 'yes',
225 'separator' => 'before',
226 ]
227 );
228
229
230 $this->add_responsive_control(
231 'conf_custom_popup_enable',
232 [
233 'label' => esc_html__( 'Enable Infobox', 'wpdirectorykit' ),
234 'type' => Controls_Manager::SWITCHER,
235 'none' => esc_html__( 'True', 'wpdirectorykit' ),
236 'block' => esc_html__( 'False', 'wpdirectorykit' ),
237 'render_type' => 'template',
238 'return_value' => 'yes',
239 'default' => 'yes',
240 'separator' => 'before',
241 ]
242 );
243
244 $this->add_responsive_control(
245 'puopup_custom_content',
246 [
247 'label' => esc_html__( 'Custom Fields For Infobox', 'wpdirectorykit' ),
248 'type' => Controls_Manager::SWITCHER,
249 'none' => esc_html__( 'True', 'wpdirectorykit' ),
250 'block' => esc_html__( 'False', 'wpdirectorykit' ),
251 'render_type' => 'template',
252 'return_value' => 'yes',
253 'default' => '',
254 'conditions' => [
255 'terms' => [
256 [
257 'name' => 'conf_custom_popup_enable',
258 'operator' => '==',
259 'value' => 'yes',
260 ]
261 ],
262 ]
263 ]
264 );
265
266
267 $this->add_control(
268 'conf_custom_map_styles_h',
269 [
270 'label' => __( 'Map Styles', 'wpdirectorykit' ),
271 'type' => \Elementor\Controls_Manager::HEADING,
272 'separator' => 'before',
273 ]
274 );
275
276 $this->add_control(
277 'conf_custom_map_style',
278 [
279 'label' => esc_html__('Styles List', 'wpdirectorykit'),
280 'type' => Controls_Manager::SELECT,
281 'options' => [
282 '' => esc_html__('Default', 'wpdirectorykit'),
283 'custom' => esc_html__('Custom', 'wpdirectorykit'),
284 'https://cartodb-basemaps-{s}.global.ssl.fastly.net/light_all/{z}/{x}/{y}{r}.png' => esc_html__('Light', 'wpdirectorykit'),
285 'https://{s}.tile.openstreetmap.fr/hot/{z}/{x}/{y}.png' => esc_html__('Osmde', 'wpdirectorykit'),
286 'https://{s}.tile.opentopomap.org/{z}/{x}/{y}.png' => esc_html__('OpenTopoMap', 'wpdirectorykit'),
287 'https://{s}.tile.thunderforest.com/cycle/{z}/{x}/{y}.png' => esc_html__('OpenCycleMap', 'wpdirectorykit'),
288 'https://server.arcgisonline.com/ArcGIS/rest/services/World_Imagery/MapServer/tile/{z}/{y}/{x}' => esc_html__('WorldImagery', 'wpdirectorykit'),
289 'https://{s}.basemaps.cartocdn.com/light_all/{z}/{x}/{y}{r}.png' => esc_html__('Carto DarkMatter', 'wpdirectorykit'),
290 'https://{s}.basemaps.cartocdn.com/rastertiles/voyager/{z}/{x}/{y}{r}.png' => esc_html__('Carto Voyager', 'wpdirectorykit'),
291 'https://cartodb-basemaps-{s}.global.ssl.fastly.net/dark_all/{z}/{x}/{y}{r}.png' => esc_html__('Maptiler dark (demo)', 'wpdirectorykit'),
292 ],
293 'default' => '',
294 ]
295 );
296
297 $this->add_control(
298 'conf_custom_map_style_self',
299 [
300 'label' => esc_html__('Link to custom Map Style', 'wpdirectorykit'),
301 'description' => esc_html__( 'You can add some custom map by link example https://leaflet-extras.github.io/leaflet-providers/preview/ or create your custom style and put link for example on maps.cloudmade.com/editor', 'wpdirectorykit' ),
302 'type' => Controls_Manager::TEXTAREA,
303 'render_type' => 'template',
304 'conditions' => [
305 'terms' => [
306 [
307 'name' => 'conf_custom_map_style',
308 'operator' => '==',
309 'value' => 'custom',
310 ]
311 ],
312 ]
313 ]
314 );
315
316
317
318 $this->end_controls_section();
319 }
320
321
322 $this->start_controls_section(
323 'tab_conf_main_section',
324 [
325 'label' => esc_html__('Custom Popup Fields', 'wpdirectorykit'),
326 'tab' => '1',
327 'conditions' => [
328 'terms' => [
329 [
330 'name' => 'puopup_custom_content',
331 'operator' => '==',
332 'value' => 'yes',
333 ]
334 ],
335 ]
336 ]
337 );
338
339 $WMVC = &wdk_get_instance();
340 $WMVC->model('field_m');
341 $fields_data = $WMVC->field_m->get();
342 $fields_list = array('' => esc_html__('Not Selected', 'wpdirectorykit'));
343 $order_i = 0;
344
345 $fields_list [(++$order_i).'__section'] = esc_html__('-- Section Custom fields --', 'wpdirectorykit');
346 $fields_list [(++$order_i).'__idlisting'] = esc_html__('Id listing', 'wpdirectorykit');
347 $fields_list [(++$order_i).'__post_id'] = esc_html__('Post Id', 'wpdirectorykit');
348 $fields_list [(++$order_i).'__counter_views'] = esc_html__('Views counter', 'wpdirectorykit');
349 $fields_list [(++$order_i).'__lat'] = esc_html__('Gps Lat', 'wpdirectorykit');
350 $fields_list [(++$order_i).'__lng'] = esc_html__('Gps Lng', 'wpdirectorykit');
351 $fields_list [(++$order_i).'__date'] = esc_html__('Date', 'wpdirectorykit');
352 $fields_list [(++$order_i).'__date_modified'] = esc_html__('Date Modified', 'wpdirectorykit');
353 $fields_list [(++$order_i).'__post_title'] = esc_html__('WP Title', 'wpdirectorykit');
354 $fields_list [(++$order_i).'__post_content'] = esc_html__('WP Content', 'wpdirectorykit');
355 $fields_list [(++$order_i).'__address'] = esc_html__('Address', 'wpdirectorykit');
356 $fields_list [(++$order_i).'__category_id'] = esc_html__('Category', 'wpdirectorykit');
357 $fields_list [(++$order_i).'__location_id'] = esc_html__('Location', 'wpdirectorykit');
358
359 foreach($fields_data as $field)
360 {
361 if(wmvc_show_data('field_type', $field) == 'SECTION') {
362 $fields_list [(++$order_i).'section__'.wmvc_show_data('idfield', $field)] = '-- '.esc_html__('Section', 'wpdirectorykit').' '.wmvc_show_data('field_label', $field).' --';
363 } else {
364 $fields_list[(++$order_i).'__'.wmvc_show_data('idfield', $field)] = '#'.wmvc_show_data('idfield', $field).' '.wmvc_show_data('field_label', $field).'['.wmvc_show_data('field_type', $field).']';
365 }
366 }
367 $this->add_control(
368 'title_field_id',
369 [
370 'label' => __( 'Title Field', 'wpdirectorykit' ),
371 'type' => \Elementor\Controls_Manager::SELECT,
372 'default' => '',
373 'options' => $fields_list,
374 ]
375 );
376
377 $this->add_control(
378 'content_field_id',
379 [
380 'label' => __( 'Content Field', 'wpdirectorykit' ),
381 'type' => \Elementor\Controls_Manager::SELECT,
382 'default' => '',
383 'options' => $fields_list,
384 ]
385 );
386
387 $this->end_controls_section();
388
389 }
390
391 private function generate_controls_layout() {
392
393 /* default marker layout */
394 $this->generate_controls_layout_default();
395 }
396
397 private function generate_controls_styles() {
398 /* marker */
399 $this->start_controls_section(
400 'styles_marker_sec',
401 [
402 'label' => esc_html__('Marker', 'wpdirectorykit'),
403 'tab' => Controls_Manager::TAB_STYLE,
404 ]
405 );
406
407
408 $this->add_control(
409 'styles_marker_h',
410 [
411 'label' => esc_html__('Marker', 'wpdirectorykit'),
412 'type' => Controls_Manager::HEADING,
413 'separator' => 'before',
414 ]
415 );
416
417 $this->start_controls_tabs('marker_button_style');
418
419 $this->start_controls_tab(
420 'marker',
421 [
422 'label' => esc_html__('Normal', 'wpdirectorykit'),
423 ]
424 );
425
426 $this->add_control(
427 'styles_marker_color',
428 [
429 'label' => esc_html__('Marker Border Color', 'wpdirectorykit'),
430 'type' => Controls_Manager::COLOR,
431 'selectors' => [
432 '{{WRAPPER}} .wdk-element .wdk-map .wdk_marker-card::before' => 'background-color: {{VALUE}};',
433 ],
434 ]
435 );
436
437 $this->add_control(
438 'styles_marker_color_bckg',
439 [
440 'label' => esc_html__('Marker Color', 'wpdirectorykit'),
441 'type' => Controls_Manager::COLOR,
442 'selectors' => [
443 '{{WRAPPER}} .wdk-element .wdk_marker-card:after' => 'background-color: {{VALUE}};',
444 ],
445 ]
446 );
447
448 $this->add_control(
449 'styles_marker_color_text',
450 [
451 'label' => esc_html__('Marker Text Color', 'wpdirectorykit'),
452 'type' => Controls_Manager::COLOR,
453 'selectors' => [
454 '{{WRAPPER}} .wdk_face i' => 'color: {{VALUE}};',
455 ],
456 ]
457 );
458
459 $this->add_control(
460 'conf_custom_map_pin_icon',
461 [
462 'label' => esc_html__('Icon', 'wpdirectorykit'),
463 'type' => Controls_Manager::ICONS,
464 'label_block' => true,
465 'default' => [
466 'value' => 'fa fa-home',
467 'library' => 'solid',
468 ],
469 ]
470 );
471
472 $this->add_control(
473 'conf_custom_map_pin',
474 [
475 'label' => esc_html__('Custom Marker Pin Image', 'wpdirectorykit'),
476 'type' => Controls_Manager::MEDIA,
477 ]
478 );
479
480 $this->end_controls_tab();
481
482 $this->start_controls_tab(
483 'marker_hover',
484 [
485 'label' => esc_html__('Hover', 'wpdirectorykit'),
486 ]
487 );
488
489 $this->add_control(
490 'styles_marker_color_hover',
491 [
492 'label' => esc_html__('Marker Border Color', 'wpdirectorykit'),
493 'type' => Controls_Manager::COLOR,
494 'selectors' => [
495 '{{WRAPPER}} .wdk-element .wdk_marker-container:hover .wdk_marker-card:before' => 'background-color: {{VALUE}};',
496 ],
497 ]
498 );
499
500 $this->add_control(
501 'styles_marker_color_hover_bckg',
502 [
503 'label' => esc_html__('Marker Color', 'wpdirectorykit'),
504 'type' => Controls_Manager::COLOR,
505 'selectors' => [
506 '{{WRAPPER}} .wdk-element .wdk_marker-container:hover .wdk_marker-card:after' => 'background-color: {{VALUE}};',
507 ],
508 ]
509 );
510
511 $this->add_control(
512 'styles_marker_color_text_hover',
513 [
514 'label' => esc_html__('Marker Text Color', 'wpdirectorykit'),
515 'type' => Controls_Manager::COLOR,
516 'selectors' => [
517 '{{WRAPPER}} .wdk_marker-container:hover .wdk_face.back i, .wdk_marker-container:hover .wdk_face i' => 'color: {{VALUE}};',
518 ],
519 ]
520 );
521
522 $this->add_control(
523 'styles_marker_effect_duration',
524 [
525 'label' => esc_html__('Transition Duration', 'wpdirectorykit'),
526 'type' => Controls_Manager::SLIDER,
527 'render_type' => 'template',
528 'range' => [
529 'px' => [
530 'min' => 0,
531 'max' => 3000,
532 ],
533 ],
534 'selectors' => [
535 '{{WRAPPER}} .wdk_map-marker-container.clicked .wdk_face.front, .wdk_marker-container:hover .wdk_face.front' => 'transition-duration: {{SIZE}}ms',
536 ],
537 ]
538 );
539
540 $this->end_controls_tab();
541
542 $this->end_controls_tabs();
543 $this->end_controls_section();
544 }
545
546 private function generate_controls_content() {
547 }
548
549 private function generate_controls_layout_default() {
550
551 }
552
553 private function generate_controls_styles_default() {
554
555 }
556
557 public function enqueue_styles_scripts() {
558 wp_enqueue_style('leaflet');
559 wp_enqueue_style('leaflet-cluster-def');
560 wp_enqueue_style('leaflet-cluster');
561 wp_enqueue_script('leaflet');
562 wp_enqueue_script('leaflet-cluster');
563 wp_enqueue_script('leaflet-fullscreen');
564 wp_enqueue_style('leaflet-fullscreen');
565
566 wp_enqueue_style('wdk-notify');
567 wp_enqueue_script('wdk-notify');
568 wp_enqueue_style( 'wdk-listings-map' );
569 }
570 }
571