PluginProbe
WP Directory Kit / 1.3.1
WP Directory Kit v1.3.1
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-categories-tree-top.php

wdk-categories-tree-top.php in WP Directory Kit 1.3.1, at elementor-elements/classes/wdk-categories-tree-top.php

906 lines 35.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 WdkCategoriesTreeTop 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-categories-tree-top';
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 Categories Tree Top', '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-sitemap';
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 = 'category';
124 $this->WMVC->model($controller.'_m');
125 $this->WMVC->model('listing_m');
126 $this->WMVC->model('category_m');
127
128 $this->data['categories_primary'] = array();
129 $this->data['categories_secondary'] = array();
130
131 /* primary */
132 if($this->data['settings']['primary_conf_results_type'] == 'custom_categories') {
133 $categories_ids = array();
134 foreach($this->data['settings']['primary_conf_custom_results'] as $category) {
135 if(isset($category['category_id']) && !empty($category['category_id'])) {
136 $categories_ids [] = $category['category_id'];
137 }
138 }
139 /* where in */
140 if(!empty($categories_ids)){
141 $this->WMVC->db->select($this->WMVC->{$controller.'_m'}->_table_name.'.*, COUNT('.$this->WMVC->listing_m->_table_name.'.post_id) AS listings_counter');
142 $this->WMVC->db->join($this->WMVC->listing_m->_table_name.' ON '.$this->WMVC->listing_m->_table_name.'.category_id = '.$this->WMVC->{$controller.'_m'}->_table_name.'.idcategory', TRUE, 'LEFT');
143 $this->WMVC->db->where($this->WMVC->{$controller.'_m'}->_table_name.'.idcategory IN(' . implode(',', $categories_ids) . ')', null, false);
144 $this->WMVC->db->order_by('FIELD('.$this->WMVC->{$controller.'_m'}->_table_name.'.idcategory, '. implode(',', $categories_ids) . ')');
145 $this->WMVC->db->group_by($this->WMVC->{$controller.'_m'}->_primary_key);
146 $this->data['categories_primary'] = $this->WMVC->{$controller.'_m'}->get();
147 }
148 } else {
149 $where = array();
150 if ($this->data['settings']['primary_root_enable'] == 'yes' && $this->data['settings']['primary_sub_enable'] != 'yes') {
151 $where['('.$this->WMVC->{$controller.'_m'}->_table_name.'.level = 0)'] = NULL;
152 } elseif ($this->data['settings']['primary_root_enable'] != 'yes' && $this->data['settings']['primary_sub_enable'] == 'yes') {
153 $where['('.$this->WMVC->{$controller.'_m'}->_table_name.'.level != 0)'] = NULL;
154 }
155
156 $order_by = NULL;
157 if($this->data['settings']['primary_conf_order_by'] == 'order_most') {
158 /* get category with most listings */
159 $order_by = 'listings_counter '.$this->data['settings']['primary_conf_order'];
160 } else if (!empty($this->data['settings']['primary_conf_order_by'])) {
161 $order_by = $this->data['settings']['primary_conf_order_by'].' '.$this->data['settings']['primary_conf_order'];
162 }
163
164 $this->data['categories_primary'] = $this->WMVC->{$controller.'_m'}->get_pagination((!empty($this->data['settings']['primary_conf_limit'])) ? $this->data['settings']['primary_conf_limit'] : NULL, $this->data['settings']['primary_conf_offset'], $where, $order_by);
165 }
166
167 /* secondary */
168 if($this->data['settings']['secondary_categories_enable'] == 'yes')
169 if($this->data['settings']['secondary_conf_results_type'] == 'custom_categories') {
170 $categories_ids = array();
171 foreach($this->data['settings']['secondary_conf_custom_results'] as $category) {
172 if(isset($category['category_id']) && !empty($category['category_id'])) {
173 $categories_ids [] = $category['category_id'];
174 }
175 }
176 /* where in */
177 if(!empty($categories_ids)){
178 $this->WMVC->db->select($this->WMVC->{$controller.'_m'}->_table_name.'.*, COUNT('.$this->WMVC->listing_m->_table_name.'.post_id) AS listings_counter');
179 $this->WMVC->db->join($this->WMVC->listing_m->_table_name.' ON '.$this->WMVC->listing_m->_table_name.'.category_id = '.$this->WMVC->{$controller.'_m'}->_table_name.'.idcategory', TRUE, 'LEFT');
180 $this->WMVC->db->where($this->WMVC->{$controller.'_m'}->_table_name.'.idcategory IN(' . implode(',', $categories_ids) . ')', null, false);
181 $this->WMVC->db->order_by('FIELD('.$this->WMVC->{$controller.'_m'}->_table_name.'.idcategory, '. implode(',', $categories_ids) . ')');
182 $this->WMVC->db->group_by($this->WMVC->{$controller.'_m'}->_secondary_key);
183 $this->data['categories_secondary'] = $this->WMVC->{$controller.'_m'}->get();
184 }
185 } else {
186 $where = array();
187 if ($this->data['settings']['secondary_root_enable'] == 'yes' && $this->data['settings']['secondary_sub_enable'] != 'yes') {
188 $where['('.$this->WMVC->{$controller.'_m'}->_table_name.'.level = 0)'] = NULL;
189 } elseif ($this->data['settings']['secondary_root_enable'] != 'yes' && $this->data['settings']['secondary_sub_enable'] == 'yes') {
190 $where['('.$this->WMVC->{$controller.'_m'}->_table_name.'.level != 0)'] = NULL;
191 }
192
193 $order_by = NULL;
194 if($this->data['settings']['secondary_conf_order_by'] == 'order_most') {
195 /* get category with most listings */
196 $order_by = 'listings_counter '.$this->data['settings']['secondary_conf_order'];
197 } else if (!empty($this->data['settings']['secondary_conf_order_by'])) {
198 $order_by = $this->data['settings']['secondary_conf_order_by'].' '.$this->data['settings']['secondary_conf_order'];
199 }
200
201 $this->data['categories_secondary'] = $this->WMVC->{$controller.'_m'}->get_pagination((!empty($this->data['settings']['secondary_conf_limit'])) ? $this->data['settings']['secondary_conf_limit'] : NULL, $this->data['settings']['secondary_conf_offset'], $where, $order_by);
202 }
203
204
205 $this->data['is_edit_mode']= false;
206 if(Plugin::$instance->editor->is_edit_mode())
207 $this->data['is_edit_mode']= true;
208
209 echo $this->view('wdk-categories-tree-top', $this->data);
210 }
211
212
213 private function generate_controls_conf() {
214
215 $this->start_controls_section(
216 'tab_conf_main_section',
217 [
218 'label' => esc_html__('Main Options', 'wpdirectorykit'),
219 'tab' => '1',
220 ]
221 );
222
223 $pages = array('' => __('Not Selected', 'wpdirectorykit'));
224 foreach(get_pages(array('sort_column' => 'post_title')) as $page)
225 {
226 $pages[$page->ID] = $page->post_title.' #'.$page->ID;
227 }
228
229 $this->add_control(
230 'conf_link',
231 [
232 'label' => __( 'Open results on page', 'wpdirectorykit' ),
233 'type' => \Elementor\Controls_Manager::SELECT2,
234 'default' => '',
235 'options' => $pages
236 ]
237 );
238
239 $this->add_control(
240 'important_note',
241 [
242 'label' => '',
243 'type' => \Elementor\Controls_Manager::RAW_HTML,
244 'raw' => wdk_sprintf(__( 'Edit Categorys <a href="%1$s" target="_blank"> open </a>', 'wpdirectorykit' ), admin_url('admin.php?page=wdk_category')),
245 'content_classes' => 'wdk_elementor_hint',
246 ]
247 );
248
249 $this->end_controls_section();
250
251
252 $this->start_controls_section(
253 'tab_conf_primary_section',
254 [
255 'label' => esc_html__('Top section Categories', 'wpdirectorykit'),
256 'tab' => '1',
257 ]
258 );
259
260 $this->add_control(
261 'primary_conf_results_type',
262 [
263 'label' => __( 'Show type', 'wpdirectorykit' ),
264 'type' => \Elementor\Controls_Manager::SELECT,
265 'default' => 'results_categories',
266 'options' => [
267 'results_categories' => __( 'All Categorys', 'wpdirectorykit' ),
268 'custom_categories' => __( 'Specific', 'wpdirectorykit' ),
269 ],
270
271 ]
272 );
273
274 $this->add_responsive_control (
275 'primary_thumbnail_position',
276 [
277 'label' => __( 'Thumbnail/icon position', 'wpdirectorykit' ),
278 'type' => Controls_Manager::SELECT,
279 'options' => [
280 'right' => esc_html__('Rigth', 'wpdirectorykit'),
281 'left' => esc_html__('Left', 'wpdirectorykit'),
282 'top' => esc_html__('Top', 'wpdirectorykit'),
283 'bottom' => esc_html__('Bottom', 'wpdirectorykit'),
284 ],
285 'selectors_dictionary' => [
286 'right' => '',
287 'left' => 'flex-direction:row-reverse;text-align:right;',
288 'top' => 'flex-direction:column-reverse;text-align:center;',
289 'bottom' => 'flex-direction:column;text-align:center;',
290 ],
291 'selectors' => [
292 '{{WRAPPER}} .wdk-categories-tree-top .wdk-primary .category-card' => '{{UNIT}}',
293 ],
294 'default' => 'right',
295 'separator' => 'after',
296 ]
297 );
298
299 $this->add_responsive_control(
300 'primary_root_enable',
301 [
302 'label' => esc_html__( 'Show Main Categories', 'wpdirectorykit' ),
303 'type' => Controls_Manager::SWITCHER,
304 'none' => esc_html__( 'No', 'wpdirectorykit' ),
305 'block' => esc_html__( 'Yes', 'wpdirectorykit' ),
306 'return_value' => 'yes',
307 'default' => 'yes',
308 ]
309 );
310
311 $this->add_responsive_control(
312 'primary_sub_enable',
313 [
314 'label' => esc_html__( 'Show Sub Categories', 'wpdirectorykit' ),
315 'type' => Controls_Manager::SWITCHER,
316 'none' => esc_html__( 'No', 'wpdirectorykit' ),
317 'block' => esc_html__( 'Yes', 'wpdirectorykit' ),
318 'return_value' => 'yes',
319 'default' => '',
320 ]
321 );
322
323 $this->add_control(
324 'primary_layout_image_type',
325 [
326 'label' => __( 'Thumbnail Type', 'wpdirectorykit' ),
327 'type' => \Elementor\Controls_Manager::SELECT,
328 'default' => 'font_icon',
329 'options' => [
330 'icon' => __( 'Icon', 'wpdirectorykit' ),
331 'image' => __( 'Image', 'wpdirectorykit' ),
332 'font_icon' => __( 'Font Icon', 'wpdirectorykit' ),
333 ],
334 'separator' => 'before',
335 ]
336 );
337
338 $this->add_control(
339 'primary_conf_offset',
340 [
341 'label' => __( 'Offset Categories', 'wpdirectorykit' ),
342 'type' => \Elementor\Controls_Manager::NUMBER,
343 'min' => 1,
344 'max' => 50,
345 'step' => 1,
346 'default' => 0,
347 'conditions' => [
348 'terms' => [
349 [
350 'name' => 'primary_conf_results_type',
351 'operator' => '==',
352 'value' => 'results_categories',
353 ]
354 ],
355 ],
356 ]
357 );
358
359 $this->add_control(
360 'primary_conf_limit',
361 [
362 'label' => __( 'Limit Categories', 'wpdirectorykit' ),
363 'description' => __( 'Set 0 for unlimit', 'wpdirectorykit' ),
364 'type' => \Elementor\Controls_Manager::NUMBER,
365 'min' => 0,
366 'max' => 500,
367 'step' => 1,
368 'default' => 3,
369 'separator' => 'before',
370 'conditions' => [
371 'terms' => [
372 [
373 'name' => 'primary_conf_results_type',
374 'operator' => '==',
375 'value' => 'results_categories',
376 ]
377 ],
378 ],
379 ]
380 );
381
382 $this->add_control(
383 'primary_conf_order_by',
384 [
385 'label' => __('Order By Column', 'wpdirectorykit'),
386 'type' => Controls_Manager::SELECT,
387 'label_block' => true,
388 'options' => [
389 '' => __('None', 'wpdirectorykit'),
390 'category_title' => __('Title', 'wpdirectorykit'),
391 'idcategory' => __('Category id', 'wpdirectorykit'),
392 'order_index' => __('Order index', 'wpdirectorykit'),
393 'listings_counter' => __('Most Listings', 'wpdirectorykit'),
394 'rand()' => __('Random', 'wpdirectorykit'),
395 ],
396 'default' => 'order_index',
397 'conditions' => [
398 'terms' => [
399 [
400 'name' => 'primary_conf_results_type',
401 'operator' => '==',
402 'value' => 'results_categories',
403 ]
404 ],
405 ],
406 ]
407 );
408
409 $this->add_control(
410 'primary_conf_order',
411 [
412 'label' => __('Order', 'wpdirectorykit'),
413 'type' => Controls_Manager::SELECT,
414 'label_block' => true,
415 'options' => [
416 'asc' => __('Ascending', 'wpdirectorykit'),
417 'desc' => __('Descending', 'wpdirectorykit')
418 ],
419 'default' => 'desc',
420 'conditions' => [
421 'terms' => [
422 [
423 'name' => 'primary_conf_results_type',
424 'operator' => '==',
425 'value' => 'results_categories',
426 ]
427 ],
428 ],
429 ]
430 );
431
432 if(true){
433 $repeater = new Repeater();
434 $repeater->start_controls_tabs( 'categories' );
435 $repeater->add_control(
436 'category_id',
437 [
438 'label' => __( 'ID category', 'wpdirectorykit' ),
439 'type' => \Elementor\Controls_Manager::NUMBER,
440 'min' => 1,
441 'step' => 1,
442 ]
443 );
444 $repeater->end_controls_tabs();
445
446 $this->add_control(
447 'primary_conf_custom_results',
448 [
449 'type' => Controls_Manager::REPEATER,
450 'fields' => $repeater->get_controls(),
451 'default' => [
452 ],
453 'title_field' => '{{{ category_id }}}',
454 'conditions' => [
455 'terms' => [
456 [
457 'name' => 'primary_conf_results_type',
458 'operator' => '==',
459 'value' => 'custom_categories',
460 ]
461 ],
462 ],
463 ]
464 );
465 }
466
467 $this->end_controls_section();
468
469
470 $this->start_controls_section(
471 'tab_conf_secondary_section',
472 [
473 'label' => esc_html__('Bottom section Categories', 'wpdirectorykit'),
474 'tab' => '1',
475 ]
476 );
477
478 $this->add_control(
479 'secondary_categories_enable',
480 [
481 'label' => esc_html__( 'Show Bottom Categories', 'wpdirectorykit' ),
482 'type' => Controls_Manager::SWITCHER,
483 'none' => esc_html__( 'No', 'wpdirectorykit' ),
484 'block' => esc_html__( 'Yes', 'wpdirectorykit' ),
485 'return_value' => 'yes',
486 'default' => 'yes',
487 ]
488 );
489
490 $this->add_control(
491 'secondary_conf_results_type',
492 [
493 'label' => __( 'Show type', 'wpdirectorykit' ),
494 'type' => \Elementor\Controls_Manager::SELECT,
495 'default' => 'results_categories',
496 'options' => [
497 'results_categories' => __( 'All Categorys', 'wpdirectorykit' ),
498 'custom_categories' => __( 'Specific', 'wpdirectorykit' ),
499 ],
500 ]
501 );
502
503 $this->add_responsive_control (
504 'secondary_thumbnail_position',
505 [
506 'label' => __( 'Thumbnail/icon position', 'wpdirectorykit' ),
507 'type' => Controls_Manager::SELECT,
508 'options' => [
509 'right' => esc_html__('Rigth', 'wpdirectorykit'),
510 'left' => esc_html__('Left', 'wpdirectorykit'),
511 'top' => esc_html__('Top', 'wpdirectorykit'),
512 'bottom' => esc_html__('Bottom', 'wpdirectorykit'),
513 ],
514 'selectors_dictionary' => [
515 'right' => '',
516 'left' => 'flex-direction:row-reverse;text-align:right;',
517 'top' => 'flex-direction:column-reverse;text-align:center;',
518 'bottom' => 'flex-direction:column;text-align:center;',
519 ],
520 'selectors' => [
521 '{{WRAPPER}} .wdk-categories-tree-top .wdk-secondary .category-card' => '{{UNIT}}',
522 ],
523 'default' => 'top',
524 'separator' => 'after',
525 ]
526 );
527
528 $this->add_responsive_control(
529 'secondary_root_enable',
530 [
531 'label' => esc_html__( 'Show Main Categories', 'wpdirectorykit' ),
532 'type' => Controls_Manager::SWITCHER,
533 'none' => esc_html__( 'No', 'wpdirectorykit' ),
534 'block' => esc_html__( 'Yes', 'wpdirectorykit' ),
535 'return_value' => 'yes',
536 'default' => '',
537 'conditions' => [
538 'terms' => [
539 [
540 'name' => 'secondary_conf_results_type',
541 'operator' => '==',
542 'value' => 'results_categories',
543 ]
544 ],
545 ],
546 ]
547 );
548
549 $this->add_responsive_control(
550 'secondary_sub_enable',
551 [
552 'label' => esc_html__( 'Show Sub Categories', 'wpdirectorykit' ),
553 'type' => Controls_Manager::SWITCHER,
554 'none' => esc_html__( 'No', 'wpdirectorykit' ),
555 'block' => esc_html__( 'Yes', 'wpdirectorykit' ),
556 'return_value' => 'yes',
557 'default' => 'yes',
558 'conditions' => [
559 'terms' => [
560 [
561 'name' => 'secondary_conf_results_type',
562 'operator' => '==',
563 'value' => 'results_categories',
564 ]
565 ],
566 ],
567 ]
568 );
569
570 $this->add_control(
571 'secondary_layout_image_type',
572 [
573 'label' => __( 'Thumbnail Type', 'wpdirectorykit' ),
574 'type' => \Elementor\Controls_Manager::SELECT,
575 'default' => 'font_icon',
576 'options' => [
577 'icon' => __( 'Icon', 'wpdirectorykit' ),
578 'image' => __( 'Image', 'wpdirectorykit' ),
579 'font_icon' => __( 'Font Icon', 'wpdirectorykit' ),
580 ],
581 'separator' => 'before',
582 ]
583 );
584
585 $this->add_control(
586 'secondary_conf_offset',
587 [
588 'label' => __( 'Offset Categories', 'wpdirectorykit' ),
589 'type' => \Elementor\Controls_Manager::NUMBER,
590 'min' => 1,
591 'max' => 50,
592 'step' => 1,
593 'default' => 0,
594 'separator' => 'before',
595 'conditions' => [
596 'terms' => [
597 [
598 'name' => 'secondary_conf_results_type',
599 'operator' => '==',
600 'value' => 'results_categories',
601 ]
602 ],
603 ],
604 ]
605 );
606
607 $this->add_control(
608 'secondary_conf_limit',
609 [
610 'label' => __( 'Limit Categories', 'wpdirectorykit' ),
611 'description' => __( 'Set 0 for unlimit', 'wpdirectorykit' ),
612 'type' => \Elementor\Controls_Manager::NUMBER,
613 'min' => 0,
614 'max' => 500,
615 'step' => 1,
616 'default' => 16,
617 'separator' => 'after',
618 'conditions' => [
619 'terms' => [
620 [
621 'name' => 'secondary_conf_results_type',
622 'operator' => '==',
623 'value' => 'results_categories',
624 ]
625 ],
626 ],
627 ]
628 );
629
630 $this->add_control(
631 'secondary_conf_order_by',
632 [
633 'label' => __('Order By Column', 'wpdirectorykit'),
634 'type' => Controls_Manager::SELECT,
635 'label_block' => true,
636 'options' => [
637 '' => __('None', 'wpdirectorykit'),
638 'category_title' => __('Title', 'wpdirectorykit'),
639 'idcategory' => __('Category id', 'wpdirectorykit'),
640 'order_index' => __('Order index', 'wpdirectorykit'),
641 'listings_counter' => __('Most Listings', 'wpdirectorykit'),
642 'rand()' => __('Random', 'wpdirectorykit'),
643 ],
644 'default' => 'order_index',
645 'conditions' => [
646 'terms' => [
647 [
648 'name' => 'secondary_conf_results_type',
649 'operator' => '==',
650 'value' => 'results_categories',
651 ]
652 ],
653 ],
654 ]
655 );
656
657 $this->add_control(
658 'secondary_conf_order',
659 [
660 'label' => __('Order', 'wpdirectorykit'),
661 'type' => Controls_Manager::SELECT,
662 'label_block' => true,
663 'options' => [
664 'asc' => __('Ascending', 'wpdirectorykit'),
665 'desc' => __('Descending', 'wpdirectorykit')
666 ],
667 'default' => 'desc',
668 'conditions' => [
669 'terms' => [
670 [
671 'name' => 'secondary_conf_results_type',
672 'operator' => '==',
673 'value' => 'results_categories',
674 ]
675 ],
676 ],
677 ]
678 );
679
680 if(true){
681 $repeater = new Repeater();
682 $repeater->start_controls_tabs( 'categories' );
683 $repeater->add_control(
684 'category_id',
685 [
686 'label' => __( 'ID category', 'wpdirectorykit' ),
687 'type' => \Elementor\Controls_Manager::NUMBER,
688 'min' => 1,
689 'step' => 1,
690 ]
691 );
692 $repeater->end_controls_tabs();
693
694 $this->add_control(
695 'secondary_conf_custom_results',
696 [
697 'type' => Controls_Manager::REPEATER,
698 'fields' => $repeater->get_controls(),
699 'default' => [
700 ],
701 'title_field' => '{{{ category_id }}}',
702 'conditions' => [
703 'terms' => [
704 [
705 'name' => 'secondary_conf_results_type',
706 'operator' => '==',
707 'value' => 'custom_categories',
708 ]
709 ],
710 ],
711 ]
712 );
713 }
714
715 $this->end_controls_section();
716
717 }
718
719 private function generate_controls_layout() {
720 }
721
722 private function generate_controls_styles() {
723
724 $this->section_cards('wdk-primary');
725 $this->section_cards('wdk-secondary', '25%');
726 }
727
728 private function section_cards($prefix = '', $grid_default = 'calc(100% / 3)') {
729
730 $this->start_controls_section(
731 $prefix.'styles_primary_section',
732 [
733 'label' => esc_html__($prefix, 'wpdirectorykit'),
734 'tab' => Controls_Manager::TAB_STYLE,
735 ]
736 );
737
738 $this->add_responsive_control(
739 $prefix.'primary_row_gap_col',
740 [
741 'label' => __( 'Columns', 'wpdirectorykit' ),
742 'type' => Controls_Manager::SELECT,
743 'options' => [
744 '' => esc_html__('Default', 'wpdirectorykit'),
745 'auto' => esc_html__('Auto', 'wpdirectorykit'),
746 '100%' => '1',
747 '50%' => '2',
748 'calc(100% / 3)' => '3',
749 '25%' => '4',
750 '20%' => '5',
751 'auto_flexible' => 'auto flexible',
752 ],
753 'selectors_dictionary' => [
754 'auto' => '-webkit-flex:1 2 auto;flex:1 2 auto',
755 '100%' => '-webkit-flex:1 2 100%;flex:1 2 100%',
756 '50%' => '-webkit-flex:1 2 50%;flex:1 2 50%',
757 'calc(100% / 3)' => '-webkit-flex:1 2 calc(100% / 3);flex:1 2 calc(100% / 3)',
758 '25%' => '-webkit-flex:1 2 25%;flex:1 2 25%',
759 '20%' => '-webkit-flex:1 2 20%;flex:1 2 20%',
760 'auto' => '-webkit-flex:1 2 auto;flex:1 2 auto',
761 'auto_flexible' => '-webkit-flex:1 2 auto;flex:1 2 auto',
762 ],
763 'selectors' => [
764 '{{WRAPPER}} .'.$prefix.' .wdk-row .wdk-col' => '{{UNIT}}',
765 ],
766 'default' => $grid_default,
767 'separator' => 'before',
768 ]
769 );
770
771 $this->add_responsive_control(
772 $prefix.'primary_column_gap',
773 [
774 'label' => esc_html__('Columns Gap', 'wpdirectorykit'),
775 'type' => Controls_Manager::SLIDER,
776 'default' => [
777 'size' => 10,
778 ],
779 'range' => [
780 'px' => [
781 'min' => 0,
782 'max' => 60,
783 ],
784 ],
785 'selectors' => [
786 '{{WRAPPER}} .'.$prefix.' .wdk-row .wdk-col' => 'padding-left: {{SIZE}}{{UNIT}};padding-right: {{SIZE}}{{UNIT}};;',
787 '{{WRAPPER}} .'.$prefix.' .wdk-row' => 'margin-left: -{{SIZE}}{{UNIT}};margin-right: -{{SIZE}}{{UNIT}};',
788 ],
789 ]
790 );
791
792 $this->add_responsive_control(
793 $prefix.'primary_row_gap',
794 [
795 'label' => esc_html__('Rows Gap', 'wpdirectorykit'),
796 'type' => Controls_Manager::SLIDER,
797 'default' => [
798 'size' => 10,
799 ],
800 'range' => [
801 'px' => [
802 'min' => 0,
803 'max' => 60,
804 ],
805 ],
806 'selectors' => [
807 '{{WRAPPER}} .'.$prefix.' .wdk-row .wdk-col' => 'margin-bottom: {{SIZE}}{{UNIT}};',
808 '{{WRAPPER}} .'.$prefix.' .wdk-row' => 'margin-bottom: -{{SIZE}}{{UNIT}};',
809 ],
810 ]
811 );
812
813 $items = [
814 [
815 'key'=>$prefix.'card',
816 'label'=> esc_html__('Card', 'wpdirectorykit'),
817 'selectors'=> array(
818 'normal'=>'{{WRAPPER}} .'.$prefix.' .category-card',
819 'hover'=>'{{WRAPPER}} .'.$prefix.' .category-card%1$s',
820 ),
821 'options'=>['background','border','border_radius','padding','shadow','transition','padding', 'outline'],
822 ],
823 [
824 'key'=>$prefix.'title',
825 'label'=> esc_html__('Title', 'wpdirectorykit'),
826 'selectors'=> array(
827 'normal'=>'{{WRAPPER}} .'.$prefix.' .category-card .body .title',
828 'hover'=>'{{WRAPPER}} .'.$prefix.' .category-card%1$s .body .title',
829 ),
830 'options'=>['color','background','border','border_radius','padding','shadow','transition','margin','padding'],
831 ],
832 [
833 'key'=>$prefix.'sub',
834 'label'=> esc_html__('Subtitle (count)', 'wpdirectorykit'),
835 'selectors'=> array(
836 'normal'=>'{{WRAPPER}} .'.$prefix.' .category-card .body .sub',
837 'hover'=>'{{WRAPPER}} .'.$prefix.' .category-card%1$s .body .sub',
838 ),
839 'selector_hider'=>'{{WRAPPER}} .'.$prefix.' .category-card .body .sub',
840 'options'=>['color','background','border','border_radius','padding','shadow','transition','margin','padding'],
841 ],
842 [
843 'key'=>$prefix.'thumbnail',
844 'label'=> esc_html__('Thumbnail', 'wpdirectorykit'),
845 'selectors'=> array(
846 'normal'=>'{{WRAPPER}} .'.$prefix.' .category-card .thumbnail>*',
847 ),
848 'selector_hider'=>'{{WRAPPER}} .'.$prefix.' .category-card .thumbnail',
849 'options'=>['border','border_radius','padding','shadow','transition','image_size_control','image_fit_control','font-size','css_filters'],
850 ],
851 ];
852
853 foreach ($items as $item) {
854 $this->add_control(
855 $item['key'].'_section',
856 [
857 'label' => $item['label'],
858 'type' => \Elementor\Controls_Manager::HEADING,
859 ]
860 );
861
862 if(isset($item['selector_hidder'])) {
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 $item['selector_hidder'] => 'display: {{VALUE}};',
874 ],
875 ]
876 );
877 }
878
879 $selectors = array();
880 if(isset($item['selectors'])) {
881 $selectors = $item['selectors'];
882 }
883
884 $this->generate_renders_tabs($selectors, $item['key'].'_dynamic', $item['options']);
885
886 $this->add_control(
887 $item['key'].'_hr',
888 [
889 'type' => \Elementor\Controls_Manager::DIVIDER,
890 ]
891 );
892
893 }
894
895 $this->end_controls_section();
896 }
897
898 private function generate_controls_content() {
899
900 }
901
902 public function enqueue_styles_scripts() {
903 wp_enqueue_style('wdk-categories-tree-top');
904 }
905 }
906