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

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

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