PluginProbe
WP Directory Kit / 1.1.6
WP Directory Kit v1.1.6
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-map.php

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

1,111 lines 44.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(!isset($_GET['order_by'])) {
142 $custom_parameters['order_by'] = $this->data['settings']['conf_order_by'].' '.$this->data['settings']['conf_order'];
143 }
144
145 if(!isset($_GET['conf_order_by_custom'])) {
146 $custom_parameters['order_by'] = $this->data['settings']['conf_order_by_custom'].' '.$this->data['settings']['conf_order'];
147 }
148
149 if(!empty($this->data['settings']['conf_query'])) {
150 $qr_string = trim($this->data['settings']['conf_query'],'?');
151 $string_par = array();
152 parse_str($qr_string, $string_par);
153 $custom_parameters += array_map('trim', $string_par);
154 }
155
156 $external_columns = array('location_id', 'category_id', 'post_title');
157 wdk_prepare_search_query_GET($columns, $controller.'_m', $external_columns, $custom_parameters);
158 $this->data['results'] = $this->WMVC->listing_m->get_pagination($this->data['settings']['conf_limit'], NULL, array('is_activated' => 1,'is_approved'=>1));
159
160 $this->data['settings']['content_button_icon'] = '';
161
162 $this->data['is_edit_mode']= false;
163 if(Plugin::$instance->editor->is_edit_mode())
164 $this->data['is_edit_mode']= true;
165
166 echo $this->view('wdk-map', $this->data);
167
168 }
169
170 private function generate_controls_conf() {
171 $this->start_controls_section(
172 'tab_conf_main_section',
173 [
174 'label' => esc_html__('Main', 'wpdirectorykit'),
175 'tab' => '1',
176 ]
177 );
178
179 /* conf_results_type :: results_listings */
180 if(true){
181 $this->add_control(
182 'conf_results_type_results_listings_header',
183 [
184 'label' => esc_html__('Results listings', 'wpdirectorykit'),
185 'type' => Controls_Manager::HEADING,
186 'separator' => 'before',
187 ]
188 );
189
190 $this->add_control(
191 'conf_limit',
192 [
193 'label' => __( 'Limit Results', 'wpdirectorykit' ),
194 'type' => \Elementor\Controls_Manager::NUMBER,
195 'min' => 1,
196 'max' => 10000,
197 'step' => 1,
198 'default' => 350,
199 ]
200 );
201
202 $this->add_control(
203 'conf_query',
204 [
205 'label' => __( 'Query', 'wpdirectorykit' ),
206 'type' => \Elementor\Controls_Manager::TEXTAREA,
207 'rows' => 5,
208 'default' => '',
209 'placeholder' => __( 'Type your query here, example xxx', 'wpdirectorykit' ),
210 'description' => '<span style="word-break: break-all;">'.__( 'Example (same like on url): ', 'wpdirectorykit' ).
211 'field_6_min=100&field_6_max=200&field_5=rent&is_featured=on&search_category=3&search_location=4&search_agents_ids=3'.
212 '</span>',
213 ]
214 );
215
216 $this->add_control(
217 'conf_order_by',
218 [
219 'label' => __('Default Order By Column', 'wpdirectorykit'),
220 'type' => Controls_Manager::SELECT,
221 'label_block' => true,
222 'options' => [
223 'none' => __('None', 'wpdirectorykit'),
224 'post_id' => __('ID', 'wpdirectorykit'),
225 'category_id' => __('Category', 'wpdirectorykit'),
226 ],
227 'default' => 'post_id',
228 ]
229 );
230
231 $this->add_control(
232 'conf_order_by_custom',
233 [
234 'label' => __('Default Custom Order By (Column)', 'wpdirectorykit'),
235 'description' => '<span style="word-break: break-all;">'.__( 'Example: ', 'wpdirectorykit' ).
236 '<br> field_13_NUMBER - where 13 is field id, NUMBER - field type'.
237 '<br> field_4_NUMBER - where 4 is field id, NUMBER - field type'.
238 '<br> field_6_DROPDOWN - where 6 is field id, DROPDOWN - field type'.
239 '</span>',
240 'type' => Controls_Manager::TEXT,
241 'label_block' => true,
242 'default' => 'post_id',
243 ]
244 );
245
246 $this->add_control(
247 'conf_order',
248 [
249 'label' => __('Default Listing Order', 'wpdirectorykit'),
250 'type' => Controls_Manager::SELECT,
251 'label_block' => true,
252 'options' => [
253 'asc' => __('Ascending', 'wpdirectorykit'),
254 'desc' => __('Descending', 'wpdirectorykit')
255 ],
256 'default' => 'desc',
257 ]
258 );
259
260
261 $WMVC = &wdk_get_instance();
262 $WMVC->model('field_m');
263 $fields_data = $WMVC->field_m->get();
264 $fields_list = array('' => esc_html__('Not Selected', 'wpdirectorykit'));
265 $order_i = 0;
266
267 $fields_list [(++$order_i).'__section'] = esc_html__('-- Section Custom fields --', 'wpdirectorykit');
268 $fields_list [(++$order_i).'__first_image'] = esc_html__('First Image', 'wpdirectorykit');
269 $fields_list [(++$order_i).'__counter_views'] = esc_html__('Views counter', 'wpdirectorykit');
270 $fields_list [(++$order_i).'__post_title'] = esc_html__('WP Title', 'wpdirectorykit');
271
272 foreach($fields_data as $field)
273 {
274 if(wmvc_show_data('field_type', $field) == 'SECTION') {
275 $fields_list [(++$order_i).'section__'.wmvc_show_data('idfield', $field)] = '-- '.esc_html__('Section', 'wpdirectorykit').' '.wmvc_show_data('field_label', $field).' --';
276 } else {
277 $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).']';
278 }
279 }
280
281 $this->add_control(
282 'custom_marker_fields',
283 [
284 'label' => __('Show field value instead of marker on map', 'wpdirectorykit'),
285 'type' => \Elementor\Controls_Manager::SELECT,
286 'default' => '',
287 'label_block' => true,
288 'options' => $fields_list,
289 'separator' => 'after',
290 ]
291 );
292
293 }
294
295 $this->end_controls_section();
296
297 if(true){
298 $this->start_controls_section(
299 'conf_custom_map',
300 [
301 'label' => esc_html__('Map', 'wpdirectorykit'),
302 'tab' => '1',
303 ]
304 );
305
306 $this->add_responsive_control(
307 'conf_custom_map_height',
308 [
309 'label' => esc_html__('Height', 'wpdirectorykit'),
310 'type' => Controls_Manager::SLIDER,
311 'range' => [
312 'px' => [
313 'min' => 100,
314 'max' => 1500,
315 ],
316 ],
317 'render_type' => 'template',
318 'default' => [
319 'size' => 350,
320 ],
321 'selectors' => [
322 '{{WRAPPER}} .wdk-element .wdk_map_results' => 'height: {{SIZE}}px !important',
323 ],
324 'separator' => 'after',
325 ]
326 );
327
328 $this->add_control(
329 'conf_custom_map_zoom_index',
330 [
331 'label' => esc_html__('Zoom Index', 'wpdirectorykit'),
332 'description' => esc_html__( 'Only active if auto centering is disabled', 'wpdirectorykit' ),
333 'type' => Controls_Manager::SLIDER,
334 'range' => [
335 'px' => [
336 'min' => 1,
337 'max' => 18,
338 ],
339 ],
340 'render_type' => 'template',
341 'default' => [
342 'size' => 7,
343 ]
344 ]
345 );
346
347 $this->add_responsive_control(
348 'conf_custom_dragging',
349 [
350 'label' => esc_html__( 'Dragging', 'wpdirectorykit' ),
351 'type' => Controls_Manager::SWITCHER,
352 'none' => esc_html__( 'True', 'wpdirectorykit' ),
353 'block' => esc_html__( 'False', 'wpdirectorykit' ),
354 'render_type' => 'template',
355 'return_value' => 'yes',
356 'default' => 'yes',
357 'separator' => 'before',
358 ]
359 );
360
361
362 $this->add_control(
363 'conf_custom_map_styles_h',
364 [
365 'label' => __( 'Map Styles', 'wpdirectorykit' ),
366 'type' => \Elementor\Controls_Manager::HEADING,
367 'separator' => 'before',
368 ]
369 );
370
371 $this->add_control(
372 'conf_custom_map_style',
373 [
374 'label' => esc_html__('Styles List', 'wpdirectorykit'),
375 'type' => Controls_Manager::SELECT,
376 'options' => [
377 '' => esc_html__('Default', 'wpdirectorykit'),
378 'custom' => esc_html__('Custom', 'wpdirectorykit'),
379 'https://cartodb-basemaps-{s}.global.ssl.fastly.net/light_all/{z}/{x}/{y}{r}.png' => esc_html__('Light', 'wpdirectorykit'),
380 'https://{s}.tile.openstreetmap.fr/hot/{z}/{x}/{y}.png' => esc_html__('Osmde', 'wpdirectorykit'),
381 'https://{s}.tile.opentopomap.org/{z}/{x}/{y}.png' => esc_html__('OpenTopoMap', 'wpdirectorykit'),
382 'https://{s}.tile.thunderforest.com/cycle/{z}/{x}/{y}.png' => esc_html__('OpenCycleMap', 'wpdirectorykit'),
383 'https://server.arcgisonline.com/ArcGIS/rest/services/World_Imagery/MapServer/tile/{z}/{y}/{x}' => esc_html__('WorldImagery', 'wpdirectorykit'),
384 'https://{s}.basemaps.cartocdn.com/light_all/{z}/{x}/{y}{r}.png' => esc_html__('Carto DarkMatter', 'wpdirectorykit'),
385 'https://{s}.basemaps.cartocdn.com/rastertiles/voyager/{z}/{x}/{y}{r}.png' => esc_html__('Carto Voyager', 'wpdirectorykit'),
386 'https://cartodb-basemaps-{s}.global.ssl.fastly.net/dark_all/{z}/{x}/{y}{r}.png' => esc_html__('Maptiler dark (demo)', 'wpdirectorykit'),
387 ],
388 'default' => '',
389 ]
390 );
391
392 $this->add_control(
393 'conf_custom_map_style_self',
394 [
395 'label' => esc_html__('Link to custom Map Style', 'wpdirectorykit'),
396 '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' ),
397 'type' => Controls_Manager::TEXTAREA,
398 'render_type' => 'template',
399 'conditions' => [
400 'terms' => [
401 [
402 'name' => 'conf_custom_map_style',
403 'operator' => '==',
404 'value' => 'custom',
405 ]
406 ],
407 ]
408 ]
409 );
410
411 $this->end_controls_section();
412 }
413
414 $this->start_controls_section(
415 'conf_map_position',
416 [
417 'label' => esc_html__('Map Positioning', 'wpdirectorykit'),
418 'tab' => '1',
419 ]
420 );
421
422 $this->add_control(
423 'conf_custom_map_center_gps_lat',
424 [
425 'label' => esc_html__('GPS lat Center', 'wpdirectorykit'),
426 'type' => Controls_Manager::TEXT,
427 'default' => '45.675243',
428 ]
429 );
430
431 $this->add_control(
432 'conf_custom_map_center_gps_lng',
433 [
434 'label' => esc_html__('GPS lng Center', 'wpdirectorykit'),
435 'type' => Controls_Manager::TEXT,
436 'default' => '5.907848',
437 ]
438 );
439
440
441 $this->add_responsive_control(
442 'enable_custom_gps_center',
443 [
444 'label' => esc_html__( 'Enable custom GPS', 'wpdirectorykit' ),
445 'type' => Controls_Manager::SWITCHER,
446 'none' => esc_html__( 'True', 'wpdirectorykit' ),
447 'block' => esc_html__( 'False', 'wpdirectorykit' ),
448 'render_type' => 'template',
449 'return_value' => 'yes',
450 'default' => '',
451 ]
452 );
453
454 $this->end_controls_section();
455
456 }
457
458 private function generate_controls_layout() {
459
460 /* default marker layout */
461 $this->generate_controls_layout_default();
462 }
463
464 private function generate_controls_styles() {
465 /* default marker layout */
466 $this->generate_controls_styles_default();
467
468 /* marker */
469 $this->start_controls_section(
470 'styles_cluster',
471 [
472 'label' => esc_html__('Cluster', 'wpdirectorykit'),
473 'tab' => Controls_Manager::TAB_STYLE,
474 ]
475 );
476
477 $this->add_control(
478 'styles_cluster_color',
479 [
480 'label' => esc_html__('Cluster Color', 'wpdirectorykit'),
481 'type' => Controls_Manager::COLOR,
482 'selectors' => [
483 '{{WRAPPER}} .marker-cluster div' => 'background-color: {{VALUE}};',
484 ],
485 ]
486 );
487
488 $this->add_control(
489 'styles_cluster_color_border',
490 [
491 'label' => esc_html__('Cluster Color Border', 'wpdirectorykit'),
492 'type' => Controls_Manager::COLOR,
493 'selectors' => [
494 '{{WRAPPER}} .marker-cluster div::before' => 'border: 6px solid {{VALUE}}; box-shadow: inset 0 0 0 4px {{VALUE}};',
495 ],
496 ]
497 );
498
499 $this->add_control(
500 'styles_cluster_color_text',
501 [
502 'label' => esc_html__('Cluster Color Text', 'wpdirectorykit'),
503 'type' => Controls_Manager::COLOR,
504 'selectors' => [
505 '{{WRAPPER}} .marker-cluster div' => 'color: {{VALUE}};',
506 ],
507 ]
508 );
509
510 $this->add_group_control(
511 Group_Control_Typography::get_type(),
512 [
513 'name' => 'styles_cluster_color_font',
514 'selector' => '{{WRAPPER}} .marker-cluster div',
515 ]
516 );
517
518 $this->end_controls_section();
519
520 /* marker */
521 $this->start_controls_section(
522 'styles_marker_sec',
523 [
524 'label' => esc_html__('Marker', 'wpdirectorykit'),
525 'tab' => Controls_Manager::TAB_STYLE,
526 ]
527 );
528
529
530 $this->add_control(
531 'styles_marker_h',
532 [
533 'label' => esc_html__('Marker', 'wpdirectorykit'),
534 'type' => Controls_Manager::HEADING,
535 'separator' => 'before',
536 ]
537 );
538
539 $this->start_controls_tabs('marker_button_style');
540
541 $this->start_controls_tab(
542 'marker',
543 [
544 'label' => esc_html__('Normal', 'wpdirectorykit'),
545 ]
546 );
547
548 $this->add_control(
549 'styles_marker_color',
550 [
551 'label' => esc_html__('Marker Border Color', 'wpdirectorykit'),
552 'type' => Controls_Manager::COLOR,
553 'selectors' => [
554 '{{WRAPPER}} .wdk-element .wdk-map .wdk_marker-card::before' => 'background-color: {{VALUE}};',
555 '{{WRAPPER}} .wdk-element .wdk_marker-container.wdk_marker_label' => 'border-color: {{VALUE}};',
556 ],
557 ]
558 );
559
560 $this->add_control(
561 'styles_marker_color_bckg',
562 [
563 'label' => esc_html__('Marker Color', 'wpdirectorykit'),
564 'type' => Controls_Manager::COLOR,
565 'selectors' => [
566 '{{WRAPPER}} .wdk-element .wdk_marker-card:after' => 'background-color: {{VALUE}};',
567 '{{WRAPPER}} .wdk-element .wdk_marker-container.wdk_marker_label' => 'background-color: {{VALUE}};',
568 ],
569 ]
570 );
571
572 $this->add_control(
573 'styles_marker_color_text',
574 [
575 'label' => esc_html__('Marker Text Color', 'wpdirectorykit'),
576 'type' => Controls_Manager::COLOR,
577 'selectors' => [
578 '{{WRAPPER}} .wdk_face i' => 'color: {{VALUE}};',
579 '{{WRAPPER}} .wdk_marker-container.wdk_marker_label' => 'color: {{VALUE}};',
580 ],
581 ]
582 );
583
584 $this->add_control(
585 'conf_custom_map_pin_icon',
586 [
587 'label' => esc_html__('Icon', 'wpdirectorykit'),
588 'type' => Controls_Manager::ICONS,
589 'label_block' => true,
590 'default' => [
591 'value' => 'fa fa-home',
592 'library' => 'solid',
593 ],
594 'exclude_inline_options' => array('svg'),
595 ]
596 );
597
598 $this->add_control(
599 'conf_custom_map_pin',
600 [
601 'label' => esc_html__('Custom Marker Pin Image', 'wpdirectorykit'),
602 'type' => Controls_Manager::MEDIA,
603 ]
604 );
605
606 $this->end_controls_tab();
607
608 $this->start_controls_tab(
609 'marker_hover',
610 [
611 'label' => esc_html__('Hover', 'wpdirectorykit'),
612 ]
613 );
614
615 $this->add_control(
616 'styles_marker_color_hover',
617 [
618 'label' => esc_html__('Marker Border Color', 'wpdirectorykit'),
619 'type' => Controls_Manager::COLOR,
620 'selectors' => [
621 '{{WRAPPER}} .wdk-element .wdk_marker-container:hover .wdk_marker-card:before' => 'background-color: {{VALUE}};',
622 '{{WRAPPER}} .wdk-element .wdk_marker-container.wdk_marker_label:hover' => 'border-color: {{VALUE}};',
623 ],
624 ]
625 );
626
627 $this->add_control(
628 'styles_marker_color_hover_bckg',
629 [
630 'label' => esc_html__('Marker Color', 'wpdirectorykit'),
631 'type' => Controls_Manager::COLOR,
632 'selectors' => [
633 '{{WRAPPER}} .wdk-element .wdk_marker-container:hover .wdk_marker-card:after' => 'background-color: {{VALUE}};',
634 '{{WRAPPER}} .wdk-element .wdk_marker-container.wdk_marker_label:hover' => 'background-color: {{VALUE}};',
635 ],
636 ]
637 );
638
639 $this->add_control(
640 'styles_marker_color_text_hover',
641 [
642 'label' => esc_html__('Marker Text Color', 'wpdirectorykit'),
643 'type' => Controls_Manager::COLOR,
644 'selectors' => [
645 '{{WRAPPER}} .wdk_marker-container:hover .wdk_face.back i, .wdk_marker-container:hover .wdk_face i' => 'color: {{VALUE}};',
646 '{{WRAPPER}} .wdk_marker-container.wdk_marker_label:hover' => 'color: {{VALUE}};',
647 ],
648 ]
649 );
650
651 $this->add_control(
652 'styles_marker_effect_duration',
653 [
654 'label' => esc_html__('Transition Duration', 'wpdirectorykit'),
655 'type' => Controls_Manager::SLIDER,
656 'render_type' => 'template',
657 'range' => [
658 'px' => [
659 'min' => 0,
660 'max' => 3000,
661 ],
662 ],
663 'selectors' => [
664 '{{WRAPPER}} .wdk_map-marker-container.clicked .wdk_face.front, .wdk_marker-container:hover .wdk_face.front' => 'transition-duration: {{SIZE}}ms',
665 '{{WRAPPER}} .wdk_marker-container.wdk_marker_label' => 'transition-duration: {{SIZE}}ms',
666 ],
667 ]
668 );
669
670 $this->end_controls_tab();
671
672 $this->end_controls_tabs();
673 $this->end_controls_section();
674 }
675
676 private function generate_controls_content() {
677 /* default marker layout */
678 $this->generate_controls_content_default();
679 }
680
681 private function generate_controls_layout_default() {
682
683 }
684
685 private function generate_controls_styles_default() {
686 $this->start_controls_section(
687 'styles_thmbn_section',
688 [
689 'label' => esc_html__('Section Image', 'wpdirectorykit'),
690 'tab' => Controls_Manager::TAB_STYLE,
691 ]
692 );
693
694 $this->add_responsive_control(
695 'styles_thmbn_des_type',
696 [
697 'label' => __( 'Design type ', 'wpdirectorykit' ),
698 'type' => \Elementor\Controls_Manager::SELECT,
699 'default' => 'wdk_size_image_cover',
700 'options' => [
701 '' => __( 'Default Sizes', 'wpdirectorykit' ),
702 'wdk_size_image_cover' => __( 'Image auto crop/resize', 'wpdirectorykit' ),
703 ],
704 ]
705 );
706
707 $this->add_responsive_control(
708 'styles_thmbn_des_height',
709 [
710 'label' => esc_html__('Height', 'wpdirectorykit'),
711 'type' => Controls_Manager::SLIDER,
712 'range' => [
713 'px' => [
714 'min' => 50,
715 'max' => 1500,
716 ],
717 ],
718 'render_type' => 'ui',
719 'default' => [
720 'size' => 350,
721 ],
722 'selectors' => [
723 '{{WRAPPER}} .wdk_size_image_cover .wdk-listing-card .wdk-thumbnail .wdk-image' => 'height: {{SIZE}}px',
724 ],
725 'separator' => 'after',
726 'conditions' => [
727 'relation' => 'or',
728 'terms' => [
729 [
730 'name' => 'styles_thmbn_des_type',
731 'operator' => '==',
732 'value' => 'wdk_size_image_cover',
733 ],
734 [
735 'name' => 'styles_thmbn_des_type',
736 'operator' => '==',
737 'value' => 'wdk_image_cover',
738 ]
739 ],
740 ]
741 ]
742 );
743 $this->end_controls_section();
744 }
745
746 private function generate_controls_content_default() {
747 $this->start_controls_section(
748 'content_thumbnail_section',
749 [
750 'label' => esc_html__('Colors', 'wpdirectorykit'),
751 'tab' => 'tab_layout',
752 ]
753 );
754
755 $this->add_control(
756 'content_thumbnail_section_header',
757 [
758 'label' => esc_html__('Color Hover Thumbnail', 'wpdirectorykit'),
759 'type' => Controls_Manager::HEADING,
760 ]
761 );
762
763 $this->add_responsive_control(
764 'content_thumbnail_section_d_background',
765 [
766 'label' => esc_html__( 'Color', 'wpdirectorykit' ),
767 'description' => esc_html__( 'Set some opacity for color', 'wpdirectorykit' ),
768 'type' => Controls_Manager::COLOR,
769 'selectors' => [
770 '{{WRAPPER}} .wdk-listing-card .wdk-thumbnail::before, {{WRAPPER}} .wdk-listing-card .wdk-thumbnail::after,{{WRAPPER}} .wdk-listing-card .overlay' => 'background-color: {{VALUE}};',
771 ],
772 ]
773 );
774
775 $this->add_control(
776 'content_thumbnail_section_header_f',
777 [
778 'label' => esc_html__('Shadow around Card, for Featured Listings', 'wpdirectorykit'),
779 'type' => Controls_Manager::HEADING,
780 ]
781 );
782
783 $this->add_group_control(
784 Group_Control_Box_Shadow::get_type(),
785 [
786 'name' => 'content_thumbnail_section_d_featured',
787 'exclude' => [
788 'field_shadow_position',
789 ],
790 'selector' => '{{WRAPPER}} .wdk-listing-card.is_featured',
791 ]
792 );
793 $this->end_controls_section();
794
795 $items = [
796 [
797 'key'=>'content_label',
798 'label'=> esc_html__('Over Image Top', 'wpdirectorykit'),
799 'selector'=>'.wdk-element .wdk-listing-card .wdk-thumbnail .wdk-over-image-top span',
800 'options'=>'full',
801 ],
802 [
803 'key'=>'content_type',
804 'label'=> esc_html__('Over Image Bottom', 'wpdirectorykit'),
805 'selector'=>'.wdk-element .wdk-listing-card .wdk-thumbnail .wdk-over-image-bottom',
806 'is_featured'=>'.wdk-element .wdk-listing-card.is_featured .wdk-thumbnail .wdk-over-image-bottom',
807 'options'=>'full',
808 ],
809 [
810 'key'=>'content_title',
811 'label'=> esc_html__('Title Part', 'wpdirectorykit'),
812 'selector'=>'.wdk-element .wdk-listing-card .wdk-title .title',
813 'options'=>'full',
814 ],
815 [
816 'key'=>'content_description',
817 'label'=> esc_html__('Subtitle part', 'wpdirectorykit'),
818 'selector'=>'.wdk-element .wdk-listing-card .wdk-subtitle-part',
819 'options'=>'full',
820 ],
821 [
822 'key'=>'content_items',
823 'label'=> esc_html__('Features part', 'wpdirectorykit'),
824 'selector'=>'.wdk-element .wdk-listing-card .wdk-features-part span',
825 'options'=>'full',
826 ],
827 [
828 'key'=>'wdk-divider',
829 'label'=> esc_html__('Divider', 'wpdirectorykit'),
830 'selector'=>'.wdk-element .wdk-listing-card .wdk-divider',
831 'options'=>'full',
832 ],
833 [
834 'key'=>'content_price',
835 'label'=> esc_html__('Pricing part', 'wpdirectorykit'),
836 'selector'=>'.wdk-element .wdk-listing-card .wdk-footer .wdk-price',
837 'options'=>'full',
838 ],
839 [
840 'key'=>'content_button',
841 'label'=> esc_html__('Button Open', 'wpdirectorykit'),
842 'selector'=>'.wdk-element .wdk-listing-card .wdk-footer .wdk-btn',
843 'options'=>'full',
844 ],
845 [
846 'key'=>'content_card',
847 'label'=> esc_html__('Card', 'wpdirectorykit'),
848 'selector'=>'.wdk-element .wdk-listing-card',
849 'options'=>'full',
850 ],
851 ];
852
853 foreach ($items as $item) {
854
855 $this->start_controls_section(
856 $item['key'].'_section',
857 [
858 'label' => $item['label'],
859 'tab' => 'tab_layout'
860 ]
861 );
862 if($item['key']!='content_card')
863 $this->add_responsive_control(
864 $item['key'].'_hide',
865 [
866 'label' => esc_html__( 'Hide Element', 'wpdirectorykit' ),
867 'type' => Controls_Manager::SWITCHER,
868 'none' => esc_html__( 'Hide', 'wpdirectorykit' ),
869 'block' => esc_html__( 'Show', 'wpdirectorykit' ),
870 'return_value' => 'none',
871 'default' => '',
872 'selectors' => [
873 '{{WRAPPER}} '.$item['selector'] => 'display: {{VALUE}};',
874 ],
875 ]
876 );
877 $selectors = array(
878 'normal' => '{{WRAPPER}} '.$item['selector'],
879 'hover'=>'{{WRAPPER}} '.$item['selector'].'%1$s'
880 );
881
882 if(isset($item['is_featured'])) {
883 $selectors['featured'] = '{{WRAPPER}} '.$item['is_featured'];
884 }
885 $this->generate_renders_tabs($selectors, $item['key'].'_dynamic', $item['options']);
886
887
888
889 /* special for some elements */
890
891 if($item['key'] == 'content_items') {
892 $this->add_control(
893 $item['key'].'_parent_head',
894 [
895 'label' => esc_html__('Parent Box', 'wpdirectorykit'),
896 'type' => Controls_Manager::HEADING,
897 'separator' => 'before',
898 ]
899 );
900
901 $selectors = array(
902 'normal' => '{{WRAPPER}} .wdk-element .wdk-listing-card .wdk-features-part',
903 );
904 $this->generate_renders_tabs($selectors, $item['key'].'_parent_dynamic', ['margin','align']);
905 }
906
907 if ($item['key'] == 'content_description') {
908
909 $this->add_control(
910 'content_description_limit',
911 [
912 'label' => __( 'Limit Line (per field)', 'wpdirectorykit' ),
913 'type' => \Elementor\Controls_Manager::NUMBER,
914 'min' => 1,
915 'max' => 10,
916 'step' => 1,
917 'default' => 3,
918 'selectors' => [
919 '{{WRAPPER}} .wdk-listing-card .wdk-subtitle-part span' => '-webkit-line-clamp: {{VALUE}};',
920 ],
921 ]
922 );
923
924 }
925
926 if($item['key'] == 'content_button' && FALSE) {
927 $this->add_control(
928 $item['key'].'_icon',
929 [
930 'label' => esc_html__('Icon', 'wpdirectorykit'),
931 'type' => Controls_Manager::ICONS,
932 'label_block' => true,
933 'default' => [
934 'value' => 'fa fa-angle-right',
935 'library' => 'solid',
936 ],
937 ]
938 );
939 $this->add_responsive_control(
940 $item['key'].'_text',
941 [
942 'label' => __( 'Text of Link', 'wpdirectorykit' ),
943 'type' => \Elementor\Controls_Manager::TEXT,
944 'default' => '',
945 ]
946 );
947
948 $selectors = array(
949 'normal' => '{{WRAPPER}} '.$item['selector'].' i',
950 );
951 $this->generate_renders_tabs($selectors, $item['key'].'_icon_dynamic', ['margin']);
952 }
953
954 if($item['key'] == 'content_label') {
955 $this->add_responsive_control(
956 $item['key'] .'content_label_positions_y',
957 [
958 'label' => __( 'Position Y', 'wpdirectorykit' ),
959 'type' => Controls_Manager::CHOOSE,
960 'options' => [
961 'top' => [
962 'title' => esc_html__( 'Top', 'wpdirectorykit' ),
963 'icon' => 'eicon-text-align-top',
964 ],
965 'center' => [
966 'title' => esc_html__( 'Center', 'wpdirectorykit' ),
967 'icon' => 'eicon-text-align-center',
968 ],
969 'bottom' => [
970 'title' => esc_html__( 'Bottom', 'wpdirectorykit' ),
971 'icon' => 'eicon-text-align-bottom',
972 ],
973 ],
974 'default' => 'left',
975 'render_type' => 'ui',
976 'selectors_dictionary' => [
977 'top' => 'top:0;bottom:initial',
978 'center' => 'top:50%;transform: translateY(-50%)',
979 'bottom' => 'top:initial;bottom:0',
980 ],
981 'selectors' => [
982 '{{WRAPPER}} .wdk-listing-card .wdk-thumbnail .wdk-over-image-top' => '{{VALUE}};',
983 ],
984 ]
985 );
986
987 $this->add_responsive_control(
988 $item['key'] .'content_label_positions_x',
989 [
990 'label' => __( 'Position X', 'wpdirectorykit' ),
991 'type' => Controls_Manager::CHOOSE,
992 'options' => [
993 'left' => [
994 'title' => esc_html__( 'Left', 'wpdirectorykit' ),
995 'icon' => 'eicon-text-align-left',
996 ],
997 'center' => [
998 'title' => esc_html__( 'Center', 'wpdirectorykit' ),
999 'icon' => 'eicon-text-align-center',
1000 ],
1001 'right' => [
1002 'title' => esc_html__( 'Right', 'wpdirectorykit' ),
1003 'icon' => 'eicon-text-align-right',
1004 ],
1005 ],
1006 'default' => 'left',
1007 'render_type' => 'ui',
1008 'selectors_dictionary' => [
1009 'left' => 'left:0',
1010 'center' => 'left:50%;transform: translateX(-50%)',
1011 'right' => 'left:initial; right:0',
1012 ],
1013 'selectors' => [
1014 '{{WRAPPER}} .wdk-listing-card .wdk-thumbnail .wdk-over-image-top' => '{{VALUE}};',
1015 ],
1016 ]
1017 );
1018 }
1019
1020 if($item['key'] == 'content_type') {
1021 $this->add_responsive_control(
1022 $item['key'] .'content_label_positions_y',
1023 [
1024 'label' => __( 'Position Y', 'wpdirectorykit' ),
1025 'type' => Controls_Manager::CHOOSE,
1026 'options' => [
1027 'top' => [
1028 'title' => esc_html__( 'Top', 'wpdirectorykit' ),
1029 'icon' => 'eicon-text-align-top',
1030 ],
1031 'center' => [
1032 'title' => esc_html__( 'Center', 'wpdirectorykit' ),
1033 'icon' => 'eicon-text-align-center',
1034 ],
1035 'bottom' => [
1036 'title' => esc_html__( 'Bottom', 'wpdirectorykit' ),
1037 'icon' => 'eicon-text-align-bottom',
1038 ],
1039 ],
1040 'default' => 'left',
1041 'render_type' => 'ui',
1042 'selectors_dictionary' => [
1043 'top' => 'top:0;bottom:initial',
1044 'center' => 'top:50%;transform: translateY(-50%)',
1045 'bottom' => 'top:initial;bottom:0',
1046 ],
1047 'selectors' => [
1048 '{{WRAPPER}} '.$item['selector'] => '{{VALUE}};',
1049 ],
1050 ]
1051 );
1052
1053 $this->add_responsive_control(
1054 $item['key'] .'content_label_positions_x',
1055 [
1056 'label' => __( 'Position X', 'wpdirectorykit' ),
1057 'type' => Controls_Manager::CHOOSE,
1058 'options' => [
1059 'left' => [
1060 'title' => esc_html__( 'Left', 'wpdirectorykit' ),
1061 'icon' => 'eicon-text-align-left',
1062 ],
1063 'center' => [
1064 'title' => esc_html__( 'Center', 'wpdirectorykit' ),
1065 'icon' => 'eicon-text-align-center',
1066 ],
1067 'right' => [
1068 'title' => esc_html__( 'Right', 'wpdirectorykit' ),
1069 'icon' => 'eicon-text-align-right',
1070 ],
1071 'justify' => [
1072 'title' => esc_html__( 'Justified', 'wpdirectorykit' ),
1073 'icon' => 'eicon-text-align-justify',
1074 ],
1075 ],
1076 'default' => 'left',
1077 'render_type' => 'ui',
1078 'selectors_dictionary' => [
1079 'top' => 'justify-content: flex-start;',
1080 'center' => 'justify-content: center;',
1081 'bottom' => 'justify-content: flex-end;',
1082 'justify' => 'justify-content: stretch;',
1083 ],
1084 'selectors' => [
1085 '{{WRAPPER}} '.$item['selector'] => '{{VALUE}};',
1086 ],
1087 ]
1088 );
1089 }
1090 $this->end_controls_section();
1091 /* END special for some elements */
1092 }
1093 }
1094
1095
1096 public function enqueue_styles_scripts() {
1097 wp_enqueue_style('leaflet');
1098 wp_enqueue_style('leaflet-cluster-def');
1099 wp_enqueue_style('leaflet-cluster');
1100 wp_enqueue_script('leaflet');
1101 wp_enqueue_script('leaflet-cluster');
1102 wp_enqueue_script('leaflet-fullscreen');
1103 wp_enqueue_style('leaflet-fullscreen');
1104
1105 wp_enqueue_style('wdk-notify');
1106 wp_enqueue_script('wdk-notify');
1107 wp_enqueue_style( 'wdk-listings-map' );
1108 }
1109
1110 }
1111