PluginProbe
WP Directory Kit / 1.5.9
WP Directory Kit v1.5.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-locations-tree.php

wdk-locations-tree.php in WP Directory Kit 1.5.9, at elementor-elements/classes/wdk-locations-tree.php

552 lines 20.0 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 WdkLocationsTree 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
35 \Elementor\Controls_Manager::add_tab(
36 'tab_layout',
37 esc_html__('Layout', 'wpdirectorykit')
38 );
39
40 \Elementor\Controls_Manager::add_tab(
41 'tab_content',
42 esc_html__('Main', 'wpdirectorykit')
43 );
44
45 if ($this->is_edit_mode_load()) {
46 $this->enqueue_styles_scripts();
47 }
48
49 parent::__construct($data, $args);
50 }
51
52 /**
53 * Retrieve the widget name.
54 *
55 * @since 1.1.0
56 *
57 * @access public
58 *
59 * @return string Widget name.
60 */
61 public function get_name() {
62 return 'wdk-locations-tree';
63 }
64
65 /**
66 * Retrieve the widget title.
67 *
68 * @since 1.1.0
69 *
70 * @access public
71 *
72 * @return string Widget title.
73 */
74 public function get_title() {
75 return esc_html__('Wdk Locations Tree', 'wpdirectorykit');
76 }
77
78 /**
79 * Retrieve the widget icon.
80 *
81 * @since 1.1.0
82 *
83 * @access public
84 *
85 * @return string Widget icon.
86 */
87 public function get_icon() {
88 return 'eicon-post-list';
89 }
90
91 /**
92 * Register the widget controls.
93 *
94 * Adds different input fields to allow the user to change and customize the widget settings.
95 *
96 * @since 1.1.0
97 *
98 * @access protected
99 */
100 protected function register_controls() {
101 $this->generate_controls_conf();
102 $this->generate_controls_layout();
103 $this->generate_controls_styles();
104 $this->generate_controls_content();
105
106 $this->insert_pro_message('1');
107 parent::register_controls();
108 }
109
110 /**
111 * Render the widget output on the frontend.
112 *
113 * Written in PHP and used to generate the final HTML.
114 *
115 * @since 1.1.0
116 *
117 * @access protected
118 */
119 protected function render() {
120 parent::render();
121 $this->data['id_element'] = $this->get_id();
122 $this->data['settings'] = $this->get_settings();
123
124 $controller = 'location';
125 $this->WMVC->model($controller.'_m');
126 $this->WMVC->model('listing_m');
127 $this->WMVC->model('location_m');
128
129 $this->data['results'] = array();
130
131 $this->data['locations'] = $this->WMVC->location_m->get_pagination(NULL, NULL, array());
132
133
134 $this->data['is_edit_mode']= false;
135 if(Plugin::$instance->editor->is_edit_mode())
136 $this->data['is_edit_mode']= true;
137
138 $this->view('wdk-locations-tree', $this->data, true);
139 }
140
141
142 private function generate_controls_conf() {
143 $this->start_controls_section(
144 'tab_conf_main_section',
145 [
146 'label' => esc_html__('Main', 'wpdirectorykit'),
147 'tab' => '1',
148 ]
149 );
150
151 $pages = array('' => __('Not Selected', 'wpdirectorykit'));
152 foreach(get_pages(array('sort_column' => 'post_title')) as $page)
153 {
154 $pages[$page->ID] = $page->post_title.' #'.$page->ID;
155 }
156
157 $this->add_control(
158 'conf_link',
159 [
160 'label' => __( 'Open results on page', 'wpdirectorykit' ),
161 'type' => \Elementor\Controls_Manager::SELECT2,
162 'default' => '',
163 'options' => $pages
164 ]
165 );
166
167 $this->add_control(
168 'disable_empty_listings',
169 [
170 'label' => __( 'Disable With Empty Listings', 'wpdirectorykit' ),
171 'type' => \Elementor\Controls_Manager::SWITCHER,
172 'label_on' => __( 'On', 'wpdirectorykit' ),
173 'label_off' => __( 'Off', 'wpdirectorykit' ),
174 'return_value' => 'yes',
175 'default' => '',
176 'separator' => 'before',
177 ]
178 );
179
180 $this->add_control(
181 'show_icon',
182 [
183 'label' => __( 'Enable Location Icons', 'wpdirectorykit' ),
184 'type' => \Elementor\Controls_Manager::SWITCHER,
185 'label_on' => __( 'On', 'wpdirectorykit' ),
186 'label_off' => __( 'Off', 'wpdirectorykit' ),
187 'return_value' => 'yes',
188 'default' => 'yes',
189 'separator' => 'before',
190 ]
191 );
192
193 $this->add_control(
194 'layout_image_type',
195 [
196 'label' => __( 'Thumbnail Type', 'wpdirectorykit' ),
197 'type' => \Elementor\Controls_Manager::SELECT,
198 'default' => 'image',
199 'options' => [
200 'icon' => __( 'Icon', 'wpdirectorykit' ),
201 'image' => __( 'Image', 'wpdirectorykit' ),
202 ],
203 'conditions' => [
204 'terms' => [
205 [
206 'name' => 'show_icon',
207 'operator' => '==',
208 'value' => 'yes',
209 ]
210 ],
211 ],
212 ]
213 );
214
215 $this->add_control(
216 'important_note',
217 [
218 'label' => '',
219 'type' => \Elementor\Controls_Manager::RAW_HTML,
220 /* translators: 1: URL. */
221 'raw' => wdk_sprintf(__( 'Manage Locations <a href="%1$s" target="_blank"> open </a>', 'wpdirectorykit' ), admin_url('admin.php?page=wdk_location')),
222 'content_classes' => 'wdk_elementor_hint',
223 ]
224 );
225
226 $this->add_responsive_control(
227 'row_gap_col',
228 [
229 'label' => __( 'Columns', 'wpdirectorykit' ),
230 'type' => Controls_Manager::SELECT,
231 'options' => [
232 '' => esc_html__('Default', 'wpdirectorykit'),
233 'auto' => esc_html__('Auto', 'wpdirectorykit'),
234 '100%' => '1',
235 '50%' => '2',
236 'calc(100% / 3)' => '3',
237 '25%' => '4',
238 '20%' => '5',
239 'auto_flexible' => 'auto flexible',
240 ],
241 'selectors_dictionary' => [
242 'auto' => '-webkit-flex:0 0 auto;flex:0 0 auto',
243 '100%' => '-webkit-flex:0 0 100%;flex:0 0 100%',
244 '50%' => '-webkit-flex:0 0 50%;flex:0 0 50%',
245 'calc(100% / 3)' => '-webkit-flex:0 0 calc(100% / 3);flex:0 0 calc(100% / 3)',
246 '25%' => '-webkit-flex:0 0 25%;flex:0 0 25%',
247 '20%' => '-webkit-flex:0 0 20%;flex:0 0 20%',
248 'auto' => '-webkit-flex:0 0 auto;flex:0 0 auto',
249 'auto_flexible' => '-webkit-flex:0 0 auto;flex:0 0 auto',
250 ],
251 'selectors' => [
252 '{{WRAPPER}} .wdk-row .wdk-col' => '{{UNIT}}',
253 ],
254 'default' => 'calc(100% / 3)',
255 'separator' => 'before',
256 ]
257 );
258
259 $this->add_responsive_control(
260 'column_gap',
261 [
262 'label' => esc_html__('Columns Gap', 'wpdirectorykit'),
263 'type' => Controls_Manager::SLIDER,
264 'default' => [
265 'size' => 10,
266 ],
267 'range' => [
268 'px' => [
269 'min' => 0,
270 'max' => 60,
271 ],
272 ],
273 'selectors' => [
274 '{{WRAPPER}} .wdk-row .wdk-col' => 'padding-left: {{SIZE}}{{UNIT}};padding-right: {{SIZE}}{{UNIT}};;',
275 '{{WRAPPER}} .wdk-row' => 'margin-left: -{{SIZE}}{{UNIT}};margin-right: -{{SIZE}}{{UNIT}};',
276 ],
277 ]
278 );
279
280 $this->add_responsive_control(
281 'row_gap',
282 [
283 'label' => esc_html__('Rows Gap', 'wpdirectorykit'),
284 'type' => Controls_Manager::SLIDER,
285 'default' => [
286 'size' => 10,
287 ],
288 'range' => [
289 'px' => [
290 'min' => 0,
291 'max' => 60,
292 ],
293 ],
294 'selectors' => [
295 '{{WRAPPER}} .wdk-row .wdk-col' => 'margin-bottom: {{SIZE}}{{UNIT}};',
296 '{{WRAPPER}} .wdk-row' => 'margin-bottom: -{{SIZE}}{{UNIT}};',
297 ],
298 ]
299 );
300
301 $this->end_controls_section();
302 }
303
304 private function generate_controls_layout() {
305 }
306
307 private function generate_controls_styles() {
308 $this->start_controls_section(
309 'sstyles_thmbn_section',
310 [
311 'label' => esc_html__('Main', 'wpdirectorykit'),
312 'tab' => Controls_Manager::TAB_STYLE,
313 ]
314 );
315
316 $this->add_responsive_control(
317 'list_gap',
318 [
319 'label' => esc_html__('Rows Gap', 'wpdirectorykit'),
320 'type' => Controls_Manager::SLIDER,
321 'default' => [
322 'size' => 10,
323 ],
324 'range' => [
325 'px' => [
326 'min' => 0,
327 'max' => 60,
328 ],
329 ],
330 'selectors' => [
331 '{{WRAPPER}} .wdk-locations .wdk-item' => 'margin-bottom: {{SIZE}}{{UNIT}};',
332 ],
333 ]
334 );
335
336 $this->end_controls_section();
337
338 $items = [
339 [
340 'key'=>'title',
341 'label'=> esc_html__('Title', 'wpdirectorykit'),
342 'selector'=>'.title',
343 'selector_hover'=>'.title%1$s',
344 'options'=>['typo','color','background','border','border_radius','padding','shadow','transition','margin','padding'],
345 ],
346 [
347 'key'=>'location_image',
348 'label'=> esc_html__('Location Image', 'wpdirectorykit'),
349 'selector'=>'.title .wdk-image',
350 'selector_hover'=>'.title%1$s .wdk-image',
351 'options'=>['margin','background','border','border_radius','padding','shadow','transition','image_size_control', 'css_filters','image_fit_control'],
352 ],
353 [
354 'key'=>'location_icon',
355 'label'=> esc_html__('Location Icon', 'wpdirectorykit'),
356 'selector'=>'.title .wdk-icon',
357 'selector_hover'=>'.title%1$s .wdk-icon',
358 'options'=>['margin','color','background','border','border_radius','padding','shadow','image_size_control','image_fit_control'],
359 ],
360 [
361 'key'=>'item_button',
362 'label'=> esc_html__('Sub Location List Item', 'wpdirectorykit'),
363 'selector'=>'.wdk-locations .wdk-link',
364 'selector_hover'=>'.wdk-locations .wdk-link%1$s',
365 'options'=>['color','background','border','border_radius','padding','shadow','transition'],
366 ],
367 [
368 'key'=>'item_icon',
369 'label'=> esc_html__('Sub Location List item Icon', 'wpdirectorykit'),
370 'selector'=>'.wdk-locations .wdk-link i',
371 'selector_hover'=>'.wdk-locations .wdk-link%1$s i',
372 'options'=>['margin','color','background','border','border_radius','padding','shadow'],
373 ],
374 [
375 'key'=>'item_title',
376 'label'=> esc_html__('Sub Location List Item Title', 'wpdirectorykit'),
377 'selector'=>'.wdk-locations .wdk-link .wdk-title',
378 'selector_hover'=>'.wdk-locations .wdk-link%1$s .wdk-title',
379 'options'=>['margin','typo','color','background','border','border_radius','padding'],
380 ],
381 [
382 'key'=>'item_count',
383 'label'=> esc_html__('Sub Location List Item Count', 'wpdirectorykit'),
384 'selector'=>'.wdk-locations .wdk-link .wdk-count',
385 'selector_hover'=>'.wdk-locations .wdk-link%1$s .wdk-count',
386 'options'=>['margin','typo','color','background','border','border_radius','padding'],
387 ],
388 ];
389
390 foreach ($items as $item) {
391 if($item['key'] == 'location_icon') {
392 $this->start_controls_section(
393 $item['key'].'_section',
394 [
395 'label' => $item['label'],
396 'tab' => Controls_Manager::TAB_STYLE,
397 'conditions' => [
398 'terms' => [
399 [
400 'name' => 'show_icon',
401 'operator' => '==',
402 'value' => 'yes',
403 ],
404 [
405 'name' => 'layout_image_type',
406 'operator' => '==',
407 'value' => 'icon',
408 ]
409 ],
410 ],
411 ]
412 );
413 } elseif($item['key'] == 'location_image') {
414 $this->start_controls_section(
415 $item['key'].'_section',
416 [
417 'label' => $item['label'],
418 'tab' => Controls_Manager::TAB_STYLE,
419 'conditions' => [
420 'terms' => [
421 [
422 'name' => 'show_icon',
423 'operator' => '==',
424 'value' => 'yes',
425 ],
426 [
427 'name' => 'layout_image_type',
428 'operator' => '==',
429 'value' => 'image',
430 ]
431 ],
432 ],
433 ]
434 );
435 } else {
436 $this->start_controls_section(
437 $item['key'].'_section',
438 [
439 'label' => $item['label'],
440 'tab' => Controls_Manager::TAB_STYLE,
441 ]
442 );
443 }
444
445 if(empty($item['selector_hide'])) {
446 $item['selector_hide'] = $item['selector'];
447 }
448
449 $this->add_responsive_control(
450 $item['key'].'_hide',
451 [
452 'label' => esc_html__( 'Hide Element', 'wpdirectorykit' ),
453 'type' => Controls_Manager::SWITCHER,
454 'none' => esc_html__( 'Hide', 'wpdirectorykit' ),
455 'block' => esc_html__( 'Show', 'wpdirectorykit' ),
456 'return_value' => 'none',
457 'default' => '',
458 'selectors' => [
459 '{{WRAPPER}} '.$item['selector_hide'] => 'display: {{VALUE}};',
460 ],
461 ]
462 );
463 $selectors = array(
464 'normal' => '{{WRAPPER}} '.$item['selector'],
465 'hover'=>'{{WRAPPER}} '.$item['selector_hover'],
466 );
467 $this->generate_renders_tabs($selectors, $item['key'].'_dynamic', $item['options']);
468
469 /* special for some elements */
470 if($item['key'] == 'item_icon') {
471 $this->add_control(
472 $item['key'].'_i',
473 [
474 'label' => esc_html__('Icon', 'wpdirectorykit'),
475 'type' => Controls_Manager::ICONS,
476 'label_block' => true,
477 'default' => [
478 'value' => 'fa fa-angle-right',
479 'library' => 'solid',
480 ],
481 ]
482 );
483 $this->add_responsive_control(
484 $item['key'].'_size',
485 [
486 'label' => __( 'Size', 'wpdirectorykit' ),
487 'type' => Controls_Manager::SLIDER,
488 'size_units' => [ 'px','em', 'vw', '%', 'custom' ],
489 'range' => [
490 'px' => [
491 'min' => 1,
492 'max' => 60,
493 'step' => 1,
494 ],
495 ],
496 'default' => [
497 'unit' => 'px',
498 'size' => 14,
499 ],
500 'selectors' => [
501 '{{WRAPPER}} '.$item['selector'] => 'font-size: {{SIZE}}{{UNIT}};',
502 ],
503 ]
504 );
505 }
506 if($item['key'] == 'item_count') {
507 $this->add_responsive_control(
508 $item['key'].'_align',
509 [
510 'label' => __( 'Position', 'wpdirectorykit' ),
511 'type' => Controls_Manager::CHOOSE,
512 'options' => [
513 'left' => [
514 'title' => esc_html__( 'Left', 'wpdirectorykit' ),
515 'icon' => 'eicon-text-align-left',
516 ],
517 'center' => [
518 'title' => esc_html__( 'Center', 'wpdirectorykit' ),
519 'icon' => 'eicon-text-align-center',
520 ],
521 'right' => [
522 'title' => esc_html__( 'Right', 'wpdirectorykit' ),
523 'icon' => 'eicon-text-align-right',
524 ],
525
526 ],
527 'render_type' => 'ui',
528 'selectors_dictionary' => [
529 'left' => 'text-align: left;',
530 'center' => 'text-alig: center;',
531 'right' => 'text-align: right;',
532 ],
533 'selectors' => [
534 '{{WRAPPER}} '.$item['selector'] => '{{VALUE}};',
535 ],
536 ]
537 );
538 }
539
540 $this->end_controls_section();
541 }
542 }
543
544 private function generate_controls_content() {
545
546 }
547
548 public function enqueue_styles_scripts() {
549 wp_enqueue_style('wdk-locations-tree');
550 }
551 }
552