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

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

563 lines 20.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 WdkCategoriesTree 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';
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', '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 = 'category';
124 $this->WMVC->model($controller.'_m');
125 $this->WMVC->model('listing_m');
126 $this->WMVC->model('category_m');
127
128 $this->data['results'] = array();
129
130 $this->data['categories'] = $this->WMVC->category_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-categories-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 Category 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' => 'font_icon',
185 'options' => [
186 'icon' => __( 'Icon', 'wpdirectorykit' ),
187 'image' => __( 'Image', 'wpdirectorykit' ),
188 'font_icon' => __( 'Font Icon', 'wpdirectorykit' ),
189 ],
190 'conditions' => [
191 'terms' => [
192 [
193 'name' => 'show_icon',
194 'operator' => '==',
195 'value' => 'yes',
196 ]
197 ],
198 ],
199 ]
200 );
201
202 $this->add_control(
203 'important_note',
204 [
205 'label' => '',
206 'type' => \Elementor\Controls_Manager::RAW_HTML,
207 'raw' => sprintf(__( 'Manage Categories <a href="%1$s" target="_blank"> open </a>', 'wpdirectorykit' ), admin_url('admin.php?page=wdk_category')),
208 'content_classes' => 'wdk_elementor_hint',
209 ]
210 );
211
212 $this->add_responsive_control(
213 'row_gap_col',
214 [
215 'label' => __( 'Columns', 'wpdirectorykit' ),
216 'type' => Controls_Manager::SELECT,
217 'options' => [
218 '' => esc_html__('Default', 'wpdirectorykit'),
219 'auto' => esc_html__('Auto', 'wpdirectorykit'),
220 '100%' => '1',
221 '50%' => '2',
222 'calc(100% / 3)' => '3',
223 '25%' => '4',
224 '20%' => '5',
225 'auto_flexible' => 'auto flexible',
226 ],
227 'selectors_dictionary' => [
228 'auto' => '-webkit-flex:0 0 auto;flex:0 0 auto',
229 '100%' => '-webkit-flex:0 0 100%;flex:0 0 100%',
230 '50%' => '-webkit-flex:0 0 50%;flex:0 0 50%',
231 'calc(100% / 3)' => '-webkit-flex:0 0 calc(100% / 3);flex:0 0 calc(100% / 3)',
232 '25%' => '-webkit-flex:0 0 25%;flex:0 0 25%',
233 '20%' => '-webkit-flex:0 0 20%;flex:0 0 20%',
234 'auto' => '-webkit-flex:0 0 auto;flex:0 0 auto',
235 'auto_flexible' => '-webkit-flex:0 0 auto;flex:0 0 auto',
236 ],
237 'selectors' => [
238 '{{WRAPPER}} .wdk-row .wdk-col' => '{{UNIT}}',
239 ],
240 'default' => 'calc(100% / 3)',
241 'separator' => 'before',
242 ]
243 );
244
245 $this->add_responsive_control(
246 'column_gap',
247 [
248 'label' => esc_html__('Columns Gap', 'wpdirectorykit'),
249 'type' => Controls_Manager::SLIDER,
250 'default' => [
251 'size' => 10,
252 ],
253 'range' => [
254 'px' => [
255 'min' => 0,
256 'max' => 60,
257 ],
258 ],
259 'selectors' => [
260 '{{WRAPPER}} .wdk-row .wdk-col' => 'padding-left: {{SIZE}}{{UNIT}};padding-right: {{SIZE}}{{UNIT}};;',
261 '{{WRAPPER}} .wdk-row' => 'margin-left: -{{SIZE}}{{UNIT}};margin-right: -{{SIZE}}{{UNIT}};',
262 ],
263 ]
264 );
265
266 $this->add_responsive_control(
267 'row_gap',
268 [
269 'label' => esc_html__('Rows Gap', 'wpdirectorykit'),
270 'type' => Controls_Manager::SLIDER,
271 'default' => [
272 'size' => 10,
273 ],
274 'range' => [
275 'px' => [
276 'min' => 0,
277 'max' => 60,
278 ],
279 ],
280 'selectors' => [
281 '{{WRAPPER}} .wdk-row .wdk-col' => 'margin-bottom: {{SIZE}}{{UNIT}};',
282 '{{WRAPPER}} .wdk-row' => 'margin-bottom: -{{SIZE}}{{UNIT}};',
283 ],
284 ]
285 );
286
287 $this->end_controls_section();
288 }
289
290 private function generate_controls_layout() {
291 }
292
293 private function generate_controls_styles() {
294 $this->start_controls_section(
295 'sstyles_thmbn_section',
296 [
297 'label' => esc_html__('Main', 'wpdirectorykit'),
298 'tab' => Controls_Manager::TAB_STYLE,
299 ]
300 );
301
302 $this->add_responsive_control(
303 'list_gap',
304 [
305 'label' => esc_html__('Rows Gap', 'wpdirectorykit'),
306 'type' => Controls_Manager::SLIDER,
307 'default' => [
308 'size' => 10,
309 ],
310 'range' => [
311 'px' => [
312 'min' => 0,
313 'max' => 60,
314 ],
315 ],
316 'selectors' => [
317 '{{WRAPPER}} .wdk-categories .wdk-item' => 'margin-bottom: {{SIZE}}{{UNIT}};',
318 ],
319 ]
320 );
321
322 $this->end_controls_section();
323
324 $items = [
325 [
326 'key'=>'title',
327 'label'=> esc_html__('Title', 'wpdirectorykit'),
328 'selector'=>'.title',
329 'selector_hover'=>'.title%1$s',
330 'options'=>['color','background','border','border_radius','padding','shadow','transition','margin','padding'],
331 ],
332 [
333 'key'=>'item_button',
334 'label'=> esc_html__('Item Box', 'wpdirectorykit'),
335 'selector'=>'.wdk-categories .wdk-link',
336 'selector_hover'=>'.wdk-categories .wdk-link%1$s',
337 'options'=>['color','background','border','border_radius','padding','shadow','transition'],
338 ],
339 [
340 'key'=>'item_icon',
341 'label'=> esc_html__('Item Icon', 'wpdirectorykit'),
342 'selector'=>'.wdk-categories .wdk-link i',
343 'selector_hover'=>'.wdk-categories .wdk-link%1$s i',
344 'options'=>['margin','color','background','border','border_radius','padding','shadow'],
345 ],
346 [
347 'key'=>'category_icon',
348 'label'=> esc_html__('Category Icon', 'wpdirectorykit'),
349 'selector'=>'.title .wdk-icon',
350 'selector_hover'=>'.title%1$s .wdk-icon',
351 'options'=>['margin','color','background','border','border_radius','padding','shadow','image_size_control','image_fit_control'],
352 ],
353 [
354 'key'=>'category_image',
355 'label'=> esc_html__('Category Image', 'wpdirectorykit'),
356 'selector'=>'.title .wdk-image',
357 'selector_hover'=>'.title%1$s .wdk-image',
358 'options'=>['margin','background','border','border_radius','padding','shadow','transition','image_size_control', 'css_filters','image_fit_control'],
359 ],
360 [
361 'key'=>'category_font_icon',
362 'label'=> esc_html__('Category Font Icon', 'wpdirectorykit'),
363 'selector'=>'.title .wdk-font-icon',
364 'selector_hover'=>'.title%1$s .wdk-font-icon',
365 'options'=>['margin','background','border','border_radius','shadow','color','font-size','height','width'],
366 ],
367 [
368 'key'=>'item_title',
369 'label'=> esc_html__('Item Title', 'wpdirectorykit'),
370 'selector'=>'.wdk-categories .wdk-link .wdk-title',
371 'selector_hover'=>'.wdk-categories .wdk-link%1$s .wdk-title',
372 'options'=>['margin','typo','color','background','border','border_radius','padding'],
373 ],
374 [
375 'key'=>'item_count',
376 'label'=> esc_html__('Item Count', 'wpdirectorykit'),
377 'selector'=>'.wdk-categories .wdk-link .wdk-count',
378 'selector_hover'=>'.wdk-categories .wdk-link%1$s .wdk-count',
379 'options'=>['margin','typo','color','background','border','border_radius','padding'],
380 ],
381 ];
382
383 foreach ($items as $item) {
384 if($item['key'] == 'category_icon') {
385 $this->start_controls_section(
386 $item['key'].'_section',
387 [
388 'label' => $item['label'],
389 'tab' => Controls_Manager::TAB_STYLE,
390 'conditions' => [
391 'terms' => [
392 [
393 'name' => 'show_icon',
394 'operator' => '==',
395 'value' => 'yes',
396 ],
397 [
398 'name' => 'layout_image_type',
399 'operator' => '==',
400 'value' => 'icon',
401 ]
402 ],
403 ],
404 ]
405 );
406 } elseif($item['key'] == 'category_image') {
407 $this->start_controls_section(
408 $item['key'].'_section',
409 [
410 'label' => $item['label'],
411 'tab' => Controls_Manager::TAB_STYLE,
412 'conditions' => [
413 'terms' => [
414 [
415 'name' => 'show_icon',
416 'operator' => '==',
417 'value' => 'yes',
418 ],
419 [
420 'name' => 'layout_image_type',
421 'operator' => '==',
422 'value' => 'image',
423 ]
424 ],
425 ],
426 ]
427 );
428 } elseif($item['key'] == 'category_font_icon') {
429 $this->start_controls_section(
430 $item['key'].'_section',
431 [
432 'label' => $item['label'],
433 'tab' => Controls_Manager::TAB_STYLE,
434 'conditions' => [
435 'terms' => [
436 [
437 'name' => 'show_icon',
438 'operator' => '==',
439 'value' => 'yes',
440 ],
441 [
442 'name' => 'layout_image_type',
443 'operator' => '==',
444 'value' => 'font_icon',
445 ]
446 ],
447 ],
448 ]
449 );
450 } else {
451 $this->start_controls_section(
452 $item['key'].'_section',
453 [
454 'label' => $item['label'],
455 'tab' => Controls_Manager::TAB_STYLE,
456 ]
457 );
458 }
459
460 $this->add_responsive_control(
461 $item['key'].'_hide',
462 [
463 'label' => esc_html__( 'Hide Element', 'wpdirectorykit' ),
464 'type' => Controls_Manager::SWITCHER,
465 'none' => esc_html__( 'Hide', 'wpdirectorykit' ),
466 'block' => esc_html__( 'Show', 'wpdirectorykit' ),
467 'return_value' => 'none',
468 'default' => '',
469 'selectors' => [
470 '{{WRAPPER}} '.$item['selector'] => 'display: {{VALUE}};',
471 ],
472 ]
473 );
474 $selectors = array(
475 'normal' => '{{WRAPPER}} '.$item['selector'],
476 'hover'=>'{{WRAPPER}} '.$item['selector_hover'],
477 );
478 $this->generate_renders_tabs($selectors, $item['key'].'_dynamic', $item['options']);
479
480 /* special for some elements */
481 if($item['key'] == 'item_icon') {
482 $this->add_control(
483 $item['key'].'_i',
484 [
485 'label' => esc_html__('Icon', 'wpdirectorykit'),
486 'type' => Controls_Manager::ICONS,
487 'label_block' => true,
488 'default' => [
489 'value' => 'fa fa-angle-right',
490 'library' => 'solid',
491 ],
492 ]
493 );
494 $this->add_responsive_control(
495 $item['key'].'_size',
496 [
497 'label' => __( 'Size', 'wpdirectorykit' ),
498 'type' => Controls_Manager::SLIDER,
499 'size_units' => [ 'px'],
500 'range' => [
501 'px' => [
502 'min' => 1,
503 'max' => 60,
504 'step' => 1,
505 ],
506 ],
507 'default' => [
508 'unit' => 'px',
509 'size' => 14,
510 ],
511 'selectors' => [
512 '{{WRAPPER}} '.$item['selector'] => 'font-size: {{SIZE}}{{UNIT}};',
513 ],
514 ]
515 );
516 }
517 if($item['key'] == 'item_count') {
518 $this->add_responsive_control(
519 $item['key'].'_align',
520 [
521 'label' => __( 'Position', 'wpdirectorykit' ),
522 'type' => Controls_Manager::CHOOSE,
523 'options' => [
524 'left' => [
525 'title' => esc_html__( 'Left', 'wpdirectorykit' ),
526 'icon' => 'eicon-text-align-left',
527 ],
528 'center' => [
529 'title' => esc_html__( 'Center', 'wpdirectorykit' ),
530 'icon' => 'eicon-text-align-center',
531 ],
532 'right' => [
533 'title' => esc_html__( 'Right', 'wpdirectorykit' ),
534 'icon' => 'eicon-text-align-right',
535 ],
536
537 ],
538 'render_type' => 'ui',
539 'selectors_dictionary' => [
540 'left' => 'text-align: left;',
541 'center' => 'text-alig: center;',
542 'right' => 'text-align: right;',
543 ],
544 'selectors' => [
545 '{{WRAPPER}} '.$item['selector'] => '{{VALUE}};',
546 ],
547 ]
548 );
549 }
550
551 $this->end_controls_section();
552 }
553 }
554
555 private function generate_controls_content() {
556
557 }
558
559 public function enqueue_styles_scripts() {
560 wp_enqueue_style('wdk-categories-tree');
561 }
562 }
563