PluginProbe
WP Directory Kit / 1.2.9
WP Directory Kit v1.2.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
wpdirectorykit / elementor-elements / classes / wdk-map.php

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

1,261 lines 53.1 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 WdkMap 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 parent::__construct($data, $args);
44
45 if ($this->is_edit_mode_load()) {
46 wp_enqueue_style('leaflet');
47 wp_enqueue_style('leaflet-cluster-def');
48 wp_enqueue_style('leaflet-cluster');
49 wp_enqueue_style('leaflet-fullscreen');
50 wp_enqueue_script('leaflet');
51 wp_enqueue_script('leaflet-fullscreen');
52 wp_enqueue_script('leaflet-cluster');
53
54 wp_enqueue_style('wdk-notify');
55 wp_enqueue_script('wdk-notify');
56 wp_enqueue_style( 'wdk-listings-map' );
57 $this->enqueue_styles_scripts();
58 }
59 }
60
61 /**
62 * Retrieve the widget name.
63 *
64 * @since 1.1.0
65 *
66 * @access public
67 *
68 * @return string Widget name.
69 */
70 public function get_name() {
71 return 'wdk-map';
72 }
73
74 /**
75 * Retrieve the widget title.
76 *
77 * @since 1.1.0
78 *
79 * @access public
80 *
81 * @return string Widget title.
82 */
83 public function get_title() {
84 return esc_html__('Wdk Map', 'wpdirectorykit');
85 }
86
87 /**
88 * Retrieve the widget icon.
89 *
90 * @since 1.1.0
91 *
92 * @access public
93 *
94 * @return string Widget icon.
95 */
96 public function get_icon() {
97 return 'eicon-google-maps';
98 }
99
100 /**
101 * Register the widget controls.
102 *
103 * Adds different input fields to allow the user to change and customize the widget settings.
104 *
105 * @since 1.1.0
106 *
107 * @access protected
108 */
109 protected function register_controls() {
110 $this->generate_controls_conf();
111 $this->generate_controls_layout();
112 $this->generate_controls_styles();
113 $this->generate_controls_content();
114
115 $this->insert_pro_message('1');
116 parent::register_controls();
117 }
118
119 /**
120 * Render the widget output on the frontend.
121 *
122 * Written in PHP and used to generate the final HTML.
123 *
124 * @since 1.1.0
125 *
126 * @access protected
127 */
128 protected function render() {
129 parent::render();
130
131 /* default from settings */
132 $this->data['lat'] = wdk_get_option('wdk_default_lat', 51.505);
133 $this->data['lng'] = wdk_get_option('wdk_default_lng', -0.09);
134
135 $this->data['id_element'] = $this->get_id();
136 $this->data['settings'] = $this->get_settings();
137 $columns = array('ID', 'location_id', 'category_id', 'post_title', 'post_date', 'search', 'order_by','is_featured', 'address');
138 $controller = 'listing';
139 $custom_parameters = array();
140
141 if($this->data['settings']['enable_custom_gps_center'] == 'yes') {
142 $this->data['lat'] = $this->data['settings']['conf_custom_map_center_gps_lat'];
143 $this->data['lng'] = $this->data['settings']['conf_custom_map_center_gps_lng'];
144 }
145
146 if(!isset($_GET['order_by'])) {
147 $custom_parameters['order_by'] = $this->data['settings']['conf_order_by'].' '.$this->data['settings']['conf_order'];
148 }
149
150 if(!isset($_GET['conf_order_by_custom'])) {
151 $custom_parameters['order_by'] = $this->data['settings']['conf_order_by_custom'].' '.$this->data['settings']['conf_order'];
152 }
153
154 if(!empty($this->data['settings']['conf_query'])) {
155 $qr_string = trim($this->data['settings']['conf_query'],'?');
156 $string_par = array();
157 parse_str($qr_string, $string_par);
158 $custom_parameters += array_map('trim', $string_par);
159 }
160
161 $external_columns = array('location_id', 'category_id', 'post_title');
162 wdk_prepare_search_query_GET($columns, $controller.'_m', $external_columns, $custom_parameters);
163 $this->data['results'] = $this->WMVC->listing_m->get_pagination($this->data['settings']['conf_limit'], NULL, array('is_activated' => 1,'is_approved'=>1));
164
165 $this->data['settings']['content_button_icon'] = '';
166
167 $this->data['is_edit_mode']= false;
168 if(Plugin::$instance->editor->is_edit_mode())
169 $this->data['is_edit_mode']= true;
170
171 echo $this->view('wdk-map', $this->data);
172
173 }
174
175 private function generate_controls_conf() {
176 $this->start_controls_section(
177 'tab_conf_main_section',
178 [
179 'label' => esc_html__('Main', 'wpdirectorykit'),
180 'tab' => '1',
181 ]
182 );
183
184 /* conf_results_type :: results_listings */
185 if(true){
186 $this->add_control(
187 'conf_results_type_results_listings_header',
188 [
189 'label' => esc_html__('Results listings', 'wpdirectorykit'),
190 'type' => Controls_Manager::HEADING,
191 'separator' => 'before',
192 ]
193 );
194
195 $this->add_control(
196 'conf_hide_real_location',
197 [
198 'label' => esc_html__( 'Hide real location', 'wpdirectorykit' ),
199 'type' => Controls_Manager::SWITCHER,
200 'none' => esc_html__( 'True', 'wpdirectorykit' ),
201 'block' => esc_html__( 'False', 'wpdirectorykit' ),
202 'render_type' => 'template',
203 'return_value' => 'yes',
204 'default' => '',
205 'separator' => 'after',
206 ]
207 );
208
209 $this->add_control(
210 'conf_limit',
211 [
212 'label' => __( 'Limit Results', 'wpdirectorykit' ),
213 'type' => \Elementor\Controls_Manager::NUMBER,
214 'min' => 1,
215 'max' => 10000,
216 'step' => 1,
217 'default' => 350,
218 ]
219 );
220
221 $this->add_control(
222 'conf_query',
223 [
224 'label' => __( 'Query', 'wpdirectorykit' ),
225 'type' => \Elementor\Controls_Manager::TEXTAREA,
226 'rows' => 5,
227 'default' => '',
228 'placeholder' => __( 'Type your query here, example xxx', 'wpdirectorykit' ),
229 'description' => '<span style="word-break: break-all;">'.__( 'Example (same like on url):', 'wpdirectorykit' ).
230 ' field_6_min=100&field_6_max=200&field_5=rent&is_featured=on&search_category=3&search_location=4&search_agents_ids=3'.
231 '</span>',
232 ]
233 );
234
235 $this->add_control(
236 'conf_order_by',
237 [
238 'label' => __('Default Sort By Column', 'wpdirectorykit'),
239 'type' => Controls_Manager::SELECT,
240 'label_block' => true,
241 'options' => [
242 'none' => __('None', 'wpdirectorykit'),
243 'post_id' => __('ID', 'wpdirectorykit'),
244 'category_id' => __('Category', 'wpdirectorykit'),
245 ],
246 'default' => 'post_id',
247 ]
248 );
249
250 $this->add_control(
251 'conf_order_by_custom',
252 [
253 'label' => __('Default Custom Sort By (Column)', 'wpdirectorykit'),
254 'description' => '<span style="word-break: break-all;">'.__( 'Example:', 'wpdirectorykit' ).
255 '<br> field_13_NUMBER - where 13 is field id, NUMBER - field type'.
256 '<br> field_4_NUMBER - where 4 is field id, NUMBER - field type'.
257 '<br> field_6_DROPDOWN - where 6 is field id, DROPDOWN - field type'.
258 '<br> category_title - Category Title'.
259 '<br> location_title - Location Title'.
260 '</span>',
261 'type' => Controls_Manager::TEXT,
262 'label_block' => true,
263 'default' => 'post_id',
264 ]
265 );
266
267 $this->add_control(
268 'conf_order',
269 [
270 'label' => __('Default Listing Order', 'wpdirectorykit'),
271 'type' => Controls_Manager::SELECT,
272 'label_block' => true,
273 'options' => [
274 'asc' => __('Ascending', 'wpdirectorykit'),
275 'desc' => __('Descending', 'wpdirectorykit')
276 ],
277 'default' => 'desc',
278 ]
279 );
280
281
282 $fields_data = wdk_cached_field_get();
283 $fields_list = array('' => esc_html__('Not Selected', 'wpdirectorykit'));
284 $order_i = 0;
285
286 $fields_list [(++$order_i).'__section'] = esc_html__('-- Section Custom fields --', 'wpdirectorykit');
287 $fields_list [(++$order_i).'__first_image'] = esc_html__('First Image', 'wpdirectorykit');
288 $fields_list [(++$order_i).'__counter_views'] = esc_html__('Views counter', 'wpdirectorykit');
289 $fields_list [(++$order_i).'__post_title'] = esc_html__('WP Title', 'wpdirectorykit');
290
291 $fields_list [(++$order_i).'__date'] = esc_html__('Date', 'wpdirectorykit');
292 $fields_list [(++$order_i).'__address'] = esc_html__('Address', 'wpdirectorykit');
293 $fields_list [(++$order_i).'__category_title'] = esc_html__('Category', 'wpdirectorykit');
294 $fields_list [(++$order_i).'__location_title'] = esc_html__('Location', 'wpdirectorykit');
295
296 foreach($fields_data as $field)
297 {
298 if(wmvc_show_data('field_type', $field) == 'SECTION') {
299 $fields_list [(++$order_i).'section__'.wmvc_show_data('idfield', $field)] = '-- '.esc_html__('Section', 'wpdirectorykit').' '.wmvc_show_data('field_label', $field).' --';
300 } else {
301 $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).']';
302 }
303 }
304
305 $this->add_control(
306 'custom_marker_fields',
307 [
308 'label' => __('Show field value instead of marker on map', 'wpdirectorykit'),
309 'type' => \Elementor\Controls_Manager::SELECT,
310 'default' => '',
311 'label_block' => true,
312 'options' => $fields_list,
313 'separator' => 'after',
314 ]
315 );
316
317 }
318
319 $this->end_controls_section();
320
321 if(true){
322 $this->start_controls_section(
323 'conf_custom_map',
324 [
325 'label' => esc_html__('Map', 'wpdirectorykit'),
326 'tab' => '1',
327 ]
328 );
329
330 $this->add_responsive_control(
331 'conf_custom_map_height',
332 [
333 'label' => esc_html__('Height', 'wpdirectorykit'),
334 'type' => Controls_Manager::SLIDER,
335 'range' => [
336 'px' => [
337 'min' => 100,
338 'max' => 1500,
339 ],
340 ],
341 'render_type' => 'template',
342 'default' => [
343 'size' => 350,
344 ],
345 'selectors' => [
346 '{{WRAPPER}} .wdk-element .wdk_map_results' => 'height: {{SIZE}}px !important',
347 ],
348 'separator' => 'after',
349 ]
350 );
351
352 $this->add_control(
353 'conf_custom_map_zoom_index',
354 [
355 'label' => esc_html__('Zoom Index', 'wpdirectorykit'),
356 'description' => esc_html__( 'Only active if auto centering is disabled', 'wpdirectorykit' ),
357 'type' => Controls_Manager::SLIDER,
358 'range' => [
359 'px' => [
360 'min' => 1,
361 'max' => 18,
362 ],
363 ],
364 'render_type' => 'template',
365 'default' => [
366 'size' => 7,
367 ]
368 ]
369 );
370
371 $this->add_control(
372 'conf_custom_dragging',
373 [
374 'label' => esc_html__( 'Dragging For Desktop', 'wpdirectorykit' ),
375 'type' => Controls_Manager::SWITCHER,
376 'none' => esc_html__( 'True', 'wpdirectorykit' ),
377 'block' => esc_html__( 'False', 'wpdirectorykit' ),
378 'render_type' => 'template',
379 'return_value' => 'yes',
380 'default' => 'yes',
381 'separator' => 'before',
382 ]
383 );
384
385 $this->add_control(
386 'conf_custom_dragging_mobile',
387 [
388 'label' => esc_html__( 'Dragging For Mobile', 'wpdirectorykit' ),
389 'type' => Controls_Manager::SWITCHER,
390 'none' => esc_html__( 'True', 'wpdirectorykit' ),
391 'block' => esc_html__( 'False', 'wpdirectorykit' ),
392 'render_type' => 'template',
393 'return_value' => 'yes',
394 'default' => '',
395 'separator' => 'before',
396 ]
397 );
398
399 $this->add_control(
400 'conf_custom_map_styles_h',
401 [
402 'label' => __( 'Map Styles', 'wpdirectorykit' ),
403 'type' => \Elementor\Controls_Manager::HEADING,
404 'separator' => 'before',
405 ]
406 );
407
408 $this->add_control(
409 'conf_custom_map_style',
410 [
411 'label' => esc_html__('Styles List', 'wpdirectorykit'),
412 'type' => Controls_Manager::SELECT,
413 'options' => [
414 '' => esc_html__('Default', 'wpdirectorykit'),
415 'custom' => esc_html__('Custom', 'wpdirectorykit'),
416 'https://cartodb-basemaps-{s}.global.ssl.fastly.net/light_all/{z}/{x}/{y}{r}.png' => esc_html__('Light', 'wpdirectorykit'),
417 'https://{s}.tile.openstreetmap.fr/hot/{z}/{x}/{y}.png' => esc_html__('Osmde', 'wpdirectorykit'),
418 'https://{s}.tile.openstreetmap.fr/osmfr/{z}/{x}/{y}.png' => esc_html__('Osmde Fr', 'wpdirectorykit'),
419 'https://tile.openstreetmap.de/{z}/{x}/{y}.png' => esc_html__('Osmde De', 'wpdirectorykit'),
420 'https://tile.openstreetmap.org/{z}/{x}/{y}.png' => esc_html__('Mapnik', 'wpdirectorykit'),
421 'https://{s}.tile.opentopomap.org/{z}/{x}/{y}.png' => esc_html__('OpenTopoMap', 'wpdirectorykit'),
422 'https://server.arcgisonline.com/ArcGIS/rest/services/World_Imagery/MapServer/tile/{z}/{y}/{x}' => esc_html__('WorldImagery', 'wpdirectorykit'),
423 'https://{s}.basemaps.cartocdn.com/light_all/{z}/{x}/{y}{r}.png' => esc_html__('Carto DarkMatter', 'wpdirectorykit'),
424 'https://{s}.basemaps.cartocdn.com/rastertiles/voyager/{z}/{x}/{y}{r}.png' => esc_html__('Carto Voyager', 'wpdirectorykit'),
425 'https://cartodb-basemaps-{s}.global.ssl.fastly.net/dark_all/{z}/{x}/{y}{r}.png' => esc_html__('Maptiler dark (demo)', 'wpdirectorykit'),
426 'https://{s}.tile.thunderforest.com/mobile-atlas/{z}/{x}/{y}.png' => esc_html__('Thunderforest MobileAtlas', 'wpdirectorykit'),
427 'https://{s}.tile.thunderforest.com/cycle/{z}/{x}/{y}.png' => esc_html__('Thunderforest OpenCycleMap', 'wpdirectorykit'),
428 'https://{s}.tile.thunderforest.com/transport-dark/{z}/{x}/{y}.png' => esc_html__('Thunderforest TransportDark', 'wpdirectorykit'),
429 'https://{s}.tile.thunderforest.com/landscape/{z}/{x}/{y}.png' => esc_html__('Thunderforest Landscape', 'wpdirectorykit'),
430 'https://{s}.tile.thunderforest.com/outdoors/{z}/{x}/{y}.png' => esc_html__('Thunderforest Outdoors', 'wpdirectorykit'),
431 'https://{s}.tile.thunderforest.com/pioneer/{z}/{x}/{y}.png' => esc_html__('Thunderforest Pioneer', 'wpdirectorykit'),
432 'https://{s}.tile.thunderforest.com/neighbourhood/{z}/{x}/{y}.png' => esc_html__('Thunderforest Neighbourhood', 'wpdirectorykit'),
433 'https://{s}.tile-cyclosm.openstreetmap.fr/cyclosm/{z}/{x}/{y}.png' => esc_html__('CyclOSM', 'wpdirectorykit'),
434 'https://{s}.tile.jawg.io/jawg-terrain/{z}/{x}/{y}{r}.png' => esc_html__('Jawg Streets', 'wpdirectorykit'),
435 'https://{s}.tile.jawg.io/jawg-streets/{z}/{x}/{y}{r}.png' => esc_html__('Jawg Sunny', 'wpdirectorykit'),
436 'https://{s}.tile.jawg.io/jawg-dark/{z}/{x}/{y}{r}.png' => esc_html__('Jawg Dark', 'wpdirectorykit'),
437 'https://{s}.tile.jawg.io/jawg-light/{z}/{x}/{y}{r}.png' => esc_html__('Jawg Light', 'wpdirectorykit'),
438 'https://server.arcgisonline.com/ArcGIS/rest/services/World_Topo_Map/MapServer/tile/{z}/{y}/{x}' => esc_html__('World Top oMap', 'wpdirectorykit'),
439 'google_map' => esc_html__('Google Map Layout', 'wpdirectorykit'),
440 ],
441 'default' => '',
442 ]
443 );
444
445 $this->add_control(
446 'jawg_map_key',
447 [
448 'label' => __( 'Jawg Map API Key', 'wpdirectorykit' ),
449 'description' => wdk_sprintf(__( 'Please follow link and get API key <a href="%1$s" target="_blank"> here </a>', 'wpdirectorykit' ), 'https://www.jawg.io/en/pricing')
450 .' '.wdk_sprintf(__( 'or check demo maps <a href="%1$s" target="_blank"> here </a>', 'wpdirectorykit' ), 'https://www.jawg.io/en/maps'),
451 'type' => \Elementor\Controls_Manager::TEXT,
452 'default' => '',
453 'condition' => [
454 'conf_custom_map_style' => [
455 'https://{s}.tile.jawg.io/jawg-terrain/{z}/{x}/{y}{r}.png',
456 'https://{s}.tile.jawg.io/jawg-streets/{z}/{x}/{y}{r}.png',
457 'https://{s}.tile.jawg.io/jawg-dark/{z}/{x}/{y}{r}.png',
458 'https://{s}.tile.jawg.io/jawg-light/{z}/{x}/{y}{r}.png',
459 ],
460 ],
461 ]
462 );
463
464 $this->add_control(
465 'thunderforest_map_key',
466 [
467 'label' => __( 'Thunderforest Map API Key', 'wpdirectorykit' ),
468 'description' => wdk_sprintf(__( 'Please follow link and get API key <a href="%1$s" target="_blank"> here </a>', 'wpdirectorykit' ), 'https://www.thunderforest.com/pricing/'),
469 'type' => \Elementor\Controls_Manager::TEXT,
470 'default' => '',
471 'condition' => [
472 'conf_custom_map_style' => [
473 'https://{s}.tile.thunderforest.com/mobile-atlas/{z}/{x}/{y}.png',
474 'https://{s}.tile.thunderforest.com/cycle/{z}/{x}/{y}.png',
475 'https://{s}.tile.thunderforest.com/transport-dark/{z}/{x}/{y}.png',
476 'https://{s}.tile.thunderforest.com/landscape/{z}/{x}/{y}.png',
477 'https://{s}.tile.thunderforest.com/outdoors/{z}/{x}/{y}.png',
478 'https://{s}.tile.thunderforest.com/pioneer/{z}/{x}/{y}.png',
479 'https://{s}.tile.thunderforest.com/neighbourhood/{z}/{x}/{y}.png',
480 ],
481 ],
482 ]
483 );
484
485 $this->add_control(
486 'google_map_key',
487 [
488 'label' => __( 'Google Map API Key', 'wpdirectorykit' ),
489 'description' => wdk_sprintf(__( 'Please follow link and get API key <a href="%1$s" target="_blank"> here </a>', 'wpdirectorykit' ), 'https://developers.google.com/maps/documentation/javascript/get-api-key'),
490 'type' => \Elementor\Controls_Manager::TEXT,
491 'default' => '',
492 'condition' => [
493 'conf_custom_map_style' => ['google_map'],
494 ],
495 ]
496 );
497
498 $this->add_control(
499 'google_map_default_type',
500 [
501 'label' => __( 'Default Type', 'wpdirectorykit' ),
502 'type' => \Elementor\Controls_Manager::SELECT,
503 'default' => 'roadmap',
504 'options' => array(
505 'roadmap' => __( 'Roadmap', 'wpdirectorykit' ),
506 'aerial' => __( 'Aerial', 'wpdirectorykit' ),
507 'terrain' => __( 'Terrain', 'wpdirectorykit' ),
508 'hybrid' => __( 'Hybrid', 'wpdirectorykit' ),
509 'satellite' => __( 'Satellite', 'wpdirectorykit' ),
510 'traffic' => __( 'Traffic', 'wpdirectorykit' ),
511 'transit' => __( 'Transit', 'wpdirectorykit' ),
512 ),
513 'condition' => [
514 'conf_custom_map_style' => ['google_map'],
515 ],
516 ]
517 );
518
519 $this->add_control(
520 'conf_custom_map_style_self',
521 [
522 'label' => esc_html__('Link to custom Map Style', 'wpdirectorykit'),
523 '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' ),
524 'type' => Controls_Manager::TEXTAREA,
525 'render_type' => 'template',
526 'conditions' => [
527 'terms' => [
528 [
529 'name' => 'conf_custom_map_style',
530 'operator' => '==',
531 'value' => 'custom',
532 ]
533 ],
534 ]
535 ]
536 );
537
538 $this->end_controls_section();
539 }
540
541 $this->start_controls_section(
542 'conf_map_position',
543 [
544 'label' => esc_html__('Map Positioning', 'wpdirectorykit'),
545 'tab' => '1',
546 ]
547 );
548
549 $this->add_control(
550 'conf_custom_map_center_gps_lat',
551 [
552 'label' => esc_html__('GPS lat Center', 'wpdirectorykit'),
553 'type' => Controls_Manager::TEXT,
554 'default' => '45.675243',
555 ]
556 );
557
558 $this->add_control(
559 'conf_custom_map_center_gps_lng',
560 [
561 'label' => esc_html__('GPS lng Center', 'wpdirectorykit'),
562 'type' => Controls_Manager::TEXT,
563 'default' => '5.907848',
564 ]
565 );
566
567
568 $this->add_responsive_control(
569 'enable_custom_gps_center',
570 [
571 'label' => esc_html__( 'Enable custom GPS', 'wpdirectorykit' ),
572 'type' => Controls_Manager::SWITCHER,
573 'none' => esc_html__( 'True', 'wpdirectorykit' ),
574 'block' => esc_html__( 'False', 'wpdirectorykit' ),
575 'render_type' => 'template',
576 'return_value' => 'yes',
577 'default' => '',
578 ]
579 );
580
581 $this->end_controls_section();
582
583 }
584
585 private function generate_controls_layout() {
586
587 /* default marker layout */
588 $this->generate_controls_layout_default();
589 }
590
591 private function generate_controls_styles() {
592 /* default marker layout */
593 $this->generate_controls_styles_default();
594
595 /* marker */
596 $this->start_controls_section(
597 'styles_cluster',
598 [
599 'label' => esc_html__('Cluster', 'wpdirectorykit'),
600 'tab' => Controls_Manager::TAB_STYLE,
601 ]
602 );
603
604 $this->add_responsive_control(
605 'disable_cluster',
606 [
607 'label' => esc_html__( 'Disable Clusters', 'wpdirectorykit' ),
608 'type' => Controls_Manager::SWITCHER,
609 'none' => esc_html__( 'True', 'wpdirectorykit' ),
610 'block' => esc_html__( 'False', 'wpdirectorykit' ),
611 'render_type' => 'template',
612 'return_value' => 'yes',
613 'default' => '',
614 ]
615 );
616
617 $this->add_control(
618 'styles_cluster_color',
619 [
620 'label' => esc_html__('Cluster Color', 'wpdirectorykit'),
621 'type' => Controls_Manager::COLOR,
622 'selectors' => [
623 '{{WRAPPER}} .marker-cluster div' => 'background-color: {{VALUE}};',
624 ],
625 ]
626 );
627
628 $this->add_control(
629 'styles_cluster_color_border',
630 [
631 'label' => esc_html__('Cluster Color Border', 'wpdirectorykit'),
632 'type' => Controls_Manager::COLOR,
633 'selectors' => [
634 '{{WRAPPER}} .marker-cluster div::before' => 'border: 6px solid {{VALUE}}; box-shadow: inset 0 0 0 4px {{VALUE}};',
635 ],
636 ]
637 );
638
639 $this->add_control(
640 'styles_cluster_color_text',
641 [
642 'label' => esc_html__('Cluster Color Text', 'wpdirectorykit'),
643 'type' => Controls_Manager::COLOR,
644 'selectors' => [
645 '{{WRAPPER}} .marker-cluster div' => 'color: {{VALUE}};',
646 ],
647 ]
648 );
649
650 $this->add_group_control(
651 Group_Control_Typography::get_type(),
652 [
653 'name' => 'styles_cluster_color_font',
654 'selector' => '{{WRAPPER}} .marker-cluster div',
655 ]
656 );
657
658 $this->end_controls_section();
659
660 /* marker */
661 $this->start_controls_section(
662 'styles_marker_sec',
663 [
664 'label' => esc_html__('Marker', 'wpdirectorykit'),
665 'tab' => Controls_Manager::TAB_STYLE,
666 ]
667 );
668
669
670 $this->add_control(
671 'styles_marker_h',
672 [
673 'label' => esc_html__('Marker', 'wpdirectorykit'),
674 'type' => Controls_Manager::HEADING,
675 'separator' => 'before',
676 ]
677 );
678
679 $this->start_controls_tabs('marker_button_style');
680
681 $this->start_controls_tab(
682 'marker',
683 [
684 'label' => esc_html__('Normal', 'wpdirectorykit'),
685 ]
686 );
687
688 $this->add_control(
689 'styles_marker_color',
690 [
691 'label' => esc_html__('Marker Border Color', 'wpdirectorykit'),
692 'type' => Controls_Manager::COLOR,
693 'selectors' => [
694 '{{WRAPPER}} .wdk-element .wdk-map .wdk_marker-card::before' => 'background-color: {{VALUE}};',
695 '{{WRAPPER}} .wdk-element .wdk_marker-container.wdk_marker_label' => 'border-color: {{VALUE}};',
696 ],
697 ]
698 );
699
700 $this->add_control(
701 'styles_marker_color_bckg',
702 [
703 'label' => esc_html__('Marker Color', 'wpdirectorykit'),
704 'type' => Controls_Manager::COLOR,
705 'selectors' => [
706 '{{WRAPPER}} .wdk-element .wdk_marker-card:after' => 'background-color: {{VALUE}};',
707 '{{WRAPPER}} .wdk-element .wdk_marker-container.wdk_marker_label' => 'background-color: {{VALUE}};',
708 ],
709 ]
710 );
711
712 $this->add_control(
713 'styles_marker_color_text',
714 [
715 'label' => esc_html__('Marker Text Color', 'wpdirectorykit'),
716 'type' => Controls_Manager::COLOR,
717 'selectors' => [
718 '{{WRAPPER}} .wdk_face i' => 'color: {{VALUE}};',
719 '{{WRAPPER}} .wdk_marker-container.wdk_marker_label' => 'color: {{VALUE}};',
720 ],
721 ]
722 );
723
724 $this->add_control(
725 'conf_custom_map_pin_icon',
726 [
727 'label' => esc_html__('Icon', 'wpdirectorykit'),
728 'type' => Controls_Manager::ICONS,
729 'label_block' => true,
730 'default' => [
731 'value' => 'fa fa-home',
732 'library' => 'solid',
733 ],
734 'exclude_inline_options' => array('svg'),
735 ]
736 );
737
738 $this->add_control(
739 'conf_custom_map_pin',
740 [
741 'label' => esc_html__('Custom Marker Pin Image', 'wpdirectorykit'),
742 'type' => Controls_Manager::MEDIA,
743 ]
744 );
745
746 $this->end_controls_tab();
747
748 $this->start_controls_tab(
749 'marker_hover',
750 [
751 'label' => esc_html__('Hover', 'wpdirectorykit'),
752 ]
753 );
754
755 $this->add_control(
756 'styles_marker_color_hover',
757 [
758 'label' => esc_html__('Marker Border Color', 'wpdirectorykit'),
759 'type' => Controls_Manager::COLOR,
760 'selectors' => [
761 '{{WRAPPER}} .wdk-element .wdk_marker-container:hover .wdk_marker-card:before' => 'background-color: {{VALUE}};',
762 '{{WRAPPER}} .wdk-element .wdk_marker-container.wdk_marker_label:hover' => 'border-color: {{VALUE}};',
763 ],
764 ]
765 );
766
767 $this->add_control(
768 'styles_marker_color_hover_bckg',
769 [
770 'label' => esc_html__('Marker Color', 'wpdirectorykit'),
771 'type' => Controls_Manager::COLOR,
772 'selectors' => [
773 '{{WRAPPER}} .wdk-element .wdk_marker-container:hover .wdk_marker-card:after' => 'background-color: {{VALUE}};',
774 '{{WRAPPER}} .wdk-element .wdk_marker-container.wdk_marker_label:hover' => 'background-color: {{VALUE}};',
775 ],
776 ]
777 );
778
779 $this->add_control(
780 'styles_marker_color_text_hover',
781 [
782 'label' => esc_html__('Marker Text Color', 'wpdirectorykit'),
783 'type' => Controls_Manager::COLOR,
784 'selectors' => [
785 '{{WRAPPER}} .wdk_marker-container:hover .wdk_face.back i, .wdk_marker-container:hover .wdk_face i' => 'color: {{VALUE}};',
786 '{{WRAPPER}} .wdk_marker-container.wdk_marker_label:hover' => 'color: {{VALUE}};',
787 ],
788 ]
789 );
790
791 $this->add_control(
792 'styles_marker_effect_duration',
793 [
794 'label' => esc_html__('Transition Duration', 'wpdirectorykit'),
795 'type' => Controls_Manager::SLIDER,
796 'render_type' => 'template',
797 'range' => [
798 'px' => [
799 'min' => 0,
800 'max' => 3000,
801 ],
802 ],
803 'selectors' => [
804 '{{WRAPPER}} .wdk_map-marker-container.clicked .wdk_face.front, .wdk_marker-container:hover .wdk_face.front' => 'transition-duration: {{SIZE}}ms',
805 '{{WRAPPER}} .wdk_marker-container.wdk_marker_label' => 'transition-duration: {{SIZE}}ms',
806 ],
807 ]
808 );
809
810 $this->end_controls_tab();
811
812 $this->end_controls_tabs();
813 $this->end_controls_section();
814
815
816
817
818 }
819
820 private function generate_controls_content() {
821 /* default marker layout */
822 $this->generate_controls_content_default();
823 }
824
825 private function generate_controls_layout_default() {
826
827 }
828
829 private function generate_controls_styles_default() {
830 $this->start_controls_section(
831 'styles_thmbn_section',
832 [
833 'label' => esc_html__('Section Image', 'wpdirectorykit'),
834 'tab' => Controls_Manager::TAB_STYLE,
835 ]
836 );
837
838 $this->add_responsive_control(
839 'styles_thmbn_des_type',
840 [
841 'label' => __( 'Design type', 'wpdirectorykit' ),
842 'type' => \Elementor\Controls_Manager::SELECT,
843 'default' => 'wdk_size_image_cover',
844 'options' => [
845 '' => __( 'Default Sizes', 'wpdirectorykit' ),
846 'wdk_size_image_cover' => __( 'Image auto crop/resize', 'wpdirectorykit' ),
847 ],
848 ]
849 );
850
851 $this->add_responsive_control(
852 'styles_thmbn_des_height',
853 [
854 'label' => esc_html__('Height', 'wpdirectorykit'),
855 'type' => Controls_Manager::SLIDER,
856 'range' => [
857 'px' => [
858 'min' => 50,
859 'max' => 1500,
860 ],
861 ],
862 'render_type' => 'ui',
863 'default' => [
864 'size' => 350,
865 ],
866 'selectors' => [
867 '{{WRAPPER}} .wdk_size_image_cover .wdk-listing-card .wdk-thumbnail .wdk-image' => 'height: {{SIZE}}px',
868 ],
869 'separator' => 'after',
870 'conditions' => [
871 'relation' => 'or',
872 'terms' => [
873 [
874 'name' => 'styles_thmbn_des_type',
875 'operator' => '==',
876 'value' => 'wdk_size_image_cover',
877 ],
878 [
879 'name' => 'styles_thmbn_des_type',
880 'operator' => '==',
881 'value' => 'wdk_image_cover',
882 ]
883 ],
884 ]
885 ]
886 );
887 $this->end_controls_section();
888 }
889
890 private function generate_controls_content_default() {
891 $this->start_controls_section(
892 'content_thumbnail_section',
893 [
894 'label' => esc_html__('Colors', 'wpdirectorykit'),
895 'tab' => 'tab_layout',
896 ]
897 );
898
899 $this->add_control(
900 'content_thumbnail_section_header',
901 [
902 'label' => esc_html__('Color Hover Thumbnail', 'wpdirectorykit'),
903 'type' => Controls_Manager::HEADING,
904 ]
905 );
906
907 $this->add_responsive_control(
908 'content_thumbnail_section_d_background',
909 [
910 'label' => esc_html__( 'Color', 'wpdirectorykit' ),
911 'description' => esc_html__( 'Set some opacity for color', 'wpdirectorykit' ),
912 'type' => Controls_Manager::COLOR,
913 'selectors' => [
914 '{{WRAPPER}} .wdk-listing-card .wdk-thumbnail::before, {{WRAPPER}} .wdk-listing-card .wdk-thumbnail::after,{{WRAPPER}} .wdk-listing-card .overlay' => 'background-color: {{VALUE}};',
915 ],
916 ]
917 );
918
919 $this->add_control(
920 'content_thumbnail_section_header_f',
921 [
922 'label' => esc_html__('Shadow around Card, for Featured Listings', 'wpdirectorykit'),
923 'type' => Controls_Manager::HEADING,
924 ]
925 );
926
927 $this->add_group_control(
928 Group_Control_Box_Shadow::get_type(),
929 [
930 'name' => 'content_thumbnail_section_d_featured',
931 'exclude' => [
932 'field_shadow_position',
933 ],
934 'selector' => '{{WRAPPER}} .wdk-listing-card.is_featured',
935 ]
936 );
937 $this->end_controls_section();
938
939 $items = [
940 [
941 'key'=>'content_label',
942 'label'=> esc_html__('Over Image Top', 'wpdirectorykit'),
943 'selector'=>'.wdk-element .wdk-listing-card .wdk-thumbnail .wdk-over-image-top span',
944 'options'=>'full',
945 ],
946 [
947 'key'=>'content_type',
948 'label'=> esc_html__('Over Image Bottom', 'wpdirectorykit'),
949 'selector'=>'.wdk-element .wdk-listing-card .wdk-thumbnail .wdk-over-image-bottom',
950 'is_featured'=>'.wdk-element .wdk-listing-card.is_featured .wdk-thumbnail .wdk-over-image-bottom',
951 'options'=>'full',
952 ],
953 [
954 'key'=>'content_title',
955 'label'=> esc_html__('Title Part', 'wpdirectorykit'),
956 'selector'=>'.wdk-element .wdk-listing-card .wdk-title .title',
957 'options'=>'full',
958 ],
959 [
960 'key'=>'content_description',
961 'label'=> esc_html__('Subtitle part', 'wpdirectorykit'),
962 'selector'=>'.wdk-element .wdk-listing-card .wdk-subtitle-part',
963 'options'=>'full',
964 ],
965 [
966 'key'=>'content_items',
967 'label'=> esc_html__('Features part', 'wpdirectorykit'),
968 'selector'=>'.wdk-element .wdk-listing-card .wdk-features-part span',
969 'options'=>'full',
970 ],
971 [
972 'key'=>'wdk-divider',
973 'label'=> esc_html__('Divider', 'wpdirectorykit'),
974 'selector'=>'.wdk-element .wdk-listing-card .wdk-divider',
975 'options'=>'full',
976 ],
977 [
978 'key'=>'content_price',
979 'label'=> esc_html__('Pricing part', 'wpdirectorykit'),
980 'selector'=>'.wdk-element .wdk-listing-card .wdk-footer .wdk-price',
981 'options'=>'full',
982 ],
983 [
984 'key'=>'content_button',
985 'label'=> esc_html__('Button Open', 'wpdirectorykit'),
986 'selector'=>'.wdk-element .wdk-listing-card .wdk-footer .wdk-btn',
987 'options'=>'full',
988 ],
989 [
990 'key'=>'content_card',
991 'label'=> esc_html__('Card', 'wpdirectorykit'),
992 'selector'=>'.wdk-element .wdk-listing-card',
993 'options'=>'full',
994 ],
995 ];
996
997 foreach ($items as $item) {
998
999 $this->start_controls_section(
1000 $item['key'].'_section',
1001 [
1002 'label' => $item['label'],
1003 'tab' => 'tab_layout'
1004 ]
1005 );
1006 if($item['key']!='content_card')
1007 $this->add_responsive_control(
1008 $item['key'].'_hide',
1009 [
1010 'label' => esc_html__( 'Hide Element', 'wpdirectorykit' ),
1011 'type' => Controls_Manager::SWITCHER,
1012 'none' => esc_html__( 'Hide', 'wpdirectorykit' ),
1013 'block' => esc_html__( 'Show', 'wpdirectorykit' ),
1014 'return_value' => 'none',
1015 'default' => '',
1016 'selectors' => [
1017 '{{WRAPPER}} '.$item['selector'] => 'display: {{VALUE}};',
1018 ],
1019 ]
1020 );
1021 $selectors = array(
1022 'normal' => '{{WRAPPER}} '.$item['selector'],
1023 'hover'=>'{{WRAPPER}} '.$item['selector'].'%1$s'
1024 );
1025
1026 if(isset($item['is_featured'])) {
1027 $selectors['featured'] = '{{WRAPPER}} '.$item['is_featured'];
1028 }
1029 $this->generate_renders_tabs($selectors, $item['key'].'_dynamic', $item['options']);
1030
1031
1032
1033 /* special for some elements */
1034
1035 if($item['key'] == 'content_items') {
1036 $this->add_control(
1037 $item['key'].'_parent_head',
1038 [
1039 'label' => esc_html__('Parent Box', 'wpdirectorykit'),
1040 'type' => Controls_Manager::HEADING,
1041 'separator' => 'before',
1042 ]
1043 );
1044
1045 $selectors = array(
1046 'normal' => '{{WRAPPER}} .wdk-element .wdk-listing-card .wdk-features-part',
1047 );
1048 $this->generate_renders_tabs($selectors, $item['key'].'_parent_dynamic', ['margin','align']);
1049 }
1050
1051 if ($item['key'] == 'content_description') {
1052
1053 $this->add_control(
1054 'content_description_limit',
1055 [
1056 'label' => __( 'Limit Line (per field)', 'wpdirectorykit' ),
1057 'type' => \Elementor\Controls_Manager::NUMBER,
1058 'min' => 1,
1059 'max' => 10,
1060 'step' => 1,
1061 'default' => 3,
1062 'selectors' => [
1063 '{{WRAPPER}} .wdk-listing-card .wdk-subtitle-part span' => '-webkit-line-clamp: {{VALUE}};',
1064 ],
1065 ]
1066 );
1067
1068 }
1069
1070 if($item['key'] == 'content_button' && FALSE) {
1071 $this->add_control(
1072 $item['key'].'_icon',
1073 [
1074 'label' => esc_html__('Icon', 'wpdirectorykit'),
1075 'type' => Controls_Manager::ICONS,
1076 'label_block' => true,
1077 'default' => [
1078 'value' => 'fa fa-angle-right',
1079 'library' => 'solid',
1080 ],
1081 ]
1082 );
1083 $this->add_responsive_control(
1084 $item['key'].'_text',
1085 [
1086 'label' => __( 'Text of Link', 'wpdirectorykit' ),
1087 'type' => \Elementor\Controls_Manager::TEXT,
1088 'default' => '',
1089 ]
1090 );
1091
1092 $selectors = array(
1093 'normal' => '{{WRAPPER}} '.$item['selector'].' i',
1094 );
1095 $this->generate_renders_tabs($selectors, $item['key'].'_icon_dynamic', ['margin']);
1096 }
1097
1098 if($item['key'] == 'content_label') {
1099 $this->add_responsive_control(
1100 $item['key'] .'content_label_positions_y',
1101 [
1102 'label' => __( 'Position Y', 'wpdirectorykit' ),
1103 'type' => Controls_Manager::CHOOSE,
1104 'options' => [
1105 'top' => [
1106 'title' => esc_html__( 'Top', 'wpdirectorykit' ),
1107 'icon' => 'eicon-text-align-top',
1108 ],
1109 'center' => [
1110 'title' => esc_html__( 'Center', 'wpdirectorykit' ),
1111 'icon' => 'eicon-text-align-center',
1112 ],
1113 'bottom' => [
1114 'title' => esc_html__( 'Bottom', 'wpdirectorykit' ),
1115 'icon' => 'eicon-text-align-bottom',
1116 ],
1117 ],
1118 'default' => 'left',
1119 'render_type' => 'ui',
1120 'selectors_dictionary' => [
1121 'top' => 'top:0;bottom:initial',
1122 'center' => 'top:50%;transform: translateY(-50%)',
1123 'bottom' => 'top:initial;bottom:0',
1124 ],
1125 'selectors' => [
1126 '{{WRAPPER}} .wdk-listing-card .wdk-thumbnail .wdk-over-image-top' => '{{VALUE}};',
1127 ],
1128 ]
1129 );
1130
1131 $this->add_responsive_control(
1132 $item['key'] .'content_label_positions_x',
1133 [
1134 'label' => __( 'Position X', 'wpdirectorykit' ),
1135 'type' => Controls_Manager::CHOOSE,
1136 'options' => [
1137 'left' => [
1138 'title' => esc_html__( 'Left', 'wpdirectorykit' ),
1139 'icon' => 'eicon-text-align-left',
1140 ],
1141 'center' => [
1142 'title' => esc_html__( 'Center', 'wpdirectorykit' ),
1143 'icon' => 'eicon-text-align-center',
1144 ],
1145 'right' => [
1146 'title' => esc_html__( 'Right', 'wpdirectorykit' ),
1147 'icon' => 'eicon-text-align-right',
1148 ],
1149 ],
1150 'default' => 'left',
1151 'render_type' => 'ui',
1152 'selectors_dictionary' => [
1153 'left' => 'left:0',
1154 'center' => 'left:50%;transform: translateX(-50%)',
1155 'right' => 'left:initial; right:0',
1156 ],
1157 'selectors' => [
1158 '{{WRAPPER}} .wdk-listing-card .wdk-thumbnail .wdk-over-image-top' => '{{VALUE}};',
1159 ],
1160 ]
1161 );
1162 }
1163
1164 if($item['key'] == 'content_type') {
1165 $this->add_responsive_control(
1166 $item['key'] .'content_label_positions_y',
1167 [
1168 'label' => __( 'Position Y', 'wpdirectorykit' ),
1169 'type' => Controls_Manager::CHOOSE,
1170 'options' => [
1171 'top' => [
1172 'title' => esc_html__( 'Top', 'wpdirectorykit' ),
1173 'icon' => 'eicon-text-align-top',
1174 ],
1175 'center' => [
1176 'title' => esc_html__( 'Center', 'wpdirectorykit' ),
1177 'icon' => 'eicon-text-align-center',
1178 ],
1179 'bottom' => [
1180 'title' => esc_html__( 'Bottom', 'wpdirectorykit' ),
1181 'icon' => 'eicon-text-align-bottom',
1182 ],
1183 ],
1184 'default' => 'left',
1185 'render_type' => 'ui',
1186 'selectors_dictionary' => [
1187 'top' => 'top:0;bottom:initial',
1188 'center' => 'top:50%;transform: translateY(-50%)',
1189 'bottom' => 'top:initial;bottom:0',
1190 ],
1191 'selectors' => [
1192 '{{WRAPPER}} '.$item['selector'] => '{{VALUE}};',
1193 ],
1194 ]
1195 );
1196
1197 $this->add_responsive_control(
1198 $item['key'] .'content_label_positions_x',
1199 [
1200 'label' => __( 'Position X', 'wpdirectorykit' ),
1201 'type' => Controls_Manager::CHOOSE,
1202 'options' => [
1203 'left' => [
1204 'title' => esc_html__( 'Left', 'wpdirectorykit' ),
1205 'icon' => 'eicon-text-align-left',
1206 ],
1207 'center' => [
1208 'title' => esc_html__( 'Center', 'wpdirectorykit' ),
1209 'icon' => 'eicon-text-align-center',
1210 ],
1211 'right' => [
1212 'title' => esc_html__( 'Right', 'wpdirectorykit' ),
1213 'icon' => 'eicon-text-align-right',
1214 ],
1215 'justify' => [
1216 'title' => esc_html__( 'Justified', 'wpdirectorykit' ),
1217 'icon' => 'eicon-text-align-justify',
1218 ],
1219 ],
1220 'default' => 'left',
1221 'render_type' => 'ui',
1222 'selectors_dictionary' => [
1223 'top' => 'justify-content: flex-start;',
1224 'center' => 'justify-content: center;',
1225 'bottom' => 'justify-content: flex-end;',
1226 'justify' => 'justify-content: stretch;',
1227 ],
1228 'selectors' => [
1229 '{{WRAPPER}} '.$item['selector'] => '{{VALUE}};',
1230 ],
1231 ]
1232 );
1233 }
1234 $this->end_controls_section();
1235 /* END special for some elements */
1236 }
1237 }
1238
1239
1240 public function enqueue_styles_scripts() {
1241 wp_enqueue_style('leaflet');
1242 wp_enqueue_style('leaflet-cluster-def');
1243 wp_enqueue_style('leaflet-cluster');
1244 wp_enqueue_script('leaflet');
1245 wp_enqueue_script('leaflet-cluster');
1246 wp_enqueue_script('leaflet-fullscreen');
1247 wp_enqueue_style('leaflet-fullscreen');
1248
1249 wp_enqueue_style('wdk-notify');
1250 wp_enqueue_script('wdk-notify');
1251 wp_enqueue_style( 'wdk-listings-map' );
1252
1253 wp_enqueue_style('slick');
1254 wp_enqueue_style('slick-theme');
1255 wp_enqueue_style('wdk-hover');
1256 wp_enqueue_script('slick');
1257 wp_enqueue_script('leaflet-googlemutant');
1258 }
1259
1260 }
1261