PluginProbe
WP Directory Kit / 1.2.3
WP Directory Kit v1.2.3
1.5.6 1.5.5 1.5.4 1.5.3 trunk 1.1.0 1.1.6 1.1.8 1.2.3 1.2.4 1.2.5 1.2.6 1.2.7 1.2.8 1.2.9 1.3.0 1.3.1 1.3.2 1.3.3 1.3.4 1.3.5 1.3.6 1.3.8 1.4.0 1.4.1 All 35 releases
wpdirectorykit / elementor-elements / classes / wdk-locations-tree.php

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

533 lines 19.2 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 namespace Wdk\Elementor\Widgets;
4
5 use Wdk\Elementor\Widgets\WdkElementorBase;
6 use Elementor\Widget_Base;
7 use Elementor\Controls_Manager;
8 use Elementor\Utils;
9 use Elementor\Typography;
10 use Elementor\Editor;
11 use Elementor\Plugin;
12 use Elementor\Repeater;
13 use Elementor\Core\Schemes;
14 use Elementor\Icons_Manager;
15 use Elementor\Group_Control_Typography;
16 use Elementor\Group_Control_Border;
17 use Elementor\Group_Control_Box_Shadow;
18
19 if (!defined('ABSPATH'))
20 exit; // Exit if accessed directly
21
22 /**
23 * @since 1.1.0
24 */
25 class 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::SELECT,
161 'default' => '',
162 'options' => $pages
163 ]
164 );
165
166 $this->add_control(
167 'show_icon',
168 [
169 'label' => __( 'Enable Location Icons', 'wpdirectorykit' ),
170 'type' => \Elementor\Controls_Manager::SWITCHER,
171 'label_on' => __( 'On', 'wpdirectorykit' ),
172 'label_off' => __( 'Off', 'wpdirectorykit' ),
173 'return_value' => 'yes',
174 'default' => 'yes',
175 'separator' => 'before',
176 ]
177 );
178
179 $this->add_control(
180 'layout_image_type',
181 [
182 'label' => __( 'Thumbnail Type', 'wpdirectorykit' ),
183 'type' => \Elementor\Controls_Manager::SELECT,
184 'default' => 'image',
185 'options' => [
186 'icon' => __( 'Icon', 'wpdirectorykit' ),
187 'image' => __( 'Image', 'wpdirectorykit' ),
188 ],
189 'conditions' => [
190 'terms' => [
191 [
192 'name' => 'show_icon',
193 'operator' => '==',
194 'value' => 'yes',
195 ]
196 ],
197 ],
198 ]
199 );
200
201 $this->add_control(
202 'important_note',
203 [
204 'label' => '',
205 'type' => \Elementor\Controls_Manager::RAW_HTML,
206 'raw' => sprintf(__( 'Manage Locations <a href="%1$s" target="_blank"> open </a>', 'wpdirectorykit' ), admin_url('admin.php?page=wdk_location')),
207 'content_classes' => 'wdk_elementor_hint',
208 ]
209 );
210
211 $this->add_responsive_control(
212 'row_gap_col',
213 [
214 'label' => __( 'Columns', 'wpdirectorykit' ),
215 'type' => Controls_Manager::SELECT,
216 'options' => [
217 '' => esc_html__('Default', 'wpdirectorykit'),
218 'auto' => esc_html__('Auto', 'wpdirectorykit'),
219 '100%' => '1',
220 '50%' => '2',
221 'calc(100% / 3)' => '3',
222 '25%' => '4',
223 '20%' => '5',
224 'auto_flexible' => 'auto flexible',
225 ],
226 'selectors_dictionary' => [
227 'auto' => '-webkit-flex:0 0 auto;flex:0 0 auto',
228 '100%' => '-webkit-flex:0 0 100%;flex:0 0 100%',
229 '50%' => '-webkit-flex:0 0 50%;flex:0 0 50%',
230 'calc(100% / 3)' => '-webkit-flex:0 0 calc(100% / 3);flex:0 0 calc(100% / 3)',
231 '25%' => '-webkit-flex:0 0 25%;flex:0 0 25%',
232 '20%' => '-webkit-flex:0 0 20%;flex:0 0 20%',
233 'auto' => '-webkit-flex:0 0 auto;flex:0 0 auto',
234 'auto_flexible' => '-webkit-flex:0 0 auto;flex:0 0 auto',
235 ],
236 'selectors' => [
237 '{{WRAPPER}} .wdk-row .wdk-col' => '{{UNIT}}',
238 ],
239 'default' => 'calc(100% / 3)',
240 'separator' => 'before',
241 ]
242 );
243
244 $this->add_responsive_control(
245 'column_gap',
246 [
247 'label' => esc_html__('Columns Gap', 'wpdirectorykit'),
248 'type' => Controls_Manager::SLIDER,
249 'default' => [
250 'size' => 10,
251 ],
252 'range' => [
253 'px' => [
254 'min' => 0,
255 'max' => 60,
256 ],
257 ],
258 'selectors' => [
259 '{{WRAPPER}} .wdk-row .wdk-col' => 'padding-left: {{SIZE}}{{UNIT}};padding-right: {{SIZE}}{{UNIT}};;',
260 '{{WRAPPER}} .wdk-row' => 'margin-left: -{{SIZE}}{{UNIT}};margin-right: -{{SIZE}}{{UNIT}};',
261 ],
262 ]
263 );
264
265 $this->add_responsive_control(
266 'row_gap',
267 [
268 'label' => esc_html__('Rows Gap', 'wpdirectorykit'),
269 'type' => Controls_Manager::SLIDER,
270 'default' => [
271 'size' => 10,
272 ],
273 'range' => [
274 'px' => [
275 'min' => 0,
276 'max' => 60,
277 ],
278 ],
279 'selectors' => [
280 '{{WRAPPER}} .wdk-row .wdk-col' => 'margin-bottom: {{SIZE}}{{UNIT}};',
281 '{{WRAPPER}} .wdk-row' => 'margin-bottom: -{{SIZE}}{{UNIT}};',
282 ],
283 ]
284 );
285
286 $this->end_controls_section();
287 }
288
289 private function generate_controls_layout() {
290 }
291
292 private function generate_controls_styles() {
293 $this->start_controls_section(
294 'sstyles_thmbn_section',
295 [
296 'label' => esc_html__('Main', 'wpdirectorykit'),
297 'tab' => Controls_Manager::TAB_STYLE,
298 ]
299 );
300
301 $this->add_responsive_control(
302 'list_gap',
303 [
304 'label' => esc_html__('Rows Gap', 'wpdirectorykit'),
305 'type' => Controls_Manager::SLIDER,
306 'default' => [
307 'size' => 10,
308 ],
309 'range' => [
310 'px' => [
311 'min' => 0,
312 'max' => 60,
313 ],
314 ],
315 'selectors' => [
316 '{{WRAPPER}} .wdk-locations .wdk-item' => 'margin-bottom: {{SIZE}}{{UNIT}};',
317 ],
318 ]
319 );
320
321 $this->end_controls_section();
322
323 $items = [
324 [
325 'key'=>'title',
326 'label'=> esc_html__('Title', 'wpdirectorykit'),
327 'selector'=>'.title',
328 'selector_hover'=>'.title%1$s',
329 'options'=>['color','background','border','border_radius','padding','shadow','transition','margin','padding'],
330 ],
331 [
332 'key'=>'item_button',
333 'label'=> esc_html__('Item Box', 'wpdirectorykit'),
334 'selector'=>'.wdk-locations .wdk-link',
335 'selector_hover'=>'.wdk-locations .wdk-link%1$s',
336 'options'=>['color','background','border','border_radius','padding','shadow','transition'],
337 ],
338 [
339 'key'=>'item_icon',
340 'label'=> esc_html__('Item Icon', 'wpdirectorykit'),
341 'selector'=>'.wdk-locations .wdk-link i',
342 'selector_hover'=>'.wdk-locations .wdk-link%1$s i',
343 'options'=>['margin','color','background','border','border_radius','padding','shadow'],
344 ],
345 [
346 'key'=>'location_icon',
347 'label'=> esc_html__('Location Icon', 'wpdirectorykit'),
348 'selector'=>'.title .wdk-icon',
349 'selector_hover'=>'.title%1$s .wdk-icon',
350 'options'=>['margin','color','background','border','border_radius','padding','shadow','image_size_control','image_fit_control'],
351 ],
352 [
353 'key'=>'location_image',
354 'label'=> esc_html__('Location Image', 'wpdirectorykit'),
355 'selector'=>'.title .wdk-image',
356 'selector_hover'=>'.title%1$s .wdk-image',
357 'options'=>['margin','background','border','border_radius','padding','shadow','transition','image_size_control', 'css_filters','image_fit_control'],
358 ],
359 [
360 'key'=>'item_title',
361 'label'=> esc_html__('Item Title', 'wpdirectorykit'),
362 'selector'=>'.wdk-locations .wdk-link .wdk-title',
363 'selector_hover'=>'.wdk-locations .wdk-link%1$s .wdk-title',
364 'options'=>['margin','typo','color','background','border','border_radius','padding'],
365 ],
366 [
367 'key'=>'item_count',
368 'label'=> esc_html__('Item Count', 'wpdirectorykit'),
369 'selector'=>'.wdk-locations .wdk-link .wdk-count',
370 'selector_hover'=>'.wdk-locations .wdk-link%1$s .wdk-count',
371 'options'=>['margin','typo','color','background','border','border_radius','padding'],
372 ],
373 ];
374
375 foreach ($items as $item) {
376 if($item['key'] == 'location_icon') {
377 $this->start_controls_section(
378 $item['key'].'_section',
379 [
380 'label' => $item['label'],
381 'tab' => Controls_Manager::TAB_STYLE,
382 'conditions' => [
383 'terms' => [
384 [
385 'name' => 'show_icon',
386 'operator' => '==',
387 'value' => 'yes',
388 ],
389 [
390 'name' => 'layout_image_type',
391 'operator' => '==',
392 'value' => 'icon',
393 ]
394 ],
395 ],
396 ]
397 );
398 } elseif($item['key'] == 'location_image') {
399 $this->start_controls_section(
400 $item['key'].'_section',
401 [
402 'label' => $item['label'],
403 'tab' => Controls_Manager::TAB_STYLE,
404 'conditions' => [
405 'terms' => [
406 [
407 'name' => 'show_icon',
408 'operator' => '==',
409 'value' => 'yes',
410 ],
411 [
412 'name' => 'layout_image_type',
413 'operator' => '==',
414 'value' => 'image',
415 ]
416 ],
417 ],
418 ]
419 );
420 } else {
421 $this->start_controls_section(
422 $item['key'].'_section',
423 [
424 'label' => $item['label'],
425 'tab' => Controls_Manager::TAB_STYLE,
426 ]
427 );
428 }
429
430 $this->add_responsive_control(
431 $item['key'].'_hide',
432 [
433 'label' => esc_html__( 'Hide Element', 'wpdirectorykit' ),
434 'type' => Controls_Manager::SWITCHER,
435 'none' => esc_html__( 'Hide', 'wpdirectorykit' ),
436 'block' => esc_html__( 'Show', 'wpdirectorykit' ),
437 'return_value' => 'none',
438 'default' => '',
439 'selectors' => [
440 '{{WRAPPER}} '.$item['selector'] => 'display: {{VALUE}};',
441 ],
442 ]
443 );
444 $selectors = array(
445 'normal' => '{{WRAPPER}} '.$item['selector'],
446 'hover'=>'{{WRAPPER}} '.$item['selector_hover'],
447 );
448 $this->generate_renders_tabs($selectors, $item['key'].'_dynamic', $item['options']);
449
450 /* special for some elements */
451 if($item['key'] == 'item_icon') {
452 $this->add_control(
453 $item['key'].'_i',
454 [
455 'label' => esc_html__('Icon', 'wpdirectorykit'),
456 'type' => Controls_Manager::ICONS,
457 'label_block' => true,
458 'default' => [
459 'value' => 'fa fa-angle-right',
460 'library' => 'solid',
461 ],
462 ]
463 );
464 $this->add_responsive_control(
465 $item['key'].'_size',
466 [
467 'label' => __( 'Size', 'wpdirectorykit' ),
468 'type' => Controls_Manager::SLIDER,
469 'size_units' => [ 'px'],
470 'range' => [
471 'px' => [
472 'min' => 1,
473 'max' => 60,
474 'step' => 1,
475 ],
476 ],
477 'default' => [
478 'unit' => 'px',
479 'size' => 14,
480 ],
481 'selectors' => [
482 '{{WRAPPER}} '.$item['selector'] => 'font-size: {{SIZE}}{{UNIT}};',
483 ],
484 ]
485 );
486 }
487 if($item['key'] == 'item_count') {
488 $this->add_responsive_control(
489 $item['key'].'_align',
490 [
491 'label' => __( 'Position', 'wpdirectorykit' ),
492 'type' => Controls_Manager::CHOOSE,
493 'options' => [
494 'left' => [
495 'title' => esc_html__( 'Left', 'wpdirectorykit' ),
496 'icon' => 'eicon-text-align-left',
497 ],
498 'center' => [
499 'title' => esc_html__( 'Center', 'wpdirectorykit' ),
500 'icon' => 'eicon-text-align-center',
501 ],
502 'right' => [
503 'title' => esc_html__( 'Right', 'wpdirectorykit' ),
504 'icon' => 'eicon-text-align-right',
505 ],
506
507 ],
508 'render_type' => 'ui',
509 'selectors_dictionary' => [
510 'left' => 'text-align: left;',
511 'center' => 'text-alig: center;',
512 'right' => 'text-align: right;',
513 ],
514 'selectors' => [
515 '{{WRAPPER}} '.$item['selector'] => '{{VALUE}};',
516 ],
517 ]
518 );
519 }
520
521 $this->end_controls_section();
522 }
523 }
524
525 private function generate_controls_content() {
526
527 }
528
529 public function enqueue_styles_scripts() {
530 wp_enqueue_style('wdk-locations-tree');
531 }
532 }
533