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-categories-tree-top.php

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

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