PluginProbe
King Addons for Elementor – 80+ Elementor Widgets, 4 000+ Elementor Templates, WooCommerce, Mega Menu, Popup Builder / 51.1.36
King Addons for Elementor – 80+ Elementor Widgets, 4 000+ Elementor Templates, WooCommerce, Mega Menu, Popup Builder v51.1.36
51.1.83 51.1.82 51.1.81 51.1.79 51.1.78 51.1.77 51.1.76 51.1.74 51.1.75 51.1.65 51.1.64 51.1.63 trunk 51.1.14 51.1.2 51.1.35 51.1.36 51.1.37 51.1.38 51.1.39 51.1.44 51.1.45 51.1.46 51.1.47 51.1.49 All 37 releases
king-addons / includes / widgets / Dynamic_Posts_Grid / Dynamic_Posts_Grid.php

Dynamic_Posts_Grid.php in King Addons for Elementor – 80+ Elementor Widgets, 4 000+ Elementor Templates, WooCommerce, Mega Menu, Popup Builder 51.1.36, at includes/widgets/Dynamic_Posts_Grid/Dynamic_Posts_Grid.php

4,513 lines 166.6 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 /** @noinspection SpellCheckingInspection, DuplicatedCode, PhpUnused */
4
5 namespace King_Addons;
6
7 use Elementor\Controls_Manager;
8 use Elementor\Group_Control_Background;
9 use Elementor\Group_Control_Border;
10 use Elementor\Group_Control_Box_Shadow;
11 use Elementor\Group_Control_Typography;
12 use Elementor\Widget_Base;
13
14 if (!defined('ABSPATH')) {
15 exit; // Exit if accessed directly.
16 }
17
18 /**
19 * Dynamic Posts Grid Widget
20 *
21 * Creates a dynamic grid of posts with AJAX filtering, search, and load more functionality.
22 * Features different post types, color coding, and responsive design.
23 */
24 class Dynamic_Posts_Grid extends Widget_Base
25 {
26
27 /**
28 * Get widget name.
29 *
30 * @return string Widget name.
31 */
32 public function get_name(): string
33 {
34 return 'king-addons-dynamic-posts-grid';
35 }
36
37 /**
38 * Get widget title.
39 *
40 * @return string Widget title.
41 */
42 public function get_title(): string
43 {
44 return esc_html__('Dynamic Posts Grid', 'king-addons');
45 }
46
47 /**
48 * Get widget icon.
49 *
50 * @return string Widget icon.
51 */
52 public function get_icon(): string
53 {
54 return 'king-addons-icon king-addons-dynamic-posts-grid';
55 }
56
57 /**
58 * Get widget style dependencies.
59 *
60 * @return array Style dependencies.
61 */
62 public function get_style_depends(): array
63 {
64 return [KING_ADDONS_ASSETS_UNIQUE_KEY . '-dynamic-posts-grid-style'];
65 }
66
67 /**
68 * Get widget script dependencies.
69 *
70 * @return array Script dependencies.
71 */
72 public function get_script_depends(): array
73 {
74 return [KING_ADDONS_ASSETS_UNIQUE_KEY . '-dynamic-posts-grid-script'];
75 }
76
77 /**
78 * Get widget categories.
79 *
80 * @return array Widget categories.
81 */
82 public function get_categories(): array
83 {
84 return ['king-addons'];
85 }
86
87 /**
88 * Get widget keywords.
89 *
90 * @return array Widget keywords.
91 */
92 public function get_keywords(): array
93 {
94 return [
95 'posts',
96 'grid',
97 'dynamic',
98 'ajax',
99 'filter',
100 'search',
101 'load more',
102 'pagination',
103 'isotope',
104 'masonry',
105 'blog',
106 'news',
107 'articles',
108 'content',
109 'king',
110 'addons',
111 'kingaddons',
112 'king-addons'
113 ];
114 }
115
116 /**
117 * Get widget help URL.
118 *
119 * @return string Help URL.
120 */
121 public function get_custom_help_url()
122 {
123 return 'mailto:bug@kingaddons.com?subject=Bug Report - King Addons&body=Please describe the issue';
124 }
125
126 /**
127 * Register widget controls.
128 */
129 protected function register_controls(): void
130 {
131 // START TAB: CONTENT
132 $this->register_content_controls();
133
134 // START TAB: STYLE
135 $this->register_style_controls();
136 }
137
138 /**
139 * Register content controls.
140 */
141 private function register_content_controls(): void
142 {
143 // Content Section
144 $this->start_controls_section(
145 'kng_dynamic_posts_grid_content_section',
146 [
147 'label' => KING_ADDONS_ELEMENTOR_ICON . esc_html__('Content', 'king-addons'),
148 'tab' => Controls_Manager::TAB_CONTENT,
149 ]
150 );
151
152 // Editor notice
153 $this->add_control(
154 'kng_dynamic_posts_editor_notice',
155 [
156 'type' => Controls_Manager::RAW_HTML,
157 'raw' => '<div style="background: #e3f2fd; border: 1px solid #2196f3; border-radius: 4px; padding: 12px; margin-bottom: 15px; color: #1565c0;">
158 <div style="display: flex; align-items: center; gap: 8px; margin-bottom: 8px;">
159 <i class="eicon-info-circle" style="color: #2196f3;"></i>
160 <strong>' . esc_html__('Editor Notice', 'king-addons') . '</strong>
161 </div>
162 <p style="margin: 0; font-size: 13px; line-height: 1.4;">' .
163 esc_html__('Dynamic features (filtering, search, load more) work only on the live site and will not function in the Elementor editor preview.', 'king-addons') .
164 '</p>
165 </div>',
166 ]
167 );
168
169 // PRO: Widget Mode Control
170 $this->add_control_widget_mode();
171
172 // Post Types (shown only in Default mode)
173 $this->add_control(
174 'kng_dynamic_posts_post_types',
175 [
176 'label' => esc_html__('Post Types', 'king-addons'),
177 'type' => Controls_Manager::SELECT2,
178 'multiple' => true,
179 'options' => $this->get_post_types(),
180 'default' => ['post'],
181 'description' => esc_html__('Select post types to display', 'king-addons'),
182 'condition' => [
183 'kng_dynamic_posts_widget_mode' => ['', 'default'],
184 ],
185 ]
186 );
187
188 // PRO: Custom Post Types Control
189 $this->add_control_custom_post_types();
190
191 // Posts per page
192 $this->add_control(
193 'kng_dynamic_posts_per_page',
194 [
195 'label' => esc_html__('Posts Per Page', 'king-addons'),
196 'type' => Controls_Manager::NUMBER,
197 'min' => 1,
198 'max' => 100,
199 'step' => 1,
200 'default' => 12,
201 'description' => esc_html__('Number of posts to display initially', 'king-addons'),
202 ]
203 );
204
205 // Order by
206 $this->add_control(
207 'kng_dynamic_posts_orderby',
208 [
209 'label' => esc_html__('Order By', 'king-addons'),
210 'type' => Controls_Manager::SELECT,
211 'options' => [
212 'date' => esc_html__('Date', 'king-addons'),
213 'title' => esc_html__('Title', 'king-addons'),
214 'menu_order' => esc_html__('Menu Order', 'king-addons'),
215 'rand' => esc_html__('Random', 'king-addons'),
216 'comment_count' => esc_html__('Comment Count', 'king-addons'),
217 ],
218 'default' => 'date',
219 ]
220 );
221
222 // Order
223 $this->add_control(
224 'kng_dynamic_posts_order',
225 [
226 'label' => esc_html__('Order', 'king-addons'),
227 'type' => Controls_Manager::SELECT,
228 'options' => [
229 'DESC' => esc_html__('Descending', 'king-addons'),
230 'ASC' => esc_html__('Ascending', 'king-addons'),
231 ],
232 'default' => 'DESC',
233 'condition' => [
234 'kng_dynamic_posts_orderby!' => 'rand',
235 ],
236 ]
237 );
238
239 $this->end_controls_section();
240
241 // Filtering Section
242 $this->start_controls_section(
243 'kng_dynamic_posts_filtering_section',
244 [
245 'label' => KING_ADDONS_ELEMENTOR_ICON . esc_html__('Filtering & Search', 'king-addons'),
246 'tab' => Controls_Manager::TAB_CONTENT,
247 ]
248 );
249
250 // Enable filters
251 $this->add_control(
252 'kng_dynamic_posts_enable_filters',
253 [
254 'label' => esc_html__('Enable Filters', 'king-addons'),
255 'type' => Controls_Manager::SWITCHER,
256 'label_on' => esc_html__('Yes', 'king-addons'),
257 'label_off' => esc_html__('No', 'king-addons'),
258 'return_value' => 'yes',
259 'default' => 'yes',
260 ]
261 );
262
263 // Filter title text
264 $this->add_control(
265 'kng_dynamic_posts_filter_title_text',
266 [
267 'label' => esc_html__('Filter Title Text', 'king-addons'),
268 'type' => Controls_Manager::TEXT,
269 'default' => esc_html__('Filter', 'king-addons'),
270 'placeholder' => esc_html__('Enter filter title', 'king-addons'),
271 'condition' => [
272 'kng_dynamic_posts_enable_filters' => 'yes',
273 ],
274 ]
275 );
276
277 // Filter taxonomy (shown only in Default mode)
278 $this->add_control(
279 'kng_dynamic_posts_filter_taxonomy',
280 [
281 'label' => esc_html__('Filter Taxonomy', 'king-addons'),
282 'type' => Controls_Manager::SELECT,
283 'options' => $this->get_taxonomies(),
284 'default' => 'category',
285 'condition' => [
286 'kng_dynamic_posts_enable_filters' => 'yes',
287 'kng_dynamic_posts_widget_mode' => ['', 'default'],
288 ],
289 ]
290 );
291
292 // Enable search
293 $this->add_control(
294 'kng_dynamic_posts_enable_search',
295 [
296 'label' => esc_html__('Enable Search', 'king-addons'),
297 'type' => Controls_Manager::SWITCHER,
298 'label_on' => esc_html__('Yes', 'king-addons'),
299 'label_off' => esc_html__('No', 'king-addons'),
300 'return_value' => 'yes',
301 'default' => 'yes',
302 ]
303 );
304
305 // Search placeholder
306 $this->add_control(
307 'kng_dynamic_posts_search_placeholder',
308 [
309 'label' => esc_html__('Search Placeholder', 'king-addons'),
310 'type' => Controls_Manager::TEXT,
311 'default' => esc_html__('Search by keyword', 'king-addons'),
312 'condition' => [
313 'kng_dynamic_posts_enable_search' => 'yes',
314 ],
315 ]
316 );
317
318 $this->end_controls_section();
319
320 // Grid Layout Section
321 $this->start_controls_section(
322 'kng_dynamic_posts_layout_section',
323 [
324 'label' => KING_ADDONS_ELEMENTOR_ICON . esc_html__('Grid Layout', 'king-addons'),
325 'tab' => Controls_Manager::TAB_CONTENT,
326 ]
327 );
328
329 // Columns
330 $this->add_responsive_control(
331 'kng_dynamic_posts_columns',
332 [
333 'label' => esc_html__('Columns', 'king-addons'),
334 'type' => Controls_Manager::SELECT,
335 'default' => '3',
336 'tablet_default' => '2',
337 'mobile_default' => '1',
338 'options' => [
339 '1' => '1',
340 '2' => '2',
341 '3' => '3',
342 '4' => '4',
343 '5' => '5',
344 '6' => '6',
345 ],
346 'selectors' => [
347 '{{WRAPPER}} .king-addons-dpg-grid' => 'grid-template-columns: repeat({{VALUE}}, 1fr);',
348 ],
349 ]
350 );
351
352 // Grid gap
353 $this->add_responsive_control(
354 'kng_dynamic_posts_grid_gap',
355 [
356 'label' => esc_html__('Grid Gap', 'king-addons'),
357 'type' => Controls_Manager::SLIDER,
358 'size_units' => ['px', 'em', 'rem'],
359 'range' => [
360 'px' => [
361 'min' => 0,
362 'max' => 100,
363 ],
364 ],
365 'default' => [
366 'size' => 20,
367 'unit' => 'px',
368 ],
369 'selectors' => [
370 '{{WRAPPER}} .king-addons-dpg-grid' => 'gap: {{SIZE}}{{UNIT}};',
371 ],
372 ]
373 );
374
375 $this->end_controls_section();
376
377 // Grid Spacing
378 $this->start_controls_section(
379 'kng_dynamic_posts_grid_spacing_section',
380 [
381 'label' => KING_ADDONS_ELEMENTOR_ICON . esc_html__('Grid Spacing', 'king-addons'),
382 'tab' => Controls_Manager::TAB_CONTENT,
383 ]
384 );
385
386 // Grid margin bottom
387 $this->add_responsive_control(
388 'kng_dynamic_posts_grid_margin_bottom',
389 [
390 'label' => esc_html__('Grid Bottom Margin', 'king-addons'),
391 'type' => Controls_Manager::SLIDER,
392 'size_units' => ['px', 'em', 'rem'],
393 'range' => [
394 'px' => [
395 'min' => 0,
396 'max' => 100,
397 ],
398 ],
399 'default' => [
400 'size' => 50,
401 'unit' => 'px',
402 ],
403 'selectors' => [
404 '{{WRAPPER}} .king-addons-dpg-grid' => 'margin-bottom: {{SIZE}}{{UNIT}};',
405 ],
406 ]
407 );
408
409 $this->end_controls_section();
410
411 // Load More Section
412 $this->start_controls_section(
413 'kng_dynamic_posts_load_more_section',
414 [
415 'label' => KING_ADDONS_ELEMENTOR_ICON . esc_html__('Load More', 'king-addons'),
416 'tab' => Controls_Manager::TAB_CONTENT,
417 ]
418 );
419
420 // Enable load more
421 $this->add_control(
422 'kng_dynamic_posts_enable_load_more',
423 [
424 'label' => esc_html__('Enable Load More', 'king-addons'),
425 'type' => Controls_Manager::SWITCHER,
426 'label_on' => esc_html__('Yes', 'king-addons'),
427 'label_off' => esc_html__('No', 'king-addons'),
428 'return_value' => 'yes',
429 'default' => 'yes',
430 ]
431 );
432
433 // Load more text
434 $this->add_control(
435 'kng_dynamic_posts_load_more_text',
436 [
437 'label' => esc_html__('Load More Text', 'king-addons'),
438 'type' => Controls_Manager::TEXT,
439 'default' => esc_html__('LOAD MORE', 'king-addons'),
440 'condition' => [
441 'kng_dynamic_posts_enable_load_more' => 'yes',
442 ],
443 ]
444 );
445
446 // Loading text
447 $this->add_control(
448 'kng_dynamic_posts_loading_text',
449 [
450 'label' => esc_html__('Loading Text', 'king-addons'),
451 'type' => Controls_Manager::TEXT,
452 'default' => esc_html__('Loading...', 'king-addons'),
453 'condition' => [
454 'kng_dynamic_posts_enable_load_more' => 'yes',
455 ],
456 ]
457 );
458
459 // PRO: Pagination Type Control
460 $this->add_control_pagination_type();
461
462 // PRO: Scroll Threshold Control
463 $this->add_control_scroll_threshold();
464
465 $this->end_controls_section();
466
467 // PRO: CPT Actions Section
468 $this->start_controls_section(
469 'kng_dynamic_posts_cpt_actions_section',
470 [
471 'label' => KING_ADDONS_ELEMENTOR_ICON . esc_html__('CPT Action Types', 'king-addons') . ' ' . esc_html__('(PRO)', 'king-addons'),
472 'tab' => Controls_Manager::TAB_CONTENT,
473 'condition' => [
474 'kng_dynamic_posts_widget_mode' => 'custom_cpt',
475 ],
476 ]
477 );
478
479 // PRO: CPT Actions Control
480 $this->add_control_cpt_actions();
481
482 $this->end_controls_section();
483
484 // PRO: Meta Fields Section
485 $this->start_controls_section(
486 'kng_dynamic_posts_meta_fields_section',
487 [
488 'label' => KING_ADDONS_ELEMENTOR_ICON . esc_html__('Meta Fields', 'king-addons') . ' ' . esc_html__('(PRO)', 'king-addons'),
489 'tab' => Controls_Manager::TAB_CONTENT,
490 ]
491 );
492
493 // PRO: Show Meta Control
494 $this->add_control_show_meta();
495
496 // PRO: Meta Fields Control
497 $this->add_control_meta_fields();
498
499 $this->end_controls_section();
500
501 // Category Colors Section
502 $this->start_controls_section(
503 'kng_dynamic_posts_category_colors_section',
504 [
505 'label' => KING_ADDONS_ELEMENTOR_ICON . esc_html__('Category Colors', 'king-addons'),
506 'tab' => Controls_Manager::TAB_CONTENT,
507 'condition' => [
508 'kng_dynamic_posts_widget_mode' => ['', 'default']
509 ]
510 ]
511 );
512
513 // Get categories dynamically
514 $this->add_dynamic_category_colors();
515
516 $this->end_controls_section();
517
518 // CPT Colors Section (PRO)
519 $this->start_controls_section(
520 'kng_dynamic_posts_cpt_colors_section',
521 [
522 'label' => KING_ADDONS_ELEMENTOR_ICON . esc_html__('CPT Colors', 'king-addons'),
523 'tab' => Controls_Manager::TAB_CONTENT,
524 'condition' => [
525 'kng_dynamic_posts_widget_mode' => 'custom_cpt'
526 ]
527 ]
528 );
529
530 // PRO: CPT Colors
531 $this->add_control_cpt_colors();
532
533 $this->end_controls_section();
534
535 $this->start_controls_section(
536 'kng_dynamic_posts_category_button_colors_section',
537 [
538 'label' => KING_ADDONS_ELEMENTOR_ICON . esc_html__('Category Button Colors', 'king-addons'),
539 'tab' => Controls_Manager::TAB_CONTENT,
540 'condition' => [
541 'kng_dynamic_posts_widget_mode' => ['', 'default']
542 ]
543 ]
544 );
545
546 // Dynamic category button colors
547 $this->add_dynamic_category_button_colors();
548
549 $this->end_controls_section();
550
551 // CPT Button Colors Section (PRO)
552 $this->start_controls_section(
553 'kng_dynamic_posts_cpt_button_colors_section',
554 [
555 'label' => KING_ADDONS_ELEMENTOR_ICON . esc_html__('CPT Button Colors', 'king-addons'),
556 'tab' => Controls_Manager::TAB_CONTENT,
557 'condition' => [
558 'kng_dynamic_posts_widget_mode' => 'custom_cpt'
559 ]
560 ]
561 );
562
563 // PRO: CPT Button Colors
564 $this->add_control_cpt_button_colors();
565
566 $this->end_controls_section();
567
568
569
570 // Category CTAs Section
571 $this->start_controls_section(
572 'kng_dynamic_posts_ctas_section',
573 [
574 'label' => KING_ADDONS_ELEMENTOR_ICON . esc_html__('Category Button Text', 'king-addons'),
575 'tab' => Controls_Manager::TAB_CONTENT,
576 'condition' => [
577 'kng_dynamic_posts_widget_mode' => ['', 'default']
578 ]
579 ]
580 );
581
582 // Get categories dynamically
583 $this->add_dynamic_category_ctas();
584
585 $this->end_controls_section();
586
587 // CPT Button Text Section (PRO)
588 $this->start_controls_section(
589 'kng_dynamic_posts_cpt_ctas_section',
590 [
591 'label' => KING_ADDONS_ELEMENTOR_ICON . esc_html__('CPT Button Text', 'king-addons'),
592 'tab' => Controls_Manager::TAB_CONTENT,
593 'condition' => [
594 'kng_dynamic_posts_widget_mode' => 'custom_cpt'
595 ]
596 ]
597 );
598
599 // PRO: CPT Button Text
600 $this->add_control_cpt_ctas();
601
602 $this->end_controls_section();
603
604 // Category Icons Section
605 $this->start_controls_section(
606 'kng_dynamic_posts_icons_section',
607 [
608 'label' => KING_ADDONS_ELEMENTOR_ICON . esc_html__('Category Icons', 'king-addons'),
609 'tab' => Controls_Manager::TAB_CONTENT,
610 'condition' => [
611 'kng_dynamic_posts_widget_mode' => ['', 'default']
612 ]
613 ]
614 );
615
616 // Get categories dynamically
617 $this->add_dynamic_category_icons();
618
619 $this->end_controls_section();
620
621 // CPT Icons Section (PRO)
622 $this->start_controls_section(
623 'kng_dynamic_posts_cpt_icons_section',
624 [
625 'label' => KING_ADDONS_ELEMENTOR_ICON . esc_html__('CPT Icons', 'king-addons'),
626 'tab' => Controls_Manager::TAB_CONTENT,
627 'condition' => [
628 'kng_dynamic_posts_widget_mode' => 'custom_cpt'
629 ]
630 ]
631 );
632
633 // PRO: CPT Icons
634 $this->add_control_cpt_icons();
635
636 $this->end_controls_section();
637
638 // Pro Features Section
639 if (!king_addons_freemius()->can_use_premium_code__premium_only()) {
640 Core::renderProFeaturesSection($this, '', Controls_Manager::RAW_HTML, 'dynamic-posts-grid', [
641 'Advanced Query Builder',
642 'Custom Meta Fields Display',
643 'Advanced Filtering Options',
644 'Infinite Scroll',
645 'Custom Post Type Support',
646 'Advanced Search with Meta Fields',
647 'Custom Date Range Filters',
648 'Author-based Filtering'
649 ]);
650 }
651
652 // PRO extension point to append content controls without duplicating base controls
653 // Pro content controls are added via add_control_* method calls above
654 }
655
656 /**
657 * Register style controls.
658 */
659 private function register_style_controls(): void
660 {
661 // Filter Title Style
662 $this->start_controls_section(
663 'kng_dynamic_posts_filter_title_style_section',
664 [
665 'label' => KING_ADDONS_ELEMENTOR_ICON . esc_html__('Filter Title', 'king-addons'),
666 'tab' => Controls_Manager::TAB_STYLE,
667 'condition' => [
668 'kng_dynamic_posts_enable_filters' => 'yes',
669 ],
670 ]
671 );
672
673 // Filter title typography
674 $this->add_group_control(
675 Group_Control_Typography::get_type(),
676 [
677 'name' => 'kng_dynamic_posts_filter_title_typography',
678 'label' => esc_html__('Typography', 'king-addons'),
679 'selector' => '{{WRAPPER}} .king-addons-dpg-filter-title',
680 'fields_options' => [
681 'typography' => [
682 'default' => 'yes',
683 ],
684 'font_size' => [
685 'default' => [
686 'size' => 36,
687 'unit' => 'px',
688 ],
689 ],
690 'font_weight' => [
691 'default' => '600',
692 ],
693 ],
694 ]
695 );
696
697 // Filter title color
698 $this->add_control(
699 'kng_dynamic_posts_filter_title_color',
700 [
701 'label' => esc_html__('Text Color', 'king-addons'),
702 'type' => Controls_Manager::COLOR,
703 'default' => '#2c3e50',
704 'selectors' => [
705 '{{WRAPPER}} .king-addons-dpg-filter-title' => 'color: {{VALUE}};',
706 ],
707 ]
708 );
709
710 // Filter title spacing
711 $this->add_responsive_control(
712 'kng_dynamic_posts_filter_title_margin',
713 [
714 'label' => esc_html__('Margin', 'king-addons'),
715 'type' => Controls_Manager::DIMENSIONS,
716 'size_units' => ['px', 'em', '%'],
717 'default' => [
718 'top' => 0,
719 'right' => 0,
720 'bottom' => 20,
721 'left' => 0,
722 'unit' => 'px',
723 ],
724 'selectors' => [
725 '{{WRAPPER}} .king-addons-dpg-filter-title' => 'margin: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
726 ],
727 ]
728 );
729
730 $this->end_controls_section();
731
732 // Filter Bar Style
733 $this->start_controls_section(
734 'kng_dynamic_posts_filter_style_section',
735 [
736 'label' => KING_ADDONS_ELEMENTOR_ICON . esc_html__('Filter Bar', 'king-addons'),
737 'tab' => Controls_Manager::TAB_STYLE,
738 ]
739 );
740
741 // Filter bar background
742 $this->add_group_control(
743 Group_Control_Background::get_type(),
744 [
745 'name' => 'kng_dynamic_posts_filter_background',
746 'label' => esc_html__('Background', 'king-addons'),
747 'types' => ['classic', 'gradient'],
748 'selector' => '{{WRAPPER}} .king-addons-dpg-filter-bar',
749 ]
750 );
751
752 // Filter bar padding
753 $this->add_responsive_control(
754 'kng_dynamic_posts_filter_padding',
755 [
756 'label' => esc_html__('Padding', 'king-addons'),
757 'type' => Controls_Manager::DIMENSIONS,
758 'size_units' => ['px', 'em', '%'],
759 'selectors' => [
760 '{{WRAPPER}} .king-addons-dpg-filter-bar' => 'padding: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
761 ],
762 ]
763 );
764
765 // Filter bar border
766 $this->add_group_control(
767 Group_Control_Border::get_type(),
768 [
769 'name' => 'kng_dynamic_posts_filter_border',
770 'label' => esc_html__('Border', 'king-addons'),
771 'selector' => '{{WRAPPER}} .king-addons-dpg-filter-bar',
772 ]
773 );
774
775 $this->end_controls_section();
776
777 // Filter Section Spacing
778 $this->start_controls_section(
779 'kng_dynamic_posts_filter_spacing_style_section',
780 [
781 'label' => KING_ADDONS_ELEMENTOR_ICON . esc_html__('Filter Section Spacing', 'king-addons'),
782 'tab' => Controls_Manager::TAB_STYLE,
783 'condition' => [
784 'kng_dynamic_posts_enable_filters' => 'yes',
785 ],
786 ]
787 );
788
789 // Filter bar margin bottom
790 $this->add_responsive_control(
791 'kng_dynamic_posts_filter_bar_margin_bottom',
792 [
793 'label' => esc_html__('Filter Bar Bottom Margin', 'king-addons'),
794 'type' => Controls_Manager::SLIDER,
795 'size_units' => ['px', 'em', 'rem'],
796 'range' => [
797 'px' => [
798 'min' => 0,
799 'max' => 100,
800 ],
801 ],
802 'default' => [
803 'size' => 40,
804 'unit' => 'px',
805 ],
806 'selectors' => [
807 '{{WRAPPER}} .king-addons-dpg-filter-bar' => 'margin-bottom: {{SIZE}}{{UNIT}};',
808 ],
809 ]
810 );
811
812 // Filter header margin bottom
813 $this->add_responsive_control(
814 'kng_dynamic_posts_filter_header_margin_bottom',
815 [
816 'label' => esc_html__('Filter Header Bottom Margin', 'king-addons'),
817 'type' => Controls_Manager::SLIDER,
818 'size_units' => ['px', 'em', 'rem'],
819 'range' => [
820 'px' => [
821 'min' => 0,
822 'max' => 50,
823 ],
824 ],
825 'default' => [
826 'size' => 20,
827 'unit' => 'px',
828 ],
829 'selectors' => [
830 '{{WRAPPER}} .king-addons-dpg-filter-header' => 'margin-bottom: {{SIZE}}{{UNIT}};',
831 ],
832 ]
833 );
834
835 // Filter controls gap
836 $this->add_responsive_control(
837 'kng_dynamic_posts_filter_controls_gap',
838 [
839 'label' => esc_html__('Controls Gap', 'king-addons'),
840 'type' => Controls_Manager::SLIDER,
841 'size_units' => ['px', 'em', 'rem'],
842 'range' => [
843 'px' => [
844 'min' => 0,
845 'max' => 60,
846 ],
847 ],
848 'default' => [
849 'size' => 30,
850 'unit' => 'px',
851 ],
852 'selectors' => [
853 '{{WRAPPER}} .king-addons-dpg-filter-controls' => 'gap: {{SIZE}}{{UNIT}};',
854 ],
855 ]
856 );
857
858 // Filter controls alignment
859 $this->add_responsive_control(
860 'kng_dynamic_posts_filter_controls_alignment',
861 [
862 'label' => esc_html__('Controls Alignment', 'king-addons'),
863 'type' => Controls_Manager::SELECT,
864 'default' => 'space-between',
865 'options' => [
866 'flex-start' => esc_html__('Start', 'king-addons'),
867 'center' => esc_html__('Center', 'king-addons'),
868 'flex-end' => esc_html__('End', 'king-addons'),
869 'space-between' => esc_html__('Space Between', 'king-addons'),
870 ],
871 'selectors' => [
872 '{{WRAPPER}} .king-addons-dpg-filter-controls' => 'justify-content: {{VALUE}};',
873 ],
874 ]
875 );
876
877 $this->end_controls_section();
878
879 // Filter Controls Style
880 $this->start_controls_section(
881 'kng_dynamic_posts_filter_controls_style_section',
882 [
883 'label' => KING_ADDONS_ELEMENTOR_ICON . esc_html__('Filter Controls', 'king-addons'),
884 'tab' => Controls_Manager::TAB_STYLE,
885 'condition' => [
886 'kng_dynamic_posts_enable_filters' => 'yes',
887 ],
888 ]
889 );
890
891 // Filter dropdown styles
892 $this->add_control(
893 'kng_dynamic_posts_filter_dropdown_heading',
894 [
895 'label' => esc_html__('Filter Dropdown', 'king-addons'),
896 'type' => Controls_Manager::HEADING,
897 'separator' => 'before',
898 ]
899 );
900
901 // Filter dropdown typography
902 $this->add_group_control(
903 Group_Control_Typography::get_type(),
904 [
905 'name' => 'kng_dynamic_posts_filter_dropdown_typography',
906 'label' => esc_html__('Typography', 'king-addons'),
907 'selector' => '{{WRAPPER}} .king-addons-dpg-posts-filter',
908 'fields_options' => [
909 'typography' => [
910 'default' => 'yes',
911 ],
912 'font_size' => [
913 'default' => [
914 'size' => 14,
915 'unit' => 'px',
916 ],
917 ],
918 'font_weight' => [
919 'default' => '500',
920 ],
921 ],
922 ]
923 );
924
925 // Filter dropdown colors
926 $this->add_control(
927 'kng_dynamic_posts_filter_dropdown_color',
928 [
929 'label' => esc_html__('Text Color', 'king-addons'),
930 'type' => Controls_Manager::COLOR,
931 'default' => '#374151',
932 'selectors' => [
933 '{{WRAPPER}} .king-addons-dpg-posts-filter' => 'color: {{VALUE}};',
934 ],
935 ]
936 );
937
938 // Filter dropdown background
939 $this->add_control(
940 'kng_dynamic_posts_filter_dropdown_background',
941 [
942 'label' => esc_html__('Background Color', 'king-addons'),
943 'type' => Controls_Manager::COLOR,
944 'default' => '#ffffff',
945 'selectors' => [
946 '{{WRAPPER}} .king-addons-dpg-posts-filter' => 'background-color: {{VALUE}};',
947 ],
948 ]
949 );
950
951 // Filter dropdown border
952 $this->add_group_control(
953 Group_Control_Border::get_type(),
954 [
955 'name' => 'kng_dynamic_posts_filter_dropdown_border',
956 'label' => esc_html__('Border', 'king-addons'),
957 'selector' => '{{WRAPPER}} .king-addons-dpg-posts-filter',
958 'fields_options' => [
959 'border' => [
960 'default' => 'solid',
961 ],
962 'width' => [
963 'default' => [
964 'top' => 1,
965 'right' => 1,
966 'bottom' => 1,
967 'left' => 1,
968 'unit' => 'px',
969 ],
970 ],
971 'color' => [
972 'default' => '#E5E7EB',
973 ],
974 ],
975 ]
976 );
977
978 // Filter dropdown border radius
979 $this->add_responsive_control(
980 'kng_dynamic_posts_filter_dropdown_border_radius',
981 [
982 'label' => esc_html__('Border Radius', 'king-addons'),
983 'type' => Controls_Manager::DIMENSIONS,
984 'size_units' => ['px', '%'],
985 'default' => [
986 'top' => 12,
987 'right' => 12,
988 'bottom' => 12,
989 'left' => 12,
990 'unit' => 'px',
991 ],
992 'selectors' => [
993 '{{WRAPPER}} .king-addons-dpg-posts-filter' => 'border-radius: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
994 ],
995 ]
996 );
997
998 // Filter dropdown padding
999 $this->add_responsive_control(
1000 'kng_dynamic_posts_filter_dropdown_padding',
1001 [
1002 'label' => esc_html__('Padding', 'king-addons'),
1003 'type' => Controls_Manager::DIMENSIONS,
1004 'size_units' => ['px', 'em', '%'],
1005 'default' => [
1006 'top' => 12,
1007 'right' => 40,
1008 'bottom' => 12,
1009 'left' => 16,
1010 'unit' => 'px',
1011 ],
1012 'selectors' => [
1013 '{{WRAPPER}} .king-addons-dpg-posts-filter' => 'padding: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
1014 ],
1015 ]
1016 );
1017
1018 // Filter dropdown box shadow
1019 $this->add_group_control(
1020 Group_Control_Box_Shadow::get_type(),
1021 [
1022 'name' => 'kng_dynamic_posts_filter_dropdown_box_shadow',
1023 'label' => esc_html__('Box Shadow', 'king-addons'),
1024 'selector' => '{{WRAPPER}} .king-addons-dpg-posts-filter',
1025 'fields_options' => [
1026 'box_shadow_type' => [
1027 'default' => 'yes',
1028 ],
1029 'box_shadow' => [
1030 'default' => [
1031 'horizontal' => 0,
1032 'vertical' => 1,
1033 'blur' => 2,
1034 'spread' => 0,
1035 'color' => 'rgba(0, 0, 0, 0.05)',
1036 ],
1037 ],
1038 ],
1039 ]
1040 );
1041
1042 // Filter dropdown icon
1043 $this->add_control(
1044 'kng_dynamic_posts_filter_dropdown_icon_heading',
1045 [
1046 'label' => esc_html__('Dropdown Icon', 'king-addons'),
1047 'type' => Controls_Manager::HEADING,
1048 'separator' => 'before',
1049 ]
1050 );
1051
1052 // Use custom dropdown icon/image
1053 $this->add_control(
1054 'kng_dynamic_posts_filter_dropdown_use_custom',
1055 [
1056 'label' => esc_html__('Use Custom Icon/Image', 'king-addons'),
1057 'type' => Controls_Manager::SWITCHER,
1058 'label_on' => esc_html__('Yes', 'king-addons'),
1059 'label_off' => esc_html__('No', 'king-addons'),
1060 'return_value' => 'yes',
1061 'default' => 'no',
1062 'description' => esc_html__('Replace default dropdown arrow with custom icon or image', 'king-addons'),
1063 ]
1064 );
1065
1066 // Choose dropdown type (icon or image)
1067 $this->add_control(
1068 'kng_dynamic_posts_filter_dropdown_type',
1069 [
1070 'label' => esc_html__('Type', 'king-addons'),
1071 'type' => Controls_Manager::SELECT,
1072 'options' => [
1073 'icon' => esc_html__('Icon', 'king-addons'),
1074 'image' => esc_html__('Image', 'king-addons'),
1075 ],
1076 'default' => 'icon',
1077 'condition' => [
1078 'kng_dynamic_posts_filter_dropdown_use_custom' => 'yes',
1079 ],
1080 ]
1081 );
1082
1083 // Choose custom dropdown icon
1084 $this->add_control(
1085 'kng_dynamic_posts_filter_dropdown_custom_icon',
1086 [
1087 'label' => esc_html__('Choose Icon', 'king-addons'),
1088 'type' => Controls_Manager::ICONS,
1089 'default' => [
1090 'value' => 'fas fa-chevron-down',
1091 'library' => 'fa-solid',
1092 ],
1093 'condition' => [
1094 'kng_dynamic_posts_filter_dropdown_use_custom' => 'yes',
1095 'kng_dynamic_posts_filter_dropdown_type' => 'icon',
1096 ],
1097 ]
1098 );
1099
1100 // Choose custom dropdown image
1101 $this->add_control(
1102 'kng_dynamic_posts_filter_dropdown_custom_image',
1103 [
1104 'label' => esc_html__('Choose Image', 'king-addons'),
1105 'type' => Controls_Manager::MEDIA,
1106 'media_types' => ['image'],
1107 'default' => [
1108 'url' => '',
1109 ],
1110 'condition' => [
1111 'kng_dynamic_posts_filter_dropdown_use_custom' => 'yes',
1112 'kng_dynamic_posts_filter_dropdown_type' => 'image',
1113 ],
1114 ]
1115 );
1116
1117 // Dropdown icon size
1118 $this->add_control(
1119 'kng_dynamic_posts_filter_dropdown_icon_size',
1120 [
1121 'label' => esc_html__('Icon Size', 'king-addons'),
1122 'type' => Controls_Manager::SLIDER,
1123 'size_units' => ['px'],
1124 'range' => [
1125 'px' => [
1126 'min' => 8,
1127 'max' => 30,
1128 'step' => 1,
1129 ],
1130 ],
1131 'default' => [
1132 'size' => 14,
1133 'unit' => 'px',
1134 ],
1135 'selectors' => [
1136 '{{WRAPPER}} .king-addons-dpg-filter-dropdown .dropdown-icon' => 'font-size: {{SIZE}}{{UNIT}};',
1137 '{{WRAPPER}} .king-addons-dpg-filter-dropdown .dropdown-icon svg' => 'width: {{SIZE}}{{UNIT}}; height: {{SIZE}}{{UNIT}};',
1138 '{{WRAPPER}} .king-addons-dpg-filter-dropdown .dropdown-icon i' => 'font-size: {{SIZE}}{{UNIT}};',
1139 ],
1140 'condition' => [
1141 'kng_dynamic_posts_filter_dropdown_use_custom' => 'yes',
1142 'kng_dynamic_posts_filter_dropdown_type' => 'icon',
1143 ],
1144 ]
1145 );
1146
1147 // Dropdown image size
1148 $this->add_control(
1149 'kng_dynamic_posts_filter_dropdown_image_size',
1150 [
1151 'label' => esc_html__('Image Size', 'king-addons'),
1152 'type' => Controls_Manager::SLIDER,
1153 'size_units' => ['px', 'em', '%'],
1154 'range' => [
1155 'px' => [
1156 'min' => 8,
1157 'max' => 100,
1158 'step' => 1,
1159 ],
1160 'em' => [
1161 'min' => 0.5,
1162 'max' => 5,
1163 'step' => 0.1,
1164 ],
1165 '%' => [
1166 'min' => 50,
1167 'max' => 200,
1168 'step' => 5,
1169 ],
1170 ],
1171 'default' => [
1172 'size' => 16,
1173 'unit' => 'px',
1174 ],
1175 'selectors' => [
1176 '{{WRAPPER}} .king-addons-dpg-filter-dropdown .dropdown-image' => 'width: {{SIZE}}{{UNIT}}; height: {{SIZE}}{{UNIT}};',
1177 '{{WRAPPER}} .king-addons-dpg-filter-dropdown .dropdown-image img' => 'width: 100%; height: 100%; object-fit: contain;',
1178 ],
1179 'condition' => [
1180 'kng_dynamic_posts_filter_dropdown_use_custom' => 'yes',
1181 'kng_dynamic_posts_filter_dropdown_type' => 'image',
1182 ],
1183 ]
1184 );
1185
1186 // Dropdown icon color
1187 $this->add_control(
1188 'kng_dynamic_posts_filter_dropdown_icon_color',
1189 [
1190 'label' => esc_html__('Icon Color', 'king-addons'),
1191 'type' => Controls_Manager::COLOR,
1192 'default' => '#6B7280',
1193 'selectors' => [
1194 '{{WRAPPER}} .king-addons-dpg-filter-dropdown .dropdown-icon' => 'color: {{VALUE}};',
1195 '{{WRAPPER}} .king-addons-dpg-filter-dropdown .dropdown-icon svg' => 'fill: {{VALUE}};',
1196 '{{WRAPPER}} .king-addons-dpg-filter-dropdown .dropdown-icon i' => 'color: {{VALUE}};',
1197 ],
1198 'condition' => [
1199 'kng_dynamic_posts_filter_dropdown_use_custom' => 'yes',
1200 'kng_dynamic_posts_filter_dropdown_type' => 'icon',
1201 ],
1202 ]
1203 );
1204
1205 // Dropdown image opacity
1206 $this->add_control(
1207 'kng_dynamic_posts_filter_dropdown_image_opacity',
1208 [
1209 'label' => esc_html__('Image Opacity', 'king-addons'),
1210 'type' => Controls_Manager::SLIDER,
1211 'range' => [
1212 'px' => [
1213 'min' => 0.1,
1214 'max' => 1,
1215 'step' => 0.1,
1216 ],
1217 ],
1218 'default' => [
1219 'size' => 0.8,
1220 ],
1221 'selectors' => [
1222 '{{WRAPPER}} .king-addons-dpg-filter-dropdown .dropdown-image' => 'opacity: {{SIZE}};',
1223 ],
1224 'condition' => [
1225 'kng_dynamic_posts_filter_dropdown_use_custom' => 'yes',
1226 'kng_dynamic_posts_filter_dropdown_type' => 'image',
1227 ],
1228 ]
1229 );
1230
1231 // Search input styles
1232 $this->add_control(
1233 'kng_dynamic_posts_search_input_heading',
1234 [
1235 'label' => esc_html__('Search Input', 'king-addons'),
1236 'type' => Controls_Manager::HEADING,
1237 'separator' => 'before',
1238 'condition' => [
1239 'kng_dynamic_posts_enable_search' => 'yes',
1240 ],
1241 ]
1242 );
1243
1244 // Search input typography
1245 $this->add_group_control(
1246 Group_Control_Typography::get_type(),
1247 [
1248 'name' => 'kng_dynamic_posts_search_input_typography',
1249 'label' => esc_html__('Typography', 'king-addons'),
1250 'selector' => '{{WRAPPER}} .king-addons-dpg-posts-search',
1251 'condition' => [
1252 'kng_dynamic_posts_enable_search' => 'yes',
1253 ],
1254 'fields_options' => [
1255 'typography' => [
1256 'default' => 'yes',
1257 ],
1258 'font_size' => [
1259 'default' => [
1260 'size' => 14,
1261 'unit' => 'px',
1262 ],
1263 ],
1264 ],
1265 ]
1266 );
1267
1268 // Search input colors
1269 $this->add_control(
1270 'kng_dynamic_posts_search_input_color',
1271 [
1272 'label' => esc_html__('Text Color', 'king-addons'),
1273 'type' => Controls_Manager::COLOR,
1274 'default' => '#374151',
1275 'selectors' => [
1276 '{{WRAPPER}} .king-addons-dpg-posts-search' => 'color: {{VALUE}};',
1277 ],
1278 'condition' => [
1279 'kng_dynamic_posts_enable_search' => 'yes',
1280 ],
1281 ]
1282 );
1283
1284 // Search input placeholder color
1285 $this->add_control(
1286 'kng_dynamic_posts_search_placeholder_color',
1287 [
1288 'label' => esc_html__('Placeholder Color', 'king-addons'),
1289 'type' => Controls_Manager::COLOR,
1290 'default' => '#9CA3AF',
1291 'selectors' => [
1292 '{{WRAPPER}} .king-addons-dpg-posts-search::placeholder' => 'color: {{VALUE}};',
1293 ],
1294 'condition' => [
1295 'kng_dynamic_posts_enable_search' => 'yes',
1296 ],
1297 ]
1298 );
1299
1300 // Search input background
1301 $this->add_control(
1302 'kng_dynamic_posts_search_input_background',
1303 [
1304 'label' => esc_html__('Background Color', 'king-addons'),
1305 'type' => Controls_Manager::COLOR,
1306 'default' => '#ffffff',
1307 'selectors' => [
1308 '{{WRAPPER}} .king-addons-dpg-search-input' => 'background-color: {{VALUE}};',
1309 ],
1310 'condition' => [
1311 'kng_dynamic_posts_enable_search' => 'yes',
1312 ],
1313 ]
1314 );
1315
1316 // Search input border
1317 $this->add_group_control(
1318 Group_Control_Border::get_type(),
1319 [
1320 'name' => 'kng_dynamic_posts_search_input_border',
1321 'label' => esc_html__('Border', 'king-addons'),
1322 'selector' => '{{WRAPPER}} .king-addons-dpg-search-input',
1323 'condition' => [
1324 'kng_dynamic_posts_enable_search' => 'yes',
1325 ],
1326 'fields_options' => [
1327 'border' => [
1328 'default' => 'solid',
1329 ],
1330 'width' => [
1331 'default' => [
1332 'top' => 1,
1333 'right' => 1,
1334 'bottom' => 1,
1335 'left' => 1,
1336 'unit' => 'px',
1337 ],
1338 ],
1339 'color' => [
1340 'default' => '#E5E7EB',
1341 ],
1342 ],
1343 ]
1344 );
1345
1346 // Search input border radius
1347 $this->add_responsive_control(
1348 'kng_dynamic_posts_search_input_border_radius',
1349 [
1350 'label' => esc_html__('Border Radius', 'king-addons'),
1351 'type' => Controls_Manager::DIMENSIONS,
1352 'size_units' => ['px', '%'],
1353 'default' => [
1354 'top' => 12,
1355 'right' => 12,
1356 'bottom' => 12,
1357 'left' => 12,
1358 'unit' => 'px',
1359 ],
1360 'selectors' => [
1361 '{{WRAPPER}} .king-addons-dpg-search-input' => 'border-radius: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
1362 ],
1363 'condition' => [
1364 'kng_dynamic_posts_enable_search' => 'yes',
1365 ],
1366 ]
1367 );
1368
1369 // Search input padding
1370 $this->add_responsive_control(
1371 'kng_dynamic_posts_search_input_padding',
1372 [
1373 'label' => esc_html__('Padding', 'king-addons'),
1374 'type' => Controls_Manager::DIMENSIONS,
1375 'size_units' => ['px', 'em', '%'],
1376 'default' => [
1377 'top' => 12,
1378 'right' => 16,
1379 'bottom' => 12,
1380 'left' => 16,
1381 'unit' => 'px',
1382 ],
1383 'selectors' => [
1384 '{{WRAPPER}} .king-addons-dpg-posts-search' => 'padding: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
1385 ],
1386 'condition' => [
1387 'kng_dynamic_posts_enable_search' => 'yes',
1388 ],
1389 ]
1390 );
1391
1392 // Search input box shadow
1393 $this->add_group_control(
1394 Group_Control_Box_Shadow::get_type(),
1395 [
1396 'name' => 'kng_dynamic_posts_search_input_box_shadow',
1397 'label' => esc_html__('Box Shadow', 'king-addons'),
1398 'selector' => '{{WRAPPER}} .king-addons-dpg-search-input',
1399 'condition' => [
1400 'kng_dynamic_posts_enable_search' => 'yes',
1401 ],
1402 'fields_options' => [
1403 'box_shadow_type' => [
1404 'default' => 'yes',
1405 ],
1406 'box_shadow' => [
1407 'default' => [
1408 'horizontal' => 0,
1409 'vertical' => 1,
1410 'blur' => 2,
1411 'spread' => 0,
1412 'color' => 'rgba(0, 0, 0, 0.05)',
1413 ],
1414 ],
1415 ],
1416 ]
1417 );
1418
1419 // Search button heading
1420 $this->add_control(
1421 'kng_dynamic_posts_search_button_heading',
1422 [
1423 'label' => esc_html__('Search Button', 'king-addons'),
1424 'type' => Controls_Manager::HEADING,
1425 'separator' => 'before',
1426 'condition' => [
1427 'kng_dynamic_posts_enable_search' => 'yes',
1428 ],
1429 ]
1430 );
1431
1432 // Search button size
1433 $this->add_responsive_control(
1434 'kng_dynamic_posts_search_button_size',
1435 [
1436 'label' => esc_html__('Button Size', 'king-addons'),
1437 'type' => Controls_Manager::SLIDER,
1438 'size_units' => ['px'],
1439 'range' => [
1440 'px' => [
1441 'min' => 30,
1442 'max' => 80,
1443 ],
1444 ],
1445 'default' => [
1446 'size' => 44,
1447 'unit' => 'px',
1448 ],
1449 'selectors' => [
1450 '{{WRAPPER}} .king-addons-dpg-search-btn' => 'width: {{SIZE}}{{UNIT}}; height: {{SIZE}}{{UNIT}};',
1451 ],
1452 'condition' => [
1453 'kng_dynamic_posts_enable_search' => 'yes',
1454 ],
1455 ]
1456 );
1457
1458 // Search button color
1459 $this->add_control(
1460 'kng_dynamic_posts_search_button_color',
1461 [
1462 'label' => esc_html__('Button Color', 'king-addons'),
1463 'type' => Controls_Manager::COLOR,
1464 'default' => '#6B7280',
1465 'selectors' => [
1466 '{{WRAPPER}} .king-addons-dpg-search-btn' => 'color: {{VALUE}};',
1467 ],
1468 'condition' => [
1469 'kng_dynamic_posts_enable_search' => 'yes',
1470 ],
1471 ]
1472 );
1473
1474 // Search button background
1475 $this->add_control(
1476 'kng_dynamic_posts_search_button_background',
1477 [
1478 'label' => esc_html__('Button Background', 'king-addons'),
1479 'type' => Controls_Manager::COLOR,
1480 'default' => 'transparent',
1481 'selectors' => [
1482 '{{WRAPPER}} .king-addons-dpg-search-btn' => 'background-color: {{VALUE}};',
1483 ],
1484 'condition' => [
1485 'kng_dynamic_posts_enable_search' => 'yes',
1486 ],
1487 ]
1488 );
1489
1490 // Search button hover color
1491 $this->add_control(
1492 'kng_dynamic_posts_search_button_hover_color',
1493 [
1494 'label' => esc_html__('Button Hover Color', 'king-addons'),
1495 'type' => Controls_Manager::COLOR,
1496 'default' => '#374151',
1497 'selectors' => [
1498 '{{WRAPPER}} .king-addons-dpg-search-btn:hover' => 'color: {{VALUE}};',
1499 ],
1500 'condition' => [
1501 'kng_dynamic_posts_enable_search' => 'yes',
1502 ],
1503 ]
1504 );
1505
1506 // Search button hover background
1507 $this->add_control(
1508 'kng_dynamic_posts_search_button_hover_background',
1509 [
1510 'label' => esc_html__('Button Hover Background', 'king-addons'),
1511 'type' => Controls_Manager::COLOR,
1512 'default' => 'rgba(59, 130, 246, 0.05)',
1513 'selectors' => [
1514 '{{WRAPPER}} .king-addons-dpg-search-btn:hover' => 'background-color: {{VALUE}};',
1515 ],
1516 'condition' => [
1517 'kng_dynamic_posts_enable_search' => 'yes',
1518 ],
1519 ]
1520 );
1521
1522 // Search button border
1523 $this->add_group_control(
1524 Group_Control_Border::get_type(),
1525 [
1526 'name' => 'kng_dynamic_posts_search_button_border',
1527 'label' => esc_html__('Button Border', 'king-addons'),
1528 'selector' => '{{WRAPPER}} .king-addons-dpg-search-btn',
1529 'condition' => [
1530 'kng_dynamic_posts_enable_search' => 'yes',
1531 ],
1532 ]
1533 );
1534
1535 // Search button border radius
1536 $this->add_responsive_control(
1537 'kng_dynamic_posts_search_button_border_radius',
1538 [
1539 'label' => esc_html__('Button Border Radius', 'king-addons'),
1540 'type' => Controls_Manager::DIMENSIONS,
1541 'size_units' => ['px', '%'],
1542 'selectors' => [
1543 '{{WRAPPER}} .king-addons-dpg-search-btn' => 'border-radius: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
1544 ],
1545 'condition' => [
1546 'kng_dynamic_posts_enable_search' => 'yes',
1547 ],
1548 ]
1549 );
1550
1551 // Search button padding
1552 $this->add_responsive_control(
1553 'kng_dynamic_posts_search_button_padding',
1554 [
1555 'label' => esc_html__('Button Padding', 'king-addons'),
1556 'type' => Controls_Manager::DIMENSIONS,
1557 'size_units' => ['px', 'em', '%'],
1558 'default' => [
1559 'top' => 8,
1560 'right' => 12,
1561 'bottom' => 8,
1562 'left' => 12,
1563 'unit' => 'px',
1564 ],
1565 'selectors' => [
1566 '{{WRAPPER}} .king-addons-dpg-search-btn' => 'padding: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
1567 ],
1568 'condition' => [
1569 'kng_dynamic_posts_enable_search' => 'yes',
1570 ],
1571 ]
1572 );
1573
1574 // Search button transition duration
1575 $this->add_control(
1576 'kng_dynamic_posts_search_button_transition',
1577 [
1578 'label' => esc_html__('Transition Duration (ms)', 'king-addons'),
1579 'type' => Controls_Manager::SLIDER,
1580 'range' => [
1581 'px' => [
1582 'min' => 100,
1583 'max' => 1000,
1584 'step' => 50,
1585 ],
1586 ],
1587 'default' => [
1588 'size' => 300,
1589 ],
1590 'selectors' => [
1591 '{{WRAPPER}} .king-addons-dpg-search-btn' => 'transition: all {{SIZE}}ms ease;',
1592 ],
1593 'condition' => [
1594 'kng_dynamic_posts_enable_search' => 'yes',
1595 ],
1596 ]
1597 );
1598
1599 // Search button icon heading
1600 $this->add_control(
1601 'kng_dynamic_posts_search_button_icon_heading',
1602 [
1603 'label' => esc_html__('Search Button Icon', 'king-addons'),
1604 'type' => Controls_Manager::HEADING,
1605 'separator' => 'before',
1606 'condition' => [
1607 'kng_dynamic_posts_enable_search' => 'yes',
1608 ],
1609 ]
1610 );
1611
1612 // Use custom icon
1613 $this->add_control(
1614 'kng_dynamic_posts_search_use_custom_icon',
1615 [
1616 'label' => esc_html__('Use Custom Icon', 'king-addons'),
1617 'type' => Controls_Manager::SWITCHER,
1618 'label_on' => esc_html__('Yes', 'king-addons'),
1619 'label_off' => esc_html__('No', 'king-addons'),
1620 'return_value' => 'yes',
1621 'default' => '',
1622 'condition' => [
1623 'kng_dynamic_posts_enable_search' => 'yes',
1624 ],
1625 ]
1626 );
1627
1628 // Custom icon
1629 $this->add_control(
1630 'kng_dynamic_posts_search_custom_icon',
1631 [
1632 'label' => esc_html__('Choose Icon', 'king-addons'),
1633 'type' => Controls_Manager::ICONS,
1634 'default' => [
1635 'value' => 'fas fa-search',
1636 'library' => 'fa-solid',
1637 ],
1638 'condition' => [
1639 'kng_dynamic_posts_enable_search' => 'yes',
1640 'kng_dynamic_posts_search_use_custom_icon' => 'yes',
1641 ],
1642 ]
1643 );
1644
1645 // Icon size
1646 $this->add_responsive_control(
1647 'kng_dynamic_posts_search_icon_size',
1648 [
1649 'label' => esc_html__('Icon Size', 'king-addons'),
1650 'type' => Controls_Manager::SLIDER,
1651 'size_units' => ['px'],
1652 'range' => [
1653 'px' => [
1654 'min' => 10,
1655 'max' => 50,
1656 ],
1657 ],
1658 'default' => [
1659 'size' => 18,
1660 'unit' => 'px',
1661 ],
1662 'selectors' => [
1663 '{{WRAPPER}} .king-addons-dpg-search-btn svg' => 'width: {{SIZE}}{{UNIT}}; height: {{SIZE}}{{UNIT}};',
1664 '{{WRAPPER}} .king-addons-dpg-search-btn i' => 'font-size: {{SIZE}}{{UNIT}};',
1665 ],
1666 'condition' => [
1667 'kng_dynamic_posts_enable_search' => 'yes',
1668 ],
1669 ]
1670 );
1671
1672 // Icon color
1673 $this->add_control(
1674 'kng_dynamic_posts_search_icon_color',
1675 [
1676 'label' => esc_html__('Icon Color', 'king-addons'),
1677 'type' => Controls_Manager::COLOR,
1678 'default' => '',
1679 'selectors' => [
1680 '{{WRAPPER}} .king-addons-dpg-search-btn svg' => 'fill: {{VALUE}};',
1681 '{{WRAPPER}} .king-addons-dpg-search-btn i' => 'color: {{VALUE}};',
1682 ],
1683 'condition' => [
1684 'kng_dynamic_posts_enable_search' => 'yes',
1685 ],
1686 ]
1687 );
1688
1689 // Icon hover color
1690 $this->add_control(
1691 'kng_dynamic_posts_search_icon_hover_color',
1692 [
1693 'label' => esc_html__('Icon Hover Color', 'king-addons'),
1694 'type' => Controls_Manager::COLOR,
1695 'default' => '',
1696 'selectors' => [
1697 '{{WRAPPER}} .king-addons-dpg-search-btn:hover svg' => 'fill: {{VALUE}};',
1698 '{{WRAPPER}} .king-addons-dpg-search-btn:hover i' => 'color: {{VALUE}};',
1699 ],
1700 'condition' => [
1701 'kng_dynamic_posts_enable_search' => 'yes',
1702 ],
1703 ]
1704 );
1705
1706 $this->end_controls_section();
1707
1708 // Card Style
1709 $this->start_controls_section(
1710 'kng_dynamic_posts_card_style_section',
1711 [
1712 'label' => KING_ADDONS_ELEMENTOR_ICON . esc_html__('Cards', 'king-addons'),
1713 'tab' => Controls_Manager::TAB_STYLE,
1714 ]
1715 );
1716
1717 // Icon Position
1718 $this->add_control(
1719 'kng_dynamic_posts_icon_position',
1720 [
1721 'label' => esc_html__('Icon Position', 'king-addons'),
1722 'type' => Controls_Manager::SELECT,
1723 'default' => 'left',
1724 'options' => [
1725 'left' => esc_html__('Left', 'king-addons'),
1726 'right' => esc_html__('Right', 'king-addons'),
1727 ],
1728 'prefix_class' => 'king-addons-icon-',
1729 ]
1730 );
1731
1732 // Card background color
1733 $this->add_control(
1734 'kng_dynamic_posts_card_background_color',
1735 [
1736 'label' => esc_html__('Background Color', 'king-addons'),
1737 'type' => Controls_Manager::COLOR,
1738 'default' => '#F8F9FA',
1739 'selectors' => [
1740 '{{WRAPPER}} .king-addons-dpg-card' => 'background-color: {{VALUE}};',
1741 ],
1742 ]
1743 );
1744
1745 // Card border
1746 $this->add_group_control(
1747 Group_Control_Border::get_type(),
1748 [
1749 'name' => 'kng_dynamic_posts_card_border',
1750 'label' => esc_html__('Border', 'king-addons'),
1751 'selector' => '{{WRAPPER}} .king-addons-dpg-card',
1752 'fields_options' => [
1753 'border' => [
1754 'default' => 'solid',
1755 ],
1756 'width' => [
1757 'default' => [
1758 'top' => 1,
1759 'right' => 1,
1760 'bottom' => 1,
1761 'left' => 1,
1762 'unit' => 'px',
1763 ],
1764 ],
1765 'color' => [
1766 'default' => 'rgba(0, 0, 0, 0.05)',
1767 ],
1768 ],
1769 ]
1770 );
1771
1772 // Card border radius
1773 $this->add_responsive_control(
1774 'kng_dynamic_posts_card_border_radius',
1775 [
1776 'label' => esc_html__('Border Radius', 'king-addons'),
1777 'type' => Controls_Manager::DIMENSIONS,
1778 'size_units' => ['px', '%'],
1779 'default' => [
1780 'top' => 20,
1781 'right' => 20,
1782 'bottom' => 20,
1783 'left' => 20,
1784 'unit' => 'px',
1785 ],
1786 'selectors' => [
1787 '{{WRAPPER}} .king-addons-dpg-card' => 'border-radius: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
1788 ],
1789 ]
1790 );
1791
1792 // Card min height
1793 $this->add_responsive_control(
1794 'kng_dynamic_posts_card_min_height',
1795 [
1796 'label' => esc_html__('Min Height', 'king-addons'),
1797 'type' => Controls_Manager::SLIDER,
1798 'size_units' => ['px', 'vh'],
1799 'range' => [
1800 'px' => [
1801 'min' => 100,
1802 'max' => 800,
1803 'step' => 10,
1804 ],
1805 'vh' => [
1806 'min' => 10,
1807 'max' => 100,
1808 ],
1809 ],
1810 'default' => [
1811 'size' => 260,
1812 'unit' => 'px',
1813 ],
1814 'selectors' => [
1815 '{{WRAPPER}} .king-addons-dpg-card' => 'min-height: {{SIZE}}{{UNIT}};',
1816 ],
1817 ]
1818 );
1819
1820 // Card box shadow
1821 $this->add_group_control(
1822 Group_Control_Box_Shadow::get_type(),
1823 [
1824 'name' => 'kng_dynamic_posts_card_box_shadow',
1825 'label' => esc_html__('Box Shadow', 'king-addons'),
1826 'selector' => '{{WRAPPER}} .king-addons-dpg-card',
1827 'fields_options' => [
1828 'box_shadow_type' => [
1829 'default' => 'yes',
1830 ],
1831 'box_shadow' => [
1832 'default' => [
1833 'horizontal' => 0,
1834 'vertical' => 1,
1835 'blur' => 3,
1836 'spread' => 0,
1837 'color' => 'rgba(0, 0, 0, 0.1)',
1838 ],
1839 ],
1840 ],
1841 ]
1842 );
1843
1844 // Card typography
1845 $this->add_group_control(
1846 Group_Control_Typography::get_type(),
1847 [
1848 'name' => 'kng_dynamic_posts_card_typography',
1849 'label' => esc_html__('Typography', 'king-addons'),
1850 'selector' => '{{WRAPPER}} .king-addons-dpg-card',
1851 ]
1852 );
1853
1854 $this->end_controls_section();
1855
1856 // Card Hover Effects
1857 $this->start_controls_section(
1858 'kng_dynamic_posts_card_hover_style_section',
1859 [
1860 'label' => KING_ADDONS_ELEMENTOR_ICON . esc_html__('Card Hover Effects', 'king-addons'),
1861 'tab' => Controls_Manager::TAB_STYLE,
1862 ]
1863 );
1864
1865 // Hover transform
1866 $this->add_control(
1867 'kng_dynamic_posts_card_hover_transform',
1868 [
1869 'label' => esc_html__('Hover Transform', 'king-addons'),
1870 'type' => Controls_Manager::SELECT,
1871 'default' => 'translateY(-4px)',
1872 'options' => [
1873 'none' => esc_html__('None', 'king-addons'),
1874 'translateY(-2px)' => esc_html__('Lift Small', 'king-addons'),
1875 'translateY(-4px)' => esc_html__('Lift Medium', 'king-addons'),
1876 'translateY(-6px)' => esc_html__('Lift Large', 'king-addons'),
1877 'scale(1.02)' => esc_html__('Scale Small', 'king-addons'),
1878 'scale(1.05)' => esc_html__('Scale Medium', 'king-addons'),
1879 ],
1880 'selectors' => [
1881 '{{WRAPPER}} .king-addons-dpg-card:hover' => 'transform: {{VALUE}};',
1882 ],
1883 ]
1884 );
1885
1886 // Hover box shadow
1887 $this->add_group_control(
1888 Group_Control_Box_Shadow::get_type(),
1889 [
1890 'name' => 'kng_dynamic_posts_card_hover_box_shadow',
1891 'label' => esc_html__('Hover Box Shadow', 'king-addons'),
1892 'selector' => '{{WRAPPER}} .king-addons-dpg-card:hover',
1893 'fields_options' => [
1894 'box_shadow_type' => [
1895 'default' => 'yes',
1896 ],
1897 'box_shadow' => [
1898 'default' => [
1899 'horizontal' => 0,
1900 'vertical' => 10,
1901 'blur' => 25,
1902 'spread' => 0,
1903 'color' => 'rgba(0, 0, 0, 0.15)',
1904 ],
1905 ],
1906 ],
1907 ]
1908 );
1909
1910 // Hover border color
1911 $this->add_control(
1912 'kng_dynamic_posts_card_hover_border_color',
1913 [
1914 'label' => esc_html__('Hover Border Color', 'king-addons'),
1915 'type' => Controls_Manager::COLOR,
1916 'default' => 'rgba(0, 0, 0, 0.1)',
1917 'selectors' => [
1918 '{{WRAPPER}} .king-addons-dpg-card:hover' => 'border-color: {{VALUE}};',
1919 ],
1920 ]
1921 );
1922
1923 // Transition duration
1924 $this->add_control(
1925 'kng_dynamic_posts_card_transition_duration',
1926 [
1927 'label' => esc_html__('Transition Duration (ms)', 'king-addons'),
1928 'type' => Controls_Manager::SLIDER,
1929 'range' => [
1930 'px' => [
1931 'min' => 100,
1932 'max' => 1000,
1933 'step' => 50,
1934 ],
1935 ],
1936 'default' => [
1937 'size' => 300,
1938 ],
1939 'selectors' => [
1940 '{{WRAPPER}} .king-addons-dpg-card' => 'transition: all {{SIZE}}ms cubic-bezier(0.4, 0, 0.2, 1);',
1941 ],
1942 ]
1943 );
1944
1945 // Card clickable
1946 $this->add_control(
1947 'kng_dynamic_posts_card_clickable',
1948 [
1949 'label' => esc_html__('Make Card Clickable', 'king-addons'),
1950 'type' => Controls_Manager::SWITCHER,
1951 'label_on' => esc_html__('Yes', 'king-addons'),
1952 'label_off' => esc_html__('No', 'king-addons'),
1953 'return_value' => 'yes',
1954 'default' => 'no',
1955 'description' => esc_html__('Makes the entire card clickable to navigate to the post. Note: This feature works only on the live site.', 'king-addons'),
1956 ]
1957 );
1958
1959 // Card clickable notice for editor
1960 $this->add_control(
1961 'kng_dynamic_posts_card_clickable_notice',
1962 [
1963 'type' => Controls_Manager::RAW_HTML,
1964 'raw' => '<div style="background: #fff3cd; border: 1px solid #ffc107; border-radius: 4px; padding: 12px; margin-top: 10px; color: #856404;">
1965 <div style="display: flex; align-items: center; gap: 8px; margin-bottom: 8px;">
1966 <i class="eicon-info-circle" style="color: #ffc107;"></i>
1967 <strong>' . esc_html__('Card Clickable Notice', 'king-addons') . '</strong>
1968 </div>
1969 <p style="margin: 0; font-size: 13px; line-height: 1.4;">' .
1970 esc_html__('Card clicking functionality is disabled in the Elementor editor to prevent interference with editing. It will work properly on the live site.', 'king-addons') .
1971 '</p>
1972 </div>',
1973 'condition' => [
1974 'kng_dynamic_posts_card_clickable' => 'yes',
1975 ],
1976 ]
1977 );
1978
1979 $this->end_controls_section();
1980
1981 // Card Header Style
1982 $this->start_controls_section(
1983 'kng_dynamic_posts_card_header_style_section',
1984 [
1985 'label' => KING_ADDONS_ELEMENTOR_ICON . esc_html__('Card Header', 'king-addons'),
1986 'tab' => Controls_Manager::TAB_STYLE,
1987 ]
1988 );
1989
1990 // Header padding
1991 $this->add_responsive_control(
1992 'kng_dynamic_posts_header_padding',
1993 [
1994 'label' => esc_html__('Padding', 'king-addons'),
1995 'type' => Controls_Manager::DIMENSIONS,
1996 'size_units' => ['px', 'em', '%'],
1997 'default' => [
1998 'top' => 24,
1999 'right' => 24,
2000 'bottom' => 20,
2001 'left' => 24,
2002 'unit' => 'px',
2003 ],
2004 'selectors' => [
2005 '{{WRAPPER}} .king-addons-dpg-header' => 'padding: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
2006 ],
2007 ]
2008 );
2009
2010 // Icon styles
2011 $this->add_control(
2012 'kng_dynamic_posts_icon_heading',
2013 [
2014 'label' => esc_html__('Icon', 'king-addons'),
2015 'type' => Controls_Manager::HEADING,
2016 'separator' => 'before',
2017 ]
2018 );
2019
2020 // Icon size
2021 $this->add_responsive_control(
2022 'kng_dynamic_posts_icon_size',
2023 [
2024 'label' => esc_html__('Icon Size', 'king-addons'),
2025 'type' => Controls_Manager::SLIDER,
2026 'size_units' => ['px'],
2027 'range' => [
2028 'px' => [
2029 'min' => 12,
2030 'max' => 50,
2031 ],
2032 ],
2033 'default' => [
2034 'size' => 20,
2035 'unit' => 'px',
2036 ],
2037 'selectors' => [
2038 '{{WRAPPER}} .king-addons-dpg-icon i' => 'font-size: {{SIZE}}{{UNIT}};',
2039 '{{WRAPPER}} .king-addons-dpg-icon svg' => 'width: {{SIZE}}{{UNIT}}; height: {{SIZE}}{{UNIT}};',
2040 '{{WRAPPER}} .king-addons-dpg-icon img' => 'width: {{SIZE}}{{UNIT}}; height: {{SIZE}}{{UNIT}};',
2041 ],
2042 ]
2043 );
2044
2045 // Icon color
2046 $this->add_control(
2047 'kng_dynamic_posts_icon_color',
2048 [
2049 'label' => esc_html__('Icon Color', 'king-addons'),
2050 'type' => Controls_Manager::COLOR,
2051 'default' => '#6B7280',
2052 'selectors' => [
2053 '{{WRAPPER}} .king-addons-dpg-icon i' => 'color: {{VALUE}};',
2054 '{{WRAPPER}} .king-addons-dpg-icon svg' => 'fill: {{VALUE}};',
2055 ],
2056 ]
2057 );
2058
2059 // Icon background
2060 $this->add_control(
2061 'kng_dynamic_posts_icon_background',
2062 [
2063 'label' => esc_html__('Icon Background', 'king-addons'),
2064 'type' => Controls_Manager::COLOR,
2065 'default' => 'rgba(255, 255, 255, 0.7)',
2066 'selectors' => [
2067 '{{WRAPPER}} .king-addons-dpg-icon' => 'background-color: {{VALUE}};',
2068 ],
2069 ]
2070 );
2071
2072 // Icon border radius
2073 $this->add_responsive_control(
2074 'kng_dynamic_posts_icon_border_radius',
2075 [
2076 'label' => esc_html__('Icon Border Radius', 'king-addons'),
2077 'type' => Controls_Manager::DIMENSIONS,
2078 'size_units' => ['px', '%'],
2079 'default' => [
2080 'top' => 12,
2081 'right' => 12,
2082 'bottom' => 12,
2083 'left' => 12,
2084 'unit' => 'px',
2085 ],
2086 'selectors' => [
2087 '{{WRAPPER}} .king-addons-dpg-icon' => 'border-radius: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
2088 ],
2089 ]
2090 );
2091
2092 // Icon container size
2093 $this->add_responsive_control(
2094 'kng_dynamic_posts_icon_container_size',
2095 [
2096 'label' => esc_html__('Icon Container Size', 'king-addons'),
2097 'type' => Controls_Manager::SLIDER,
2098 'size_units' => ['px'],
2099 'range' => [
2100 'px' => [
2101 'min' => 30,
2102 'max' => 80,
2103 ],
2104 ],
2105 'default' => [
2106 'size' => 44,
2107 'unit' => 'px',
2108 ],
2109 'selectors' => [
2110 '{{WRAPPER}} .king-addons-dpg-icon' => 'width: {{SIZE}}{{UNIT}}; height: {{SIZE}}{{UNIT}};',
2111 ],
2112 ]
2113 );
2114
2115 // Icon box shadow
2116 $this->add_group_control(
2117 Group_Control_Box_Shadow::get_type(),
2118 [
2119 'name' => 'kng_dynamic_posts_icon_box_shadow',
2120 'label' => esc_html__('Icon Box Shadow', 'king-addons'),
2121 'selector' => '{{WRAPPER}} .king-addons-dpg-icon',
2122 'fields_options' => [
2123 'box_shadow_type' => [
2124 'default' => 'yes',
2125 ],
2126 'box_shadow' => [
2127 'default' => [
2128 'horizontal' => 0,
2129 'vertical' => 2,
2130 'blur' => 4,
2131 'spread' => 0,
2132 'color' => 'rgba(0, 0, 0, 0.1)',
2133 ],
2134 ],
2135 ],
2136 ]
2137 );
2138
2139 // Label styles
2140 $this->add_control(
2141 'kng_dynamic_posts_label_heading',
2142 [
2143 'label' => esc_html__('Label', 'king-addons'),
2144 'type' => Controls_Manager::HEADING,
2145 'separator' => 'before',
2146 ]
2147 );
2148
2149 // Label typography
2150 $this->add_group_control(
2151 Group_Control_Typography::get_type(),
2152 [
2153 'name' => 'kng_dynamic_posts_label_typography',
2154 'label' => esc_html__('Label Typography', 'king-addons'),
2155 'selector' => '{{WRAPPER}} .king-addons-dpg-label',
2156 'fields_options' => [
2157 'typography' => [
2158 'default' => 'yes',
2159 ],
2160 'font_size' => [
2161 'default' => [
2162 'size' => 11,
2163 'unit' => 'px',
2164 ],
2165 ],
2166 'font_weight' => [
2167 'default' => '600',
2168 ],
2169 'text_transform' => [
2170 'default' => 'uppercase',
2171 ],
2172 'letter_spacing' => [
2173 'default' => [
2174 'size' => 1,
2175 'unit' => 'px',
2176 ],
2177 ],
2178 ],
2179 ]
2180 );
2181
2182 // Label color
2183 $this->add_control(
2184 'kng_dynamic_posts_label_color',
2185 [
2186 'label' => esc_html__('Label Color', 'king-addons'),
2187 'type' => Controls_Manager::COLOR,
2188 'default' => '#6B7280',
2189 'selectors' => [
2190 '{{WRAPPER}} .king-addons-dpg-label' => 'color: {{VALUE}};',
2191 ],
2192 ]
2193 );
2194
2195 // Label padding
2196 $this->add_responsive_control(
2197 'kng_dynamic_posts_label_padding',
2198 [
2199 'label' => esc_html__('Label Padding', 'king-addons'),
2200 'type' => Controls_Manager::DIMENSIONS,
2201 'size_units' => ['px', 'em', '%'],
2202 'default' => [
2203 'top' => 4,
2204 'right' => 8,
2205 'bottom' => 4,
2206 'left' => 8,
2207 'unit' => 'px',
2208 ],
2209 'selectors' => [
2210 '{{WRAPPER}} .king-addons-dpg-label' => 'padding: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
2211 ],
2212 ]
2213 );
2214
2215 // Label border
2216 $this->add_group_control(
2217 Group_Control_Border::get_type(),
2218 [
2219 'name' => 'kng_dynamic_posts_label_border',
2220 'label' => esc_html__('Label Border', 'king-addons'),
2221 'selector' => '{{WRAPPER}} .king-addons-dpg-label',
2222 'fields_options' => [
2223 'border' => [
2224 'default' => 'solid',
2225 ],
2226 'width' => [
2227 'default' => [
2228 'top' => 1,
2229 'right' => 1,
2230 'bottom' => 1,
2231 'left' => 1,
2232 'unit' => 'px',
2233 ],
2234 ],
2235 'color' => [
2236 'default' => '#E5E7EB',
2237 ],
2238 ],
2239 ]
2240 );
2241
2242 // Label border radius
2243 $this->add_responsive_control(
2244 'kng_dynamic_posts_label_border_radius',
2245 [
2246 'label' => esc_html__('Label Border Radius', 'king-addons'),
2247 'type' => Controls_Manager::DIMENSIONS,
2248 'size_units' => ['px', 'em', '%'],
2249 'default' => [
2250 'top' => 4,
2251 'right' => 4,
2252 'bottom' => 4,
2253 'left' => 4,
2254 'unit' => 'px',
2255 ],
2256 'selectors' => [
2257 '{{WRAPPER}} .king-addons-dpg-label' => 'border-radius: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
2258 ],
2259 ]
2260 );
2261
2262 // Label background
2263 $this->add_control(
2264 'kng_dynamic_posts_label_background',
2265 [
2266 'label' => esc_html__('Label Background', 'king-addons'),
2267 'type' => Controls_Manager::COLOR,
2268 'default' => 'transparent',
2269 'selectors' => [
2270 '{{WRAPPER}} .king-addons-dpg-label' => 'background-color: {{VALUE}};',
2271 ],
2272 ]
2273 );
2274
2275 $this->end_controls_section();
2276
2277 // Card Content Style
2278 $this->start_controls_section(
2279 'kng_dynamic_posts_card_content_style_section',
2280 [
2281 'label' => KING_ADDONS_ELEMENTOR_ICON . esc_html__('Card Content', 'king-addons'),
2282 'tab' => Controls_Manager::TAB_STYLE,
2283 ]
2284 );
2285
2286 // Content padding
2287 $this->add_responsive_control(
2288 'kng_dynamic_posts_content_padding',
2289 [
2290 'label' => esc_html__('Content Padding', 'king-addons'),
2291 'type' => Controls_Manager::DIMENSIONS,
2292 'size_units' => ['px', 'em', '%'],
2293 'default' => [
2294 'top' => 0,
2295 'right' => 24,
2296 'bottom' => 20,
2297 'left' => 24,
2298 'unit' => 'px',
2299 ],
2300 'selectors' => [
2301 '{{WRAPPER}} .king-addons-dpg-content' => 'padding: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
2302 ],
2303 ]
2304 );
2305
2306 // Content vertical alignment
2307 $this->add_responsive_control(
2308 'kng_dynamic_posts_content_vertical_alignment',
2309 [
2310 'label' => esc_html__('Content Vertical Alignment', 'king-addons'),
2311 'type' => Controls_Manager::SELECT,
2312 'default' => 'flex-start',
2313 'options' => [
2314 'flex-start' => esc_html__('Top', 'king-addons'),
2315 'center' => esc_html__('Center', 'king-addons'),
2316 'flex-end' => esc_html__('Bottom', 'king-addons'),
2317 'space-between' => esc_html__('Space Between', 'king-addons'),
2318 'space-around' => esc_html__('Space Around', 'king-addons'),
2319 ],
2320 'selectors' => [
2321 '{{WRAPPER}} .king-addons-dpg-content' => 'justify-content: {{VALUE}};',
2322 ],
2323 ]
2324 );
2325
2326 // Show excerpt
2327 $this->add_control(
2328 'kng_dynamic_posts_show_excerpt',
2329 [
2330 'label' => esc_html__('Show Excerpt', 'king-addons'),
2331 'type' => Controls_Manager::SWITCHER,
2332 'label_on' => esc_html__('Show', 'king-addons'),
2333 'label_off' => esc_html__('Hide', 'king-addons'),
2334 'return_value' => 'yes',
2335 'default' => 'yes',
2336 ]
2337 );
2338
2339 // Title typography
2340 $this->add_group_control(
2341 Group_Control_Typography::get_type(),
2342 [
2343 'name' => 'kng_dynamic_posts_title_typography',
2344 'label' => esc_html__('Title Typography', 'king-addons'),
2345 'selector' => '{{WRAPPER}} .king-addons-dpg-title',
2346 'fields_options' => [
2347 'typography' => [
2348 'default' => 'yes',
2349 ],
2350 'font_size' => [
2351 'default' => [
2352 'size' => 16,
2353 'unit' => 'px',
2354 ],
2355 ],
2356 'font_weight' => [
2357 'default' => '500',
2358 ],
2359 'line_height' => [
2360 'default' => [
2361 'size' => 1.5,
2362 'unit' => 'em',
2363 ],
2364 ],
2365 ],
2366 ]
2367 );
2368
2369 // Title color
2370 $this->add_control(
2371 'kng_dynamic_posts_title_color',
2372 [
2373 'label' => esc_html__('Title Color', 'king-addons'),
2374 'type' => Controls_Manager::COLOR,
2375 'default' => '#374151',
2376 'selectors' => [
2377 '{{WRAPPER}} .king-addons-dpg-title a' => 'color: {{VALUE}};',
2378 ],
2379 ]
2380 );
2381
2382 // Title hover color
2383 $this->add_control(
2384 'kng_dynamic_posts_title_hover_color',
2385 [
2386 'label' => esc_html__('Title Hover Color', 'king-addons'),
2387 'type' => Controls_Manager::COLOR,
2388 'default' => '#1F2937',
2389 'selectors' => [
2390 '{{WRAPPER}} .king-addons-dpg-title a:hover' => 'color: {{VALUE}};',
2391 ],
2392 ]
2393 );
2394
2395 // Excerpt heading
2396 $this->add_control(
2397 'kng_dynamic_posts_excerpt_heading',
2398 [
2399 'label' => esc_html__('Excerpt', 'king-addons'),
2400 'type' => Controls_Manager::HEADING,
2401 'separator' => 'before',
2402 'condition' => [
2403 'kng_dynamic_posts_show_excerpt' => 'yes',
2404 ],
2405 ]
2406 );
2407
2408 // Excerpt typography
2409 $this->add_group_control(
2410 Group_Control_Typography::get_type(),
2411 [
2412 'name' => 'kng_dynamic_posts_excerpt_typography',
2413 'label' => esc_html__('Excerpt Typography', 'king-addons'),
2414 'selector' => '{{WRAPPER}} .king-addons-dpg-excerpt',
2415 'condition' => [
2416 'kng_dynamic_posts_show_excerpt' => 'yes',
2417 ],
2418 'fields_options' => [
2419 'typography' => [
2420 'default' => 'yes',
2421 ],
2422 'font_size' => [
2423 'default' => [
2424 'size' => 14,
2425 'unit' => 'px',
2426 ],
2427 ],
2428 'line_height' => [
2429 'default' => [
2430 'size' => 1.5,
2431 'unit' => 'em',
2432 ],
2433 ],
2434 ],
2435 ]
2436 );
2437
2438 // Excerpt color
2439 $this->add_control(
2440 'kng_dynamic_posts_excerpt_color',
2441 [
2442 'label' => esc_html__('Excerpt Color', 'king-addons'),
2443 'type' => Controls_Manager::COLOR,
2444 'default' => '#6B7280',
2445 'selectors' => [
2446 '{{WRAPPER}} .king-addons-dpg-excerpt' => 'color: {{VALUE}};',
2447 ],
2448 'condition' => [
2449 'kng_dynamic_posts_show_excerpt' => 'yes',
2450 ],
2451 ]
2452 );
2453
2454 // Excerpt margin
2455 $this->add_responsive_control(
2456 'kng_dynamic_posts_excerpt_margin',
2457 [
2458 'label' => esc_html__('Excerpt Margin', 'king-addons'),
2459 'type' => Controls_Manager::DIMENSIONS,
2460 'size_units' => ['px', 'em', '%'],
2461 'default' => [
2462 'top' => 8,
2463 'right' => 0,
2464 'bottom' => 0,
2465 'left' => 0,
2466 'unit' => 'px',
2467 ],
2468 'selectors' => [
2469 '{{WRAPPER}} .king-addons-dpg-excerpt' => 'margin: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
2470 ],
2471 'condition' => [
2472 'kng_dynamic_posts_show_excerpt' => 'yes',
2473 ],
2474 ]
2475 );
2476
2477 $this->end_controls_section();
2478
2479 // Card Button Style
2480 $this->start_controls_section(
2481 'kng_dynamic_posts_card_button_style_section',
2482 [
2483 'label' => KING_ADDONS_ELEMENTOR_ICON . esc_html__('Card Button', 'king-addons'),
2484 'tab' => Controls_Manager::TAB_STYLE,
2485 ]
2486 );
2487
2488 // Button container padding
2489 $this->add_responsive_control(
2490 'kng_dynamic_posts_button_container_padding',
2491 [
2492 'label' => esc_html__('Container Padding', 'king-addons'),
2493 'type' => Controls_Manager::DIMENSIONS,
2494 'size_units' => ['px', 'em', '%'],
2495 'default' => [
2496 'top' => 0,
2497 'right' => 24,
2498 'bottom' => 24,
2499 'left' => 24,
2500 'unit' => 'px',
2501 ],
2502 'selectors' => [
2503 '{{WRAPPER}} .king-addons-dpg-cta' => 'padding: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
2504 ],
2505 ]
2506 );
2507
2508 // Button typography
2509 $this->add_group_control(
2510 Group_Control_Typography::get_type(),
2511 [
2512 'name' => 'kng_dynamic_posts_button_typography',
2513 'label' => esc_html__('Button Typography', 'king-addons'),
2514 'selector' => '{{WRAPPER}} .king-addons-dpg-button',
2515 'fields_options' => [
2516 'typography' => [
2517 'default' => 'yes',
2518 ],
2519 'font_size' => [
2520 'default' => [
2521 'size' => 11,
2522 'unit' => 'px',
2523 ],
2524 ],
2525 'font_weight' => [
2526 'default' => '500',
2527 ],
2528 'text_transform' => [
2529 'default' => 'uppercase',
2530 ],
2531 'letter_spacing' => [
2532 'default' => [
2533 'size' => 0.5,
2534 'unit' => 'px',
2535 ],
2536 ],
2537 ],
2538 ]
2539 );
2540
2541 // Button border style
2542 $this->add_control(
2543 'kng_dynamic_posts_button_border_style',
2544 [
2545 'label' => esc_html__('Border Style', 'king-addons'),
2546 'type' => Controls_Manager::SELECT,
2547 'options' => [
2548 'none' => esc_html__('None', 'king-addons'),
2549 'solid' => esc_html__('Solid', 'king-addons'),
2550 'dashed' => esc_html__('Dashed', 'king-addons'),
2551 'dotted' => esc_html__('Dotted', 'king-addons'),
2552 ],
2553 'default' => 'solid',
2554 'selectors' => [
2555 '{{WRAPPER}} .king-addons-dpg-button' => 'border-style: {{VALUE}};',
2556 ],
2557 ]
2558 );
2559
2560 // Button border width
2561 $this->add_responsive_control(
2562 'kng_dynamic_posts_button_border_width',
2563 [
2564 'label' => esc_html__('Border Width', 'king-addons'),
2565 'type' => Controls_Manager::DIMENSIONS,
2566 'size_units' => ['px'],
2567 'default' => [
2568 'top' => 1,
2569 'right' => 1,
2570 'bottom' => 1,
2571 'left' => 1,
2572 'unit' => 'px',
2573 ],
2574 'selectors' => [
2575 '{{WRAPPER}} .king-addons-dpg-button' => 'border-width: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
2576 ],
2577 'condition' => [
2578 'kng_dynamic_posts_button_border_style!' => 'none',
2579 ],
2580 ]
2581 );
2582
2583 // Default button border color
2584 $this->add_control(
2585 'kng_dynamic_posts_default_button_border_color',
2586 [
2587 'label' => esc_html__('Default Border Color', 'king-addons'),
2588 'type' => Controls_Manager::COLOR,
2589 'default' => 'rgba(0, 0, 0, 0.1)',
2590 'selectors' => [
2591 '{{WRAPPER}} .king-addons-dpg-button' => 'border-color: {{VALUE}};',
2592 ],
2593 'condition' => [
2594 'kng_dynamic_posts_button_border_style!' => 'none',
2595 ],
2596 ]
2597 );
2598
2599 // Button border radius
2600 $this->add_responsive_control(
2601 'kng_dynamic_posts_button_border_radius',
2602 [
2603 'label' => esc_html__('Border Radius', 'king-addons'),
2604 'type' => Controls_Manager::DIMENSIONS,
2605 'size_units' => ['px', '%'],
2606 'default' => [
2607 'top' => 20,
2608 'right' => 20,
2609 'bottom' => 20,
2610 'left' => 20,
2611 'unit' => 'px',
2612 ],
2613 'selectors' => [
2614 '{{WRAPPER}} .king-addons-dpg-button' => 'border-radius: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
2615 ],
2616 ]
2617 );
2618
2619 // Button padding
2620 $this->add_responsive_control(
2621 'kng_dynamic_posts_button_padding',
2622 [
2623 'label' => esc_html__('Button Padding', 'king-addons'),
2624 'type' => Controls_Manager::DIMENSIONS,
2625 'size_units' => ['px', 'em', '%'],
2626 'default' => [
2627 'top' => 10,
2628 'right' => 20,
2629 'bottom' => 10,
2630 'left' => 20,
2631 'unit' => 'px',
2632 ],
2633 'selectors' => [
2634 '{{WRAPPER}} .king-addons-dpg-button' => 'padding: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
2635 ],
2636 ]
2637 );
2638
2639 // Button box shadow
2640 $this->add_group_control(
2641 Group_Control_Box_Shadow::get_type(),
2642 [
2643 'name' => 'kng_dynamic_posts_button_box_shadow',
2644 'label' => esc_html__('Box Shadow', 'king-addons'),
2645 'selector' => '{{WRAPPER}} .king-addons-dpg-button',
2646 'fields_options' => [
2647 'box_shadow_type' => [
2648 'default' => 'yes',
2649 ],
2650 'box_shadow' => [
2651 'default' => [
2652 'horizontal' => 0,
2653 'vertical' => 1,
2654 'blur' => 2,
2655 'spread' => 0,
2656 'color' => 'rgba(0, 0, 0, 0.05)',
2657 ],
2658 ],
2659 ],
2660 ]
2661 );
2662
2663 $this->end_controls_section();
2664
2665 // Load More Button Style
2666 $this->start_controls_section(
2667 'kng_dynamic_posts_load_more_style_section',
2668 [
2669 'label' => KING_ADDONS_ELEMENTOR_ICON . esc_html__('Load More Button', 'king-addons'),
2670 'tab' => Controls_Manager::TAB_STYLE,
2671 ]
2672 );
2673
2674 // Button typography
2675 $this->add_group_control(
2676 Group_Control_Typography::get_type(),
2677 [
2678 'name' => 'kng_dynamic_posts_load_more_typography',
2679 'label' => esc_html__('Typography', 'king-addons'),
2680 'selector' => '{{WRAPPER}} .king-addons-dpg-load-more-btn',
2681 'fields_options' => [
2682 'typography' => [
2683 'default' => 'yes',
2684 ],
2685 'font_size' => [
2686 'default' => [
2687 'size' => 14,
2688 'unit' => 'px',
2689 ],
2690 ],
2691 'font_weight' => [
2692 'default' => '600',
2693 ],
2694 'text_transform' => [
2695 'default' => 'uppercase',
2696 ],
2697 'letter_spacing' => [
2698 'default' => [
2699 'size' => 0.5,
2700 'unit' => 'px',
2701 ],
2702 ],
2703 ],
2704 ]
2705 );
2706
2707 // Button text color
2708 $this->add_control(
2709 'kng_dynamic_posts_load_more_color',
2710 [
2711 'label' => esc_html__('Text Color', 'king-addons'),
2712 'type' => Controls_Manager::COLOR,
2713 'default' => '#1F2937',
2714 'selectors' => [
2715 '{{WRAPPER}} .king-addons-dpg-load-more-btn' => 'color: {{VALUE}};',
2716 ],
2717 ]
2718 );
2719
2720 // Button background
2721 $this->add_group_control(
2722 Group_Control_Background::get_type(),
2723 [
2724 'name' => 'kng_dynamic_posts_load_more_background',
2725 'label' => esc_html__('Background', 'king-addons'),
2726 'types' => ['classic', 'gradient'],
2727 'selector' => '{{WRAPPER}} .king-addons-dpg-load-more-btn',
2728 'fields_options' => [
2729 'background' => [
2730 'default' => 'classic',
2731 ],
2732 'color' => [
2733 'default' => '#FCD34D',
2734 ],
2735 ],
2736 ]
2737 );
2738
2739 // Button hover color
2740 $this->add_control(
2741 'kng_dynamic_posts_load_more_hover_color',
2742 [
2743 'label' => esc_html__('Hover Text Color', 'king-addons'),
2744 'type' => Controls_Manager::COLOR,
2745 'default' => '#1F2937',
2746 'selectors' => [
2747 '{{WRAPPER}} .king-addons-dpg-load-more-btn:hover' => 'color: {{VALUE}};',
2748 ],
2749 ]
2750 );
2751
2752 // Button hover background
2753 $this->add_control(
2754 'kng_dynamic_posts_load_more_hover_background',
2755 [
2756 'label' => esc_html__('Hover Background', 'king-addons'),
2757 'type' => Controls_Manager::COLOR,
2758 'default' => '#F59E0B',
2759 'selectors' => [
2760 '{{WRAPPER}} .king-addons-dpg-load-more-btn:hover' => 'background-color: {{VALUE}};',
2761 ],
2762 ]
2763 );
2764
2765 // Button border
2766 $this->add_group_control(
2767 Group_Control_Border::get_type(),
2768 [
2769 'name' => 'kng_dynamic_posts_load_more_border',
2770 'label' => esc_html__('Border', 'king-addons'),
2771 'selector' => '{{WRAPPER}} .king-addons-dpg-load-more-btn',
2772 ]
2773 );
2774
2775 // Button border radius
2776 $this->add_responsive_control(
2777 'kng_dynamic_posts_load_more_border_radius',
2778 [
2779 'label' => esc_html__('Border Radius', 'king-addons'),
2780 'type' => Controls_Manager::DIMENSIONS,
2781 'size_units' => ['px', '%'],
2782 'default' => [
2783 'top' => 24,
2784 'right' => 24,
2785 'bottom' => 24,
2786 'left' => 24,
2787 'unit' => 'px',
2788 ],
2789 'selectors' => [
2790 '{{WRAPPER}} .king-addons-dpg-load-more-btn' => 'border-radius: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
2791 ],
2792 ]
2793 );
2794
2795 // Button padding
2796 $this->add_responsive_control(
2797 'kng_dynamic_posts_load_more_padding',
2798 [
2799 'label' => esc_html__('Padding', 'king-addons'),
2800 'type' => Controls_Manager::DIMENSIONS,
2801 'size_units' => ['px', 'em', '%'],
2802 'default' => [
2803 'top' => 16,
2804 'right' => 48,
2805 'bottom' => 16,
2806 'left' => 48,
2807 'unit' => 'px',
2808 ],
2809 'selectors' => [
2810 '{{WRAPPER}} .king-addons-dpg-load-more-btn' => 'padding: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
2811 ],
2812 ]
2813 );
2814
2815 // Button box shadow
2816 $this->add_group_control(
2817 Group_Control_Box_Shadow::get_type(),
2818 [
2819 'name' => 'kng_dynamic_posts_load_more_box_shadow',
2820 'label' => esc_html__('Box Shadow', 'king-addons'),
2821 'selector' => '{{WRAPPER}} .king-addons-dpg-load-more-btn',
2822 'fields_options' => [
2823 'box_shadow_type' => [
2824 'default' => 'yes',
2825 ],
2826 'box_shadow' => [
2827 'default' => [
2828 'horizontal' => 0,
2829 'vertical' => 2,
2830 'blur' => 4,
2831 'spread' => 0,
2832 'color' => 'rgba(252, 211, 77, 0.3)',
2833 ],
2834 ],
2835 ],
2836 ]
2837 );
2838
2839 $this->end_controls_section();
2840
2841 // Pagination Style
2842 $this->start_controls_section(
2843 'kng_dynamic_posts_pagination_style_section',
2844 [
2845 'label' => KING_ADDONS_ELEMENTOR_ICON . esc_html__('Pagination', 'king-addons'),
2846 'tab' => Controls_Manager::TAB_STYLE,
2847 'condition' => [
2848 'kng_dynamic_posts_enable_load_more' => 'yes',
2849 ],
2850 ]
2851 );
2852
2853 // Pagination section margin top
2854 $this->add_responsive_control(
2855 'kng_dynamic_posts_pagination_margin_top',
2856 [
2857 'label' => esc_html__('Section Top Margin', 'king-addons'),
2858 'type' => Controls_Manager::SLIDER,
2859 'size_units' => ['px', 'em', 'rem'],
2860 'range' => [
2861 'px' => [
2862 'min' => 0,
2863 'max' => 100,
2864 ],
2865 ],
2866 'default' => [
2867 'size' => 40,
2868 'unit' => 'px',
2869 ],
2870 'selectors' => [
2871 '{{WRAPPER}} .king-addons-dpg-pagination' => 'margin-top: {{SIZE}}{{UNIT}};',
2872 ],
2873 ]
2874 );
2875
2876 // Pagination info typography
2877 $this->add_group_control(
2878 Group_Control_Typography::get_type(),
2879 [
2880 'name' => 'kng_dynamic_posts_pagination_info_typography',
2881 'label' => esc_html__('Info Typography', 'king-addons'),
2882 'selector' => '{{WRAPPER}} .king-addons-dpg-pagination-info',
2883 'fields_options' => [
2884 'typography' => [
2885 'default' => 'yes',
2886 ],
2887 'font_size' => [
2888 'default' => [
2889 'size' => 14,
2890 'unit' => 'px',
2891 ],
2892 ],
2893 ],
2894 ]
2895 );
2896
2897 // Pagination info color
2898 $this->add_control(
2899 'kng_dynamic_posts_pagination_info_color',
2900 [
2901 'label' => esc_html__('Info Text Color', 'king-addons'),
2902 'type' => Controls_Manager::COLOR,
2903 'default' => '#6B7280',
2904 'selectors' => [
2905 '{{WRAPPER}} .king-addons-dpg-pagination-info' => 'color: {{VALUE}};',
2906 ],
2907 ]
2908 );
2909
2910 // Count numbers color
2911 $this->add_control(
2912 'kng_dynamic_posts_pagination_count_color',
2913 [
2914 'label' => esc_html__('Count Numbers Color', 'king-addons'),
2915 'type' => Controls_Manager::COLOR,
2916 'default' => '#374151',
2917 'selectors' => [
2918 '{{WRAPPER}} .king-addons-dpg-current-count, {{WRAPPER}} .king-addons-dpg-total-count' => 'color: {{VALUE}};',
2919 ],
2920 ]
2921 );
2922
2923 // Pagination info margin
2924 $this->add_responsive_control(
2925 'kng_dynamic_posts_pagination_info_margin',
2926 [
2927 'label' => esc_html__('Info Bottom Margin', 'king-addons'),
2928 'type' => Controls_Manager::SLIDER,
2929 'size_units' => ['px', 'em', 'rem'],
2930 'range' => [
2931 'px' => [
2932 'min' => 0,
2933 'max' => 60,
2934 ],
2935 ],
2936 'default' => [
2937 'size' => 30,
2938 'unit' => 'px',
2939 ],
2940 'selectors' => [
2941 '{{WRAPPER}} .king-addons-dpg-pagination-info' => 'margin-bottom: {{SIZE}}{{UNIT}};',
2942 ],
2943 ]
2944 );
2945
2946 // Loading text styles
2947 $this->add_control(
2948 'kng_dynamic_posts_loading_heading',
2949 [
2950 'label' => esc_html__('Loading Text', 'king-addons'),
2951 'type' => Controls_Manager::HEADING,
2952 'separator' => 'before',
2953 ]
2954 );
2955
2956 // Loading text color
2957 $this->add_control(
2958 'kng_dynamic_posts_loading_color',
2959 [
2960 'label' => esc_html__('Loading Text Color', 'king-addons'),
2961 'type' => Controls_Manager::COLOR,
2962 'default' => '#666',
2963 'selectors' => [
2964 '{{WRAPPER}} .king-addons-dpg-pagination-loading' => 'color: {{VALUE}};',
2965 ],
2966 ]
2967 );
2968
2969 // Finish text styles
2970 $this->add_control(
2971 'kng_dynamic_posts_finish_heading',
2972 [
2973 'label' => esc_html__('Finish Text', 'king-addons'),
2974 'type' => Controls_Manager::HEADING,
2975 'separator' => 'before',
2976 ]
2977 );
2978
2979 // Finish text typography
2980 $this->add_group_control(
2981 Group_Control_Typography::get_type(),
2982 [
2983 'name' => 'kng_dynamic_posts_finish_typography',
2984 'label' => esc_html__('Finish Typography', 'king-addons'),
2985 'selector' => '{{WRAPPER}} .king-addons-dpg-pagination-finish',
2986 'fields_options' => [
2987 'typography' => [
2988 'default' => 'yes',
2989 ],
2990 'font_size' => [
2991 'default' => [
2992 'size' => 14,
2993 'unit' => 'px',
2994 ],
2995 ],
2996 ],
2997 ]
2998 );
2999
3000 // Finish text color
3001 $this->add_control(
3002 'kng_dynamic_posts_finish_color',
3003 [
3004 'label' => esc_html__('Finish Text Color', 'king-addons'),
3005 'type' => Controls_Manager::COLOR,
3006 'default' => '#6B7280',
3007 'selectors' => [
3008 '{{WRAPPER}} .king-addons-dpg-pagination-finish' => 'color: {{VALUE}};',
3009 ],
3010 ]
3011 );
3012
3013 // Finish text margin
3014 $this->add_responsive_control(
3015 'kng_dynamic_posts_finish_margin',
3016 [
3017 'label' => esc_html__('Finish Text Margin', 'king-addons'),
3018 'type' => Controls_Manager::DIMENSIONS,
3019 'size_units' => ['px', 'em', '%'],
3020 'default' => [
3021 'top' => 30,
3022 'right' => 0,
3023 'bottom' => 20,
3024 'left' => 0,
3025 'unit' => 'px',
3026 ],
3027 'selectors' => [
3028 '{{WRAPPER}} .king-addons-dpg-pagination-finish' => 'margin: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
3029 ],
3030 ]
3031 );
3032
3033 $this->end_controls_section();
3034
3035 // Messages Style
3036 $this->start_controls_section(
3037 'kng_dynamic_posts_messages_style_section',
3038 [
3039 'label' => KING_ADDONS_ELEMENTOR_ICON . esc_html__('Messages', 'king-addons'),
3040 'tab' => Controls_Manager::TAB_STYLE,
3041 ]
3042 );
3043
3044 // No posts message
3045 $this->add_control(
3046 'kng_dynamic_posts_no_posts_heading',
3047 [
3048 'label' => esc_html__('No Posts Message', 'king-addons'),
3049 'type' => Controls_Manager::HEADING,
3050 ]
3051 );
3052
3053 // No posts typography
3054 $this->add_group_control(
3055 Group_Control_Typography::get_type(),
3056 [
3057 'name' => 'kng_dynamic_posts_no_posts_typography',
3058 'label' => esc_html__('Typography', 'king-addons'),
3059 'selector' => '{{WRAPPER}} .king-addons-dpg-no-posts',
3060 'fields_options' => [
3061 'typography' => [
3062 'default' => 'yes',
3063 ],
3064 'font_size' => [
3065 'default' => [
3066 'size' => 16,
3067 'unit' => 'px',
3068 ],
3069 ],
3070 ],
3071 ]
3072 );
3073
3074 // No posts color
3075 $this->add_control(
3076 'kng_dynamic_posts_no_posts_color',
3077 [
3078 'label' => esc_html__('Text Color', 'king-addons'),
3079 'type' => Controls_Manager::COLOR,
3080 'default' => '#666',
3081 'selectors' => [
3082 '{{WRAPPER}} .king-addons-dpg-no-posts' => 'color: {{VALUE}};',
3083 ],
3084 ]
3085 );
3086
3087 // No posts background
3088 $this->add_control(
3089 'kng_dynamic_posts_no_posts_background',
3090 [
3091 'label' => esc_html__('Background Color', 'king-addons'),
3092 'type' => Controls_Manager::COLOR,
3093 'default' => '#f8f9fa',
3094 'selectors' => [
3095 '{{WRAPPER}} .king-addons-dpg-no-posts' => 'background-color: {{VALUE}};',
3096 ],
3097 ]
3098 );
3099
3100 // No posts border
3101 $this->add_group_control(
3102 Group_Control_Border::get_type(),
3103 [
3104 'name' => 'kng_dynamic_posts_no_posts_border',
3105 'label' => esc_html__('Border', 'king-addons'),
3106 'selector' => '{{WRAPPER}} .king-addons-dpg-no-posts',
3107 'fields_options' => [
3108 'border' => [
3109 'default' => 'dashed',
3110 ],
3111 'width' => [
3112 'default' => [
3113 'top' => 2,
3114 'right' => 2,
3115 'bottom' => 2,
3116 'left' => 2,
3117 'unit' => 'px',
3118 ],
3119 ],
3120 'color' => [
3121 'default' => '#ddd',
3122 ],
3123 ],
3124 ]
3125 );
3126
3127 // No posts border radius
3128 $this->add_responsive_control(
3129 'kng_dynamic_posts_no_posts_border_radius',
3130 [
3131 'label' => esc_html__('Border Radius', 'king-addons'),
3132 'type' => Controls_Manager::DIMENSIONS,
3133 'size_units' => ['px', '%'],
3134 'default' => [
3135 'top' => 8,
3136 'right' => 8,
3137 'bottom' => 8,
3138 'left' => 8,
3139 'unit' => 'px',
3140 ],
3141 'selectors' => [
3142 '{{WRAPPER}} .king-addons-dpg-no-posts' => 'border-radius: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
3143 ],
3144 ]
3145 );
3146
3147 // No posts padding
3148 $this->add_responsive_control(
3149 'kng_dynamic_posts_no_posts_padding',
3150 [
3151 'label' => esc_html__('Padding', 'king-addons'),
3152 'type' => Controls_Manager::DIMENSIONS,
3153 'size_units' => ['px', 'em', '%'],
3154 'default' => [
3155 'top' => 60,
3156 'right' => 20,
3157 'bottom' => 60,
3158 'left' => 20,
3159 'unit' => 'px',
3160 ],
3161 'selectors' => [
3162 '{{WRAPPER}} .king-addons-dpg-no-posts' => 'padding: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
3163 ],
3164 ]
3165 );
3166
3167 // Error message
3168 $this->add_control(
3169 'kng_dynamic_posts_error_heading',
3170 [
3171 'label' => esc_html__('Error Message', 'king-addons'),
3172 'type' => Controls_Manager::HEADING,
3173 'separator' => 'before',
3174 ]
3175 );
3176
3177 // Error message typography
3178 $this->add_group_control(
3179 Group_Control_Typography::get_type(),
3180 [
3181 'name' => 'kng_dynamic_posts_error_typography',
3182 'label' => esc_html__('Typography', 'king-addons'),
3183 'selector' => '{{WRAPPER}} .king-addons-dpg-error-message',
3184 'fields_options' => [
3185 'typography' => [
3186 'default' => 'yes',
3187 ],
3188 'font_size' => [
3189 'default' => [
3190 'size' => 14,
3191 'unit' => 'px',
3192 ],
3193 ],
3194 ],
3195 ]
3196 );
3197
3198 // Error message colors
3199 $this->add_control(
3200 'kng_dynamic_posts_error_color',
3201 [
3202 'label' => esc_html__('Text Color', 'king-addons'),
3203 'type' => Controls_Manager::COLOR,
3204 'default' => '#721c24',
3205 'selectors' => [
3206 '{{WRAPPER}} .king-addons-dpg-error-message' => 'color: {{VALUE}};',
3207 ],
3208 ]
3209 );
3210
3211 // Error message background
3212 $this->add_control(
3213 'kng_dynamic_posts_error_background',
3214 [
3215 'label' => esc_html__('Background Color', 'king-addons'),
3216 'type' => Controls_Manager::COLOR,
3217 'default' => '#f8d7da',
3218 'selectors' => [
3219 '{{WRAPPER}} .king-addons-dpg-error-message' => 'background-color: {{VALUE}};',
3220 ],
3221 ]
3222 );
3223
3224 // Error message border
3225 $this->add_group_control(
3226 Group_Control_Border::get_type(),
3227 [
3228 'name' => 'kng_dynamic_posts_error_border',
3229 'label' => esc_html__('Border', 'king-addons'),
3230 'selector' => '{{WRAPPER}} .king-addons-dpg-error-message',
3231 'fields_options' => [
3232 'border' => [
3233 'default' => 'solid',
3234 ],
3235 'width' => [
3236 'default' => [
3237 'top' => 1,
3238 'right' => 1,
3239 'bottom' => 1,
3240 'left' => 1,
3241 'unit' => 'px',
3242 ],
3243 ],
3244 'color' => [
3245 'default' => '#f5c6cb',
3246 ],
3247 ],
3248 ]
3249 );
3250
3251 // Error message border radius
3252 $this->add_responsive_control(
3253 'kng_dynamic_posts_error_border_radius',
3254 [
3255 'label' => esc_html__('Border Radius', 'king-addons'),
3256 'type' => Controls_Manager::DIMENSIONS,
3257 'size_units' => ['px', '%'],
3258 'default' => [
3259 'top' => 8,
3260 'right' => 8,
3261 'bottom' => 8,
3262 'left' => 8,
3263 'unit' => 'px',
3264 ],
3265 'selectors' => [
3266 '{{WRAPPER}} .king-addons-dpg-error-message' => 'border-radius: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
3267 ],
3268 ]
3269 );
3270
3271 // Error message padding
3272 $this->add_responsive_control(
3273 'kng_dynamic_posts_error_padding',
3274 [
3275 'label' => esc_html__('Padding', 'king-addons'),
3276 'type' => Controls_Manager::DIMENSIONS,
3277 'size_units' => ['px', 'em', '%'],
3278 'default' => [
3279 'top' => 12,
3280 'right' => 16,
3281 'bottom' => 12,
3282 'left' => 16,
3283 'unit' => 'px',
3284 ],
3285 'selectors' => [
3286 '{{WRAPPER}} .king-addons-dpg-error-message' => 'padding: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
3287 ],
3288 ]
3289 );
3290
3291 // Error message margin
3292 $this->add_responsive_control(
3293 'kng_dynamic_posts_error_margin_bottom',
3294 [
3295 'label' => esc_html__('Bottom Margin', 'king-addons'),
3296 'type' => Controls_Manager::SLIDER,
3297 'size_units' => ['px', 'em', 'rem'],
3298 'range' => [
3299 'px' => [
3300 'min' => 0,
3301 'max' => 50,
3302 ],
3303 ],
3304 'default' => [
3305 'size' => 20,
3306 'unit' => 'px',
3307 ],
3308 'selectors' => [
3309 '{{WRAPPER}} .king-addons-dpg-error-message' => 'margin-bottom: {{SIZE}}{{UNIT}};',
3310 ],
3311 ]
3312 );
3313
3314 $this->end_controls_section();
3315 }
3316
3317 /**
3318 * Get available post types.
3319 *
3320 * @return array Post types array.
3321 */
3322 protected function get_post_types(): array
3323 {
3324 $post_types = get_post_types(['public' => true], 'objects');
3325 $options = [];
3326
3327 foreach ($post_types as $post_type) {
3328 $options[$post_type->name] = $post_type->label;
3329 }
3330
3331 return $options;
3332 }
3333
3334 /**
3335 * Get available taxonomies.
3336 *
3337 * @return array Taxonomies array.
3338 */
3339 protected function get_taxonomies(): array
3340 {
3341 $taxonomies = get_taxonomies(['public' => true], 'objects');
3342 $options = [];
3343
3344 foreach ($taxonomies as $taxonomy) {
3345 $options[$taxonomy->name] = $taxonomy->label;
3346 }
3347
3348 return $options;
3349 }
3350
3351 /**
3352 * Add dynamic category color controls.
3353 */
3354 protected function add_dynamic_category_colors(): void
3355 {
3356 // Get taxonomy from filter settings (default to category)
3357 $taxonomy = 'category';
3358
3359 // Get terms from the taxonomy
3360 $terms = get_terms([
3361 'taxonomy' => $taxonomy,
3362 'hide_empty' => false,
3363 'number' => 20, // Limit to prevent too many controls
3364 ]);
3365
3366 if (is_wp_error($terms) || empty($terms)) {
3367 // Fallback to default colors if no terms found
3368 $this->add_control(
3369 'kng_dynamic_posts_default_color',
3370 [
3371 'label' => esc_html__('Default Color', 'king-addons'),
3372 'type' => Controls_Manager::COLOR,
3373 'default' => '#F8F9FA',
3374 'description' => esc_html__('Default color for posts without categories', 'king-addons'),
3375 'selectors' => [
3376 '{{WRAPPER}} .king-addons-dpg-card' => 'background-color: {{VALUE}};',
3377 '{{WRAPPER}} .king-addons-dpg-card.king-addons-dpg-category-default' => 'background-color: {{VALUE}};',
3378 ],
3379 ]
3380 );
3381 return;
3382 }
3383
3384 // Add instruction
3385 $this->add_control(
3386 'kng_dynamic_posts_colors_info',
3387 [
3388 'type' => Controls_Manager::RAW_HTML,
3389 'raw' => esc_html__('Set custom colors for each category. These colors will be used as background colors for post cards.', 'king-addons'),
3390 'content_classes' => 'elementor-panel-alert elementor-panel-alert-info',
3391 ]
3392 );
3393
3394 // Default color for uncategorized posts
3395 $this->add_control(
3396 'kng_dynamic_posts_default_color',
3397 [
3398 'label' => esc_html__('Default Color', 'king-addons'),
3399 'type' => Controls_Manager::COLOR,
3400 'default' => '#F8F9FA',
3401 'description' => esc_html__('Color for posts without categories', 'king-addons'),
3402 'selectors' => [
3403 '{{WRAPPER}} .king-addons-dpg-card' => 'background-color: {{VALUE}};',
3404 '{{WRAPPER}} .king-addons-dpg-card.king-addons-dpg-category-default' => 'background-color: {{VALUE}};',
3405 ],
3406 ]
3407 );
3408
3409 // Add color control for each term (matching original design)
3410 $default_colors = [
3411 '#FEF3C7', // Warm yellow/cream (like REPORT in design)
3412 '#DBEAFE', // Light blue (like PUBLICATION in design)
3413 '#FBCFE8', // Light pink (like VIDEO in design)
3414 '#F3F4F6', // Light gray (like WEBSITE in design)
3415 '#E0E7FF', // Light indigo
3416 '#FEE2E2', // Light red
3417 '#D1FAE5', // Light emerald
3418 '#FEF3C7', // Light amber
3419 ];
3420
3421 $color_index = 0;
3422 foreach ($terms as $term) {
3423 $default_color = isset($default_colors[$color_index]) ? $default_colors[$color_index] : '#F8F9FA';
3424
3425 $this->add_control(
3426 'kng_dynamic_posts_color_' . $term->slug,
3427 [
3428 'label' => sprintf(esc_html__('%s Color', 'king-addons'), $term->name),
3429 'type' => Controls_Manager::COLOR,
3430 'default' => $default_color,
3431 'selectors' => [
3432 '{{WRAPPER}} .king-addons-dpg-card.filter-' . $term->slug => 'background-color: {{VALUE}};',
3433 '{{WRAPPER}} .king-addons-dpg-card.king-addons-dpg-category-' . $term->slug => 'background-color: {{VALUE}};',
3434 ],
3435 ]
3436 );
3437
3438 $color_index++;
3439 if ($color_index >= count($default_colors)) {
3440 $color_index = 0; // Reset to cycle through colors
3441 }
3442 }
3443 }
3444
3445 /**
3446 * Add dynamic category icon controls.
3447 */
3448 protected function add_dynamic_category_icons(): void
3449 {
3450 // Get taxonomy from filter settings (default to category)
3451 $taxonomy = 'category';
3452
3453 // Get terms from the taxonomy
3454 $terms = get_terms([
3455 'taxonomy' => $taxonomy,
3456 'hide_empty' => false,
3457 'number' => 20, // Limit to prevent too many controls
3458 ]);
3459
3460 if (is_wp_error($terms) || empty($terms)) {
3461 // Fallback to default icon if no terms found
3462 $this->add_control(
3463 'kng_dynamic_posts_default_icon',
3464 [
3465 'label' => esc_html__('Default Icon', 'king-addons'),
3466 'type' => Controls_Manager::ICONS,
3467 'default' => [
3468 'value' => 'far fa-file-alt',
3469 'library' => 'fa-regular',
3470 ],
3471 'description' => esc_html__('Default icon for posts without categories', 'king-addons'),
3472 ]
3473 );
3474 return;
3475 }
3476
3477 // Add instruction
3478 $this->add_control(
3479 'kng_dynamic_posts_icons_info',
3480 [
3481 'type' => Controls_Manager::RAW_HTML,
3482 'raw' => esc_html__('Set custom icons for each category. These icons will be displayed in the header of post cards.', 'king-addons'),
3483 'content_classes' => 'elementor-panel-alert elementor-panel-alert-info',
3484 ]
3485 );
3486
3487 // Default icon type
3488 $this->add_control(
3489 'kng_dynamic_posts_default_icon_type',
3490 [
3491 'label' => esc_html__('Default Type', 'king-addons'),
3492 'type' => Controls_Manager::SELECT,
3493 'options' => [
3494 'icon' => esc_html__('Icon', 'king-addons'),
3495 'image' => esc_html__('Image', 'king-addons'),
3496 ],
3497 'default' => 'icon',
3498 'description' => esc_html__('Choose type for posts without categories', 'king-addons'),
3499 ]
3500 );
3501
3502 // Default icon for uncategorized posts
3503 $this->add_control(
3504 'kng_dynamic_posts_default_icon',
3505 [
3506 'label' => esc_html__('Default Icon', 'king-addons'),
3507 'type' => Controls_Manager::ICONS,
3508 'default' => [
3509 'value' => 'far fa-file-alt',
3510 'library' => 'fa-regular',
3511 ],
3512 'condition' => [
3513 'kng_dynamic_posts_default_icon_type' => 'icon',
3514 ],
3515 ]
3516 );
3517
3518 // Default image for uncategorized posts
3519 $this->add_control(
3520 'kng_dynamic_posts_default_image',
3521 [
3522 'label' => esc_html__('Default Image', 'king-addons'),
3523 'type' => Controls_Manager::MEDIA,
3524 'media_types' => ['image'],
3525 'default' => [
3526 'url' => '',
3527 ],
3528 'condition' => [
3529 'kng_dynamic_posts_default_icon_type' => 'image',
3530 ],
3531 ]
3532 );
3533
3534 // Add icon control for each term
3535 $default_icons = [
3536 [
3537 'value' => 'far fa-file-alt',
3538 'library' => 'fa-regular',
3539 ], // Report
3540 [
3541 'value' => 'far fa-newspaper',
3542 'library' => 'fa-regular',
3543 ], // Publication
3544 [
3545 'value' => 'far fa-play-circle',
3546 'library' => 'fa-regular',
3547 ], // Video
3548 [
3549 'value' => 'fas fa-globe',
3550 'library' => 'fa-solid',
3551 ], // Website
3552 [
3553 'value' => 'far fa-star',
3554 'library' => 'fa-regular',
3555 ],
3556 [
3557 'value' => 'far fa-heart',
3558 'library' => 'fa-regular',
3559 ],
3560 [
3561 'value' => 'far fa-lightbulb',
3562 'library' => 'fa-regular',
3563 ],
3564 [
3565 'value' => 'far fa-bookmark',
3566 'library' => 'fa-regular',
3567 ],
3568 ];
3569
3570 $icon_index = 0;
3571 foreach ($terms as $term) {
3572 $default_icon = isset($default_icons[$icon_index]) ? $default_icons[$icon_index] : [
3573 'value' => 'fas fa-file',
3574 'library' => 'fa-solid',
3575 ];
3576
3577 // Category heading
3578 $this->add_control(
3579 'kng_dynamic_posts_' . $term->slug . '_heading',
3580 [
3581 'label' => sprintf(esc_html__('%s Settings', 'king-addons'), $term->name),
3582 'type' => Controls_Manager::HEADING,
3583 'separator' => 'before',
3584 ]
3585 );
3586
3587 // Icon type for this category
3588 $this->add_control(
3589 'kng_dynamic_posts_icon_type_' . $term->slug,
3590 [
3591 'label' => sprintf(esc_html__('%s Type', 'king-addons'), $term->name),
3592 'type' => Controls_Manager::SELECT,
3593 'options' => [
3594 'icon' => esc_html__('Icon', 'king-addons'),
3595 'image' => esc_html__('Image', 'king-addons'),
3596 ],
3597 'default' => 'icon',
3598 ]
3599 );
3600
3601 // Icon control
3602 $this->add_control(
3603 'kng_dynamic_posts_icon_' . $term->slug,
3604 [
3605 'label' => sprintf(esc_html__('%s Icon', 'king-addons'), $term->name),
3606 'type' => Controls_Manager::ICONS,
3607 'default' => $default_icon,
3608 'condition' => [
3609 'kng_dynamic_posts_icon_type_' . $term->slug => 'icon',
3610 ],
3611 ]
3612 );
3613
3614 // Image control
3615 $this->add_control(
3616 'kng_dynamic_posts_image_' . $term->slug,
3617 [
3618 'label' => sprintf(esc_html__('%s Image', 'king-addons'), $term->name),
3619 'type' => Controls_Manager::MEDIA,
3620 'media_types' => ['image'],
3621 'default' => [
3622 'url' => '',
3623 ],
3624 'condition' => [
3625 'kng_dynamic_posts_icon_type_' . $term->slug => 'image',
3626 ],
3627 ]
3628 );
3629
3630 $icon_index++;
3631 if ($icon_index >= count($default_icons)) {
3632 $icon_index = 0; // Reset to cycle through icons
3633 }
3634 }
3635 }
3636
3637 /**
3638 * Add dynamic category CTA controls.
3639 */
3640 protected function add_dynamic_category_ctas(): void
3641 {
3642 // Get taxonomy from filter settings (default to category)
3643 $taxonomy = 'category';
3644
3645 // Get terms from the taxonomy
3646 $terms = get_terms([
3647 'taxonomy' => $taxonomy,
3648 'hide_empty' => false,
3649 'number' => 20, // Limit to prevent too many controls
3650 ]);
3651
3652 if (is_wp_error($terms) || empty($terms)) {
3653 // Fallback to default CTA if no terms found
3654 $this->add_control(
3655 'kng_dynamic_posts_default_cta',
3656 [
3657 'label' => esc_html__('Default CTA Text', 'king-addons'),
3658 'type' => Controls_Manager::TEXT,
3659 'default' => 'READ MORE',
3660 'description' => esc_html__('Default CTA text for posts without categories', 'king-addons'),
3661 ]
3662 );
3663 return;
3664 }
3665
3666 // Add instruction
3667 $this->add_control(
3668 'kng_dynamic_posts_ctas_info',
3669 [
3670 'type' => Controls_Manager::RAW_HTML,
3671 'raw' => esc_html__('Set custom CTA button text for each category. Leave empty to use smart defaults.', 'king-addons'),
3672 'content_classes' => 'elementor-panel-alert elementor-panel-alert-info',
3673 ]
3674 );
3675
3676 // Default CTA for uncategorized posts
3677 $this->add_control(
3678 'kng_dynamic_posts_default_cta',
3679 [
3680 'label' => esc_html__('Default CTA Text', 'king-addons'),
3681 'type' => Controls_Manager::TEXT,
3682 'default' => 'READ MORE',
3683 'description' => esc_html__('CTA text for posts without categories', 'king-addons'),
3684 ]
3685 );
3686
3687 // Add CTA control for each term
3688 $default_ctas = [
3689 'READ MORE',
3690 'LEARN MORE',
3691 'WATCH NOW',
3692 'DISCOVER',
3693 'EXPLORE',
3694 'VIEW MORE',
3695 'GET STARTED',
3696 'DOWNLOAD',
3697 ];
3698
3699 $cta_index = 0;
3700 foreach ($terms as $term) {
3701 $default_cta = isset($default_ctas[$cta_index]) ? $default_ctas[$cta_index] : 'READ MORE';
3702
3703 $this->add_control(
3704 'kng_dynamic_posts_cta_' . $term->slug,
3705 [
3706 'label' => sprintf(esc_html__('%s CTA Text', 'king-addons'), $term->name),
3707 'type' => Controls_Manager::TEXT,
3708 'default' => $default_cta,
3709 'placeholder' => 'READ MORE',
3710 'description' => sprintf(esc_html__('Custom CTA text for %s category', 'king-addons'), $term->name),
3711 ]
3712 );
3713
3714 $cta_index++;
3715 if ($cta_index >= count($default_ctas)) {
3716 $cta_index = 0; // Reset to cycle through CTAs
3717 }
3718 }
3719 }
3720
3721 /**
3722 * Add dynamic category button color controls.
3723 */
3724 protected function add_dynamic_category_button_colors(): void
3725 {
3726 // Get taxonomy from filter settings (default to category)
3727 $taxonomy = 'category';
3728
3729 // Get terms from the taxonomy
3730 $terms = get_terms([
3731 'taxonomy' => $taxonomy,
3732 'hide_empty' => false,
3733 'number' => 20, // Limit to prevent too many controls
3734 ]);
3735
3736 if (is_wp_error($terms) || empty($terms)) {
3737 // Fallback to default button colors if no terms found
3738 $this->add_control(
3739 'kng_dynamic_posts_button_color',
3740 [
3741 'label' => esc_html__('Button Color', 'king-addons'),
3742 'type' => Controls_Manager::COLOR,
3743 'default' => '#374151',
3744 'selectors' => [
3745 '{{WRAPPER}} .king-addons-dpg-button' => 'color: {{VALUE}};',
3746 ],
3747 ]
3748 );
3749
3750 $this->add_control(
3751 'kng_dynamic_posts_button_background',
3752 [
3753 'label' => esc_html__('Button Background', 'king-addons'),
3754 'type' => Controls_Manager::COLOR,
3755 'default' => 'rgba(255, 255, 255, 0.8)',
3756 'selectors' => [
3757 '{{WRAPPER}} .king-addons-dpg-button' => 'background-color: {{VALUE}};',
3758 ],
3759 ]
3760 );
3761
3762 $this->add_control(
3763 'kng_dynamic_posts_button_hover_color',
3764 [
3765 'label' => esc_html__('Button Hover Color', 'king-addons'),
3766 'type' => Controls_Manager::COLOR,
3767 'default' => '#1F2937',
3768 'selectors' => [
3769 '{{WRAPPER}} .king-addons-dpg-button:hover' => 'color: {{VALUE}};',
3770 ],
3771 ]
3772 );
3773
3774 $this->add_control(
3775 'kng_dynamic_posts_button_hover_background',
3776 [
3777 'label' => esc_html__('Button Hover Background', 'king-addons'),
3778 'type' => Controls_Manager::COLOR,
3779 'default' => 'rgba(255, 255, 255, 0.95)',
3780 'selectors' => [
3781 '{{WRAPPER}} .king-addons-dpg-button:hover' => 'background-color: {{VALUE}};',
3782 ],
3783 ]
3784 );
3785
3786 $this->add_control(
3787 'kng_dynamic_posts_button_border_color',
3788 [
3789 'label' => esc_html__('Button Border Color', 'king-addons'),
3790 'type' => Controls_Manager::COLOR,
3791 'default' => 'rgba(0, 0, 0, 0.1)',
3792 'selectors' => [
3793 '{{WRAPPER}} .king-addons-dpg-button' => 'border-color: {{VALUE}};',
3794 ],
3795 ]
3796 );
3797 return;
3798 }
3799
3800 // Add instruction
3801 $this->add_control(
3802 'kng_dynamic_posts_button_colors_info',
3803 [
3804 'type' => Controls_Manager::RAW_HTML,
3805 'raw' => esc_html__('Set custom button colors for each category. These colors will override the general button style.', 'king-addons'),
3806 'content_classes' => 'elementor-panel-alert elementor-panel-alert-info',
3807 ]
3808 );
3809
3810 // Default colors for uncategorized posts
3811 $this->add_control(
3812 'kng_dynamic_posts_default_button_heading',
3813 [
3814 'label' => esc_html__('Default Button Colors', 'king-addons'),
3815 'type' => Controls_Manager::HEADING,
3816 'separator' => 'before',
3817 ]
3818 );
3819
3820 $this->add_control(
3821 'kng_dynamic_posts_default_button_color',
3822 [
3823 'label' => esc_html__('Default Button Color', 'king-addons'),
3824 'type' => Controls_Manager::COLOR,
3825 'default' => '#374151',
3826 'selectors' => [
3827 '{{WRAPPER}} .king-addons-dpg-button' => 'color: {{VALUE}};',
3828 ],
3829 ]
3830 );
3831
3832 $this->add_control(
3833 'kng_dynamic_posts_default_button_background',
3834 [
3835 'label' => esc_html__('Default Button Background', 'king-addons'),
3836 'type' => Controls_Manager::COLOR,
3837 'default' => 'rgba(255, 255, 255, 0.8)',
3838 'selectors' => [
3839 '{{WRAPPER}} .king-addons-dpg-button' => 'background-color: {{VALUE}};',
3840 ],
3841 ]
3842 );
3843
3844 $this->add_control(
3845 'kng_dynamic_posts_default_button_hover_color',
3846 [
3847 'label' => esc_html__('Default Button Hover Color', 'king-addons'),
3848 'type' => Controls_Manager::COLOR,
3849 'default' => '#1F2937',
3850 'selectors' => [
3851 '{{WRAPPER}} .king-addons-dpg-button:hover' => 'color: {{VALUE}};',
3852 ],
3853 ]
3854 );
3855
3856 $this->add_control(
3857 'kng_dynamic_posts_default_button_hover_background',
3858 [
3859 'label' => esc_html__('Default Button Hover Background', 'king-addons'),
3860 'type' => Controls_Manager::COLOR,
3861 'default' => 'rgba(255, 255, 255, 0.95)',
3862 'selectors' => [
3863 '{{WRAPPER}} .king-addons-dpg-button:hover' => 'background-color: {{VALUE}};',
3864 ],
3865 ]
3866 );
3867
3868 $this->add_control(
3869 'kng_dynamic_posts_default_button_border_color',
3870 [
3871 'label' => esc_html__('Default Button Border Color', 'king-addons'),
3872 'type' => Controls_Manager::COLOR,
3873 'default' => 'rgba(0, 0, 0, 0.1)',
3874 'selectors' => [
3875 '{{WRAPPER}} .king-addons-dpg-button' => 'border-color: {{VALUE}};',
3876 ],
3877 ]
3878 );
3879
3880 // Category-specific colors
3881 $default_colors = [
3882 ['color' => '#FFFFFF', 'bg' => '#EF4444', 'hover_color' => '#FFFFFF', 'hover_bg' => '#DC2626', 'border' => '#EF4444'], // Red
3883 ['color' => '#FFFFFF', 'bg' => '#3B82F6', 'hover_color' => '#FFFFFF', 'hover_bg' => '#2563EB', 'border' => '#3B82F6'], // Blue
3884 ['color' => '#FFFFFF', 'bg' => '#10B981', 'hover_color' => '#FFFFFF', 'hover_bg' => '#059669', 'border' => '#10B981'], // Green
3885 ['color' => '#FFFFFF', 'bg' => '#F59E0B', 'hover_color' => '#FFFFFF', 'hover_bg' => '#D97706', 'border' => '#F59E0B'], // Orange
3886 ['color' => '#FFFFFF', 'bg' => '#8B5CF6', 'hover_color' => '#FFFFFF', 'hover_bg' => '#7C3AED', 'border' => '#8B5CF6'], // Purple
3887 ['color' => '#FFFFFF', 'bg' => '#EC4899', 'hover_color' => '#FFFFFF', 'hover_bg' => '#DB2777', 'border' => '#EC4899'], // Pink
3888 ['color' => '#FFFFFF', 'bg' => '#06B6D4', 'hover_color' => '#FFFFFF', 'hover_bg' => '#0891B2', 'border' => '#06B6D4'], // Cyan
3889 ['color' => '#FFFFFF', 'bg' => '#84CC16', 'hover_color' => '#FFFFFF', 'hover_bg' => '#65A30D', 'border' => '#84CC16'], // Lime
3890 ];
3891
3892 $color_index = 0;
3893 foreach ($terms as $term) {
3894 $default_color_set = isset($default_colors[$color_index]) ? $default_colors[$color_index] : $default_colors[0];
3895
3896 // Category heading
3897 $this->add_control(
3898 'kng_dynamic_posts_' . $term->slug . '_button_heading',
3899 [
3900 'label' => sprintf(esc_html__('%s Button Colors', 'king-addons'), $term->name),
3901 'type' => Controls_Manager::HEADING,
3902 'separator' => 'before',
3903 ]
3904 );
3905
3906 // Button color
3907 $this->add_control(
3908 'kng_dynamic_posts_button_color_' . $term->slug,
3909 [
3910 'label' => sprintf(esc_html__('%s Button Text Color', 'king-addons'), $term->name),
3911 'type' => Controls_Manager::COLOR,
3912 'default' => $default_color_set['color'],
3913 'selectors' => [
3914 '{{WRAPPER}} .king-addons-dpg-card.king-addons-dpg-category-' . $term->slug . ' .king-addons-dpg-button' => 'color: {{VALUE}};',
3915 ],
3916 ]
3917 );
3918
3919 // Button background
3920 $this->add_control(
3921 'kng_dynamic_posts_button_background_' . $term->slug,
3922 [
3923 'label' => sprintf(esc_html__('%s Button Background', 'king-addons'), $term->name),
3924 'type' => Controls_Manager::COLOR,
3925 'default' => $default_color_set['bg'],
3926 'selectors' => [
3927 '{{WRAPPER}} .king-addons-dpg-card.king-addons-dpg-category-' . $term->slug . ' .king-addons-dpg-button' => 'background-color: {{VALUE}};',
3928 ],
3929 ]
3930 );
3931
3932 // Button hover color
3933 $this->add_control(
3934 'kng_dynamic_posts_button_hover_color_' . $term->slug,
3935 [
3936 'label' => sprintf(esc_html__('%s Button Hover Color', 'king-addons'), $term->name),
3937 'type' => Controls_Manager::COLOR,
3938 'default' => $default_color_set['hover_color'],
3939 'selectors' => [
3940 '{{WRAPPER}} .king-addons-dpg-card.king-addons-dpg-category-' . $term->slug . ' .king-addons-dpg-button:hover' => 'color: {{VALUE}};',
3941 ],
3942 ]
3943 );
3944
3945 // Button hover background
3946 $this->add_control(
3947 'kng_dynamic_posts_button_hover_background_' . $term->slug,
3948 [
3949 'label' => sprintf(esc_html__('%s Button Hover Background', 'king-addons'), $term->name),
3950 'type' => Controls_Manager::COLOR,
3951 'default' => $default_color_set['hover_bg'],
3952 'selectors' => [
3953 '{{WRAPPER}} .king-addons-dpg-card.king-addons-dpg-category-' . $term->slug . ' .king-addons-dpg-button:hover' => 'background-color: {{VALUE}};',
3954 ],
3955 ]
3956 );
3957
3958 // Button border color
3959 $this->add_control(
3960 'kng_dynamic_posts_button_border_color_' . $term->slug,
3961 [
3962 'label' => sprintf(esc_html__('%s Button Border Color', 'king-addons'), $term->name),
3963 'type' => Controls_Manager::COLOR,
3964 'default' => $default_color_set['border'],
3965 'selectors' => [
3966 '{{WRAPPER}} .king-addons-dpg-card.king-addons-dpg-category-' . $term->slug . ' .king-addons-dpg-button' => 'border-color: {{VALUE}};',
3967 ],
3968 ]
3969 );
3970
3971 $color_index++;
3972 if ($color_index >= count($default_colors)) {
3973 $color_index = 0; // Reset to cycle through colors
3974 }
3975 }
3976 }
3977
3978 /**
3979 * Get post category for display.
3980 *
3981 * @param object $post Post object.
3982 * @return string Post category display name.
3983 */
3984 private function get_post_type_display($post): string
3985 {
3986 // Get post categories
3987 $taxonomy = 'category';
3988 $terms = get_the_terms($post->ID, $taxonomy);
3989
3990 if ($terms && !is_wp_error($terms)) {
3991 // Use first category name
3992 $term = $terms[0];
3993 return strtoupper($term->name);
3994 }
3995
3996 // Fallback to post format/type based display
3997 $format = get_post_format($post->ID);
3998
3999 if ($format === 'video') {
4000 return 'VIDEO';
4001 } elseif ($format === 'audio') {
4002 return 'PUBLICATION';
4003 } elseif ($post->post_type === 'page') {
4004 return 'WEBSITE';
4005 } else {
4006 return 'POST';
4007 }
4008 }
4009
4010 /**
4011 * Get CTA button text based on category settings.
4012 *
4013 * @param object $post Post object.
4014 * @param array $settings Widget settings.
4015 * @return string CTA button text.
4016 */
4017 private function get_cta_text($post, $settings): string
4018 {
4019 // Get post categories for custom CTA text
4020 $taxonomy = 'category';
4021 $terms = get_the_terms($post->ID, $taxonomy);
4022
4023 if ($terms && !is_wp_error($terms)) {
4024 // Use first category's custom CTA
4025 $term = $terms[0];
4026 $cta_setting = $settings['kng_dynamic_posts_cta_' . $term->slug] ?? '';
4027
4028 if (!empty($cta_setting)) {
4029 return strtoupper(trim($cta_setting));
4030 }
4031 }
4032
4033 // Fallback to default CTA or smart detection
4034 $default_cta = $settings['kng_dynamic_posts_default_cta'] ?? '';
4035 if (!empty($default_cta)) {
4036 return strtoupper(trim($default_cta));
4037 }
4038
4039 // Final fallback - smart detection
4040 if ($terms && !is_wp_error($terms)) {
4041 $term = $terms[0];
4042 $slug = strtolower($term->slug);
4043
4044 $smart_cta_map = [
4045 'video' => 'WATCH NOW',
4046 'videos' => 'WATCH NOW',
4047 'website' => 'LEARN MORE',
4048 'websites' => 'LEARN MORE',
4049 ];
4050
4051 if (isset($smart_cta_map[$slug])) {
4052 return $smart_cta_map[$slug];
4053 }
4054 }
4055
4056 return 'READ MORE';
4057 }
4058
4059 /**
4060 * Get post category color classes.
4061 *
4062 * @param object $post Post object.
4063 * @param array $settings Widget settings.
4064 * @return string Color class names.
4065 */
4066 private function get_post_category_color_classes($post, $settings): string
4067 {
4068 $classes = [];
4069 $taxonomy = $settings['kng_dynamic_posts_filter_taxonomy'] ?? 'category';
4070
4071 // Get post categories/terms
4072 $terms = get_the_terms($post->ID, $taxonomy);
4073
4074 if ($terms && !is_wp_error($terms)) {
4075 foreach ($terms as $term) {
4076 $classes[] = 'filter-' . $term->slug;
4077 $classes[] = 'king-addons-dpg-category-' . $term->slug;
4078 }
4079 }
4080
4081 // Add default class if no terms
4082 if (empty($classes)) {
4083 $classes[] = 'king-addons-dpg-category-default';
4084 }
4085
4086 return implode(' ', $classes);
4087 }
4088
4089 /**
4090 * Get post type icon based on category settings.
4091 *
4092 * @param object $post Post object.
4093 * @param array $settings Widget settings.
4094 * @return string Icon HTML.
4095 */
4096 private function get_post_type_icon($post, $settings): string
4097 {
4098 // Get post categories/terms
4099 $taxonomy = 'category';
4100 $terms = get_the_terms($post->ID, $taxonomy);
4101
4102 if ($terms && !is_wp_error($terms)) {
4103 // Use first category's icon/image
4104 $term = $terms[0];
4105 $icon_type = $settings['kng_dynamic_posts_icon_type_' . $term->slug] ?? 'icon';
4106
4107 if ($icon_type === 'image') {
4108 // Use image
4109 $image_setting = $settings['kng_dynamic_posts_image_' . $term->slug] ?? null;
4110 if ($image_setting && !empty($image_setting['url'])) {
4111 return '<img src="' . esc_url($image_setting['url']) . '" alt="' . esc_attr($term->name) . '" class="category-image" />';
4112 }
4113 } else {
4114 // Use icon
4115 $icon_setting = $settings['kng_dynamic_posts_icon_' . $term->slug] ?? null;
4116 if ($icon_setting && !empty($icon_setting['value'])) {
4117 // Return FontAwesome icon or SVG
4118 if (isset($icon_setting['library']) && $icon_setting['library'] === 'svg') {
4119 return $icon_setting['value']['url'] ? '<img src="' . esc_url($icon_setting['value']['url']) . '" alt="" class="category-icon" />' : '';
4120 } else {
4121 return '<i class="' . esc_attr($icon_setting['value']) . ' category-icon"></i>';
4122 }
4123 }
4124 }
4125 }
4126
4127 // Fallback to default icon/image
4128 $default_type = $settings['kng_dynamic_posts_default_icon_type'] ?? 'icon';
4129
4130 if ($default_type === 'image') {
4131 // Use default image
4132 $default_image = $settings['kng_dynamic_posts_default_image'] ?? null;
4133 if ($default_image && !empty($default_image['url'])) {
4134 return '<img src="' . esc_url($default_image['url']) . '" alt="' . esc_attr__('Default', 'king-addons') . '" class="category-image" />';
4135 }
4136 }
4137
4138 // Use default icon
4139 $default_icon = $settings['kng_dynamic_posts_default_icon'] ?? [
4140 'value' => 'far fa-file-alt',
4141 'library' => 'fa-regular',
4142 ];
4143
4144 if (isset($default_icon['library']) && $default_icon['library'] === 'svg') {
4145 return $default_icon['value']['url'] ? '<img src="' . esc_url($default_icon['value']['url']) . '" alt="" class="category-icon" />' : '';
4146 } else {
4147 return '<i class="' . esc_attr($default_icon['value']) . ' category-icon"></i>';
4148 }
4149 }
4150
4151 /**
4152 * Render widget output on the frontend.
4153 */
4154 protected function render(): void
4155 {
4156 $settings = $this->get_settings_for_display();
4157 $widget_id = $this->get_id();
4158
4159 // Query posts
4160 $query_args = [
4161 'post_type' => $settings['kng_dynamic_posts_post_types'],
4162 'posts_per_page' => $settings['kng_dynamic_posts_per_page'],
4163 'orderby' => $settings['kng_dynamic_posts_orderby'],
4164 'order' => $settings['kng_dynamic_posts_order'],
4165 'post_status' => 'publish',
4166 ];
4167
4168 $posts_query = new \WP_Query($query_args);
4169
4170 // Get filter terms if filtering is enabled
4171 $filter_terms = [];
4172 if ($settings['kng_dynamic_posts_enable_filters'] === 'yes') {
4173 $taxonomy = $settings['kng_dynamic_posts_filter_taxonomy'];
4174 $filter_terms = get_terms([
4175 'taxonomy' => $taxonomy,
4176 'hide_empty' => true,
4177 ]);
4178 }
4179
4180 // Wrapper attributes
4181 $this->add_render_attribute('wrapper', 'class', 'king-addons-dpg-wrapper');
4182 $this->add_render_attribute('wrapper', 'data-widget-id', $widget_id);
4183 $this->add_render_attribute('wrapper', 'data-widget-mode', 'default'); // Set default mode for Free version
4184 $this->add_render_attribute('wrapper', 'data-posts-per-page', $settings['kng_dynamic_posts_per_page']);
4185 $this->add_render_attribute('wrapper', 'data-post-types', wp_json_encode($settings['kng_dynamic_posts_post_types']));
4186 $this->add_render_attribute('wrapper', 'data-orderby', $settings['kng_dynamic_posts_orderby']);
4187 $this->add_render_attribute('wrapper', 'data-order', $settings['kng_dynamic_posts_order']);
4188 $this->add_render_attribute('wrapper', 'data-show-excerpt', ($settings['kng_dynamic_posts_show_excerpt'] ?? 'yes') === 'yes' ? '1' : '0');
4189 $this->add_render_attribute('wrapper', 'data-card-clickable', ($settings['kng_dynamic_posts_card_clickable'] ?? 'no') === 'yes' ? '1' : '0');
4190
4191 if ($settings['kng_dynamic_posts_enable_filters'] === 'yes') {
4192 $this->add_render_attribute('wrapper', 'data-filter-taxonomy', $settings['kng_dynamic_posts_filter_taxonomy']);
4193 }
4194
4195 // CPT-related attributes (empty for Free version, but needed for JS compatibility)
4196 $this->add_render_attribute('wrapper', 'data-cpt-actions', '');
4197 $this->add_render_attribute('wrapper', 'data-cpt-icons', '');
4198 ?>
4199
4200 <div <?php echo $this->get_render_attribute_string('wrapper'); ?>>
4201
4202 <?php if ($settings['kng_dynamic_posts_enable_filters'] === 'yes' || $settings['kng_dynamic_posts_enable_search'] === 'yes'): ?>
4203 <!-- Filter Bar -->
4204 <div class="king-addons-dpg-filter-bar">
4205
4206 <!-- Filter Header -->
4207 <div class="king-addons-dpg-filter-header">
4208 <h2 class="king-addons-dpg-filter-title"><?php echo esc_html($settings['kng_dynamic_posts_filter_title_text']); ?></h2>
4209 </div>
4210
4211 <!-- Filter Controls -->
4212 <div class="king-addons-dpg-filter-controls">
4213 <?php if ($settings['kng_dynamic_posts_enable_filters'] === 'yes' && !empty($filter_terms)): ?>
4214 <!-- Filter Dropdown -->
4215 <div class="king-addons-dpg-filter-dropdown<?php
4216 $has_custom = !empty($settings['kng_dynamic_posts_filter_dropdown_use_custom']) && $settings['kng_dynamic_posts_filter_dropdown_use_custom'] === 'yes';
4217 $has_icon = $has_custom && $settings['kng_dynamic_posts_filter_dropdown_type'] === 'icon' && !empty($settings['kng_dynamic_posts_filter_dropdown_custom_icon']['value']);
4218 $has_image = $has_custom && $settings['kng_dynamic_posts_filter_dropdown_type'] === 'image' && !empty($settings['kng_dynamic_posts_filter_dropdown_custom_image']['url']);
4219 echo ($has_custom && ($has_icon || $has_image)) ? ' has-custom-icon' : '';
4220 ?>">
4221 <select class="king-addons-dpg-posts-filter" data-taxonomy="<?php echo esc_attr($settings['kng_dynamic_posts_filter_taxonomy']); ?>">
4222 <option value="*"><?php echo esc_html__('All resources types', 'king-addons'); ?></option>
4223 <?php foreach ($filter_terms as $term): ?>
4224 <option value="<?php echo esc_attr($term->slug); ?>"><?php echo esc_html($term->name); ?></option>
4225 <?php endforeach; ?>
4226 </select>
4227 <?php if ($has_icon): ?>
4228 <span class="dropdown-icon">
4229 <?php \Elementor\Icons_Manager::render_icon($settings['kng_dynamic_posts_filter_dropdown_custom_icon'], ['class' => 'dropdown-custom-icon']); ?>
4230 </span>
4231 <?php elseif ($has_image): ?>
4232 <span class="dropdown-image">
4233 <img src="<?php echo esc_url($settings['kng_dynamic_posts_filter_dropdown_custom_image']['url']); ?>" alt="<?php echo esc_attr__('Dropdown icon', 'king-addons'); ?>" />
4234 </span>
4235 <?php endif; ?>
4236 </div>
4237 <?php endif; ?>
4238
4239 <?php if ($settings['kng_dynamic_posts_enable_search'] === 'yes'): ?>
4240 <!-- Search Input -->
4241 <div class="king-addons-dpg-search-input">
4242 <input type="text" class="king-addons-dpg-posts-search" placeholder="<?php echo esc_attr($settings['kng_dynamic_posts_search_placeholder']); ?>">
4243 <button class="king-addons-dpg-search-btn" type="button">
4244 <?php if (!empty($settings['kng_dynamic_posts_search_use_custom_icon']) && $settings['kng_dynamic_posts_search_use_custom_icon'] === 'yes' && !empty($settings['kng_dynamic_posts_search_custom_icon']['value'])): ?>
4245 <?php \Elementor\Icons_Manager::render_icon($settings['kng_dynamic_posts_search_custom_icon'], ['class' => 'king-addons-dpg-search-custom-icon']); ?>
4246 <?php else: ?>
4247 <svg width="20" height="20" viewBox="0 0 24 24">
4248 <path d="M15.5 14h-.79l-.28-.27C15.41 12.59 16 11.11 16 9.5 16 5.91 13.09 3 9.5 3S3 5.91 3 9.5 5.91 16 9.5 16c1.61 0 3.09-.59 4.23-1.57l.27.28v.79l5 4.99L20.49 19l-4.99-5zm-6 0C7.01 14 5 11.99 5 9.5S7.01 5 9.5 5 14 7.01 14 9.5 11.99 14 9.5 14z" />
4249 </svg>
4250 <?php endif; ?>
4251 </button>
4252 </div>
4253 <?php endif; ?>
4254 </div>
4255
4256 </div>
4257 <?php endif; ?>
4258
4259 <!-- Grid Container -->
4260 <div class="king-addons-dpg-grid" data-columns="<?php echo esc_attr($settings['kng_dynamic_posts_columns']); ?>">
4261 <?php $this->render_posts($posts_query, $settings); ?>
4262 </div>
4263
4264 <?php if ($settings['kng_dynamic_posts_enable_load_more'] === 'yes'): ?>
4265 <!-- Load More Section -->
4266 <div class="king-addons-dpg-pagination">
4267
4268 <!-- Posts Count Info -->
4269 <div class="king-addons-dpg-pagination-info">
4270 <?php echo esc_html__('Showing', 'king-addons'); ?> <span class="king-addons-dpg-current-count"><?php echo $posts_query->post_count; ?></span> <?php echo esc_html__('of', 'king-addons'); ?> <span class="king-addons-dpg-total-count"><?php echo $posts_query->found_posts; ?></span> <?php echo esc_html__('items', 'king-addons'); ?>
4271 </div>
4272
4273 <div class="king-addons-dpg-pagination-loading" style="display: none;">
4274 <?php echo esc_html($settings['kng_dynamic_posts_loading_text']); ?>
4275 </div>
4276
4277 <?php if ($posts_query->max_num_pages > 1): ?>
4278 <button class="king-addons-dpg-load-more-btn" data-page="1" data-max-pages="<?php echo esc_attr($posts_query->max_num_pages); ?>">
4279 <?php echo esc_html($settings['kng_dynamic_posts_load_more_text']); ?>
4280 </button>
4281 <?php endif; ?>
4282
4283 <div class="king-addons-dpg-pagination-finish" style="display: none;">
4284 <?php echo esc_html__('All items loaded', 'king-addons'); ?>
4285 </div>
4286 </div>
4287 <?php endif; ?>
4288
4289 </div>
4290
4291 <?php
4292 wp_reset_postdata();
4293 }
4294
4295 /**
4296 * Render posts grid.
4297 *
4298 * @param \WP_Query $posts_query Posts query object.
4299 * @param array $settings Widget settings.
4300 */
4301 private function render_posts($posts_query, $settings): void
4302 {
4303 if (!$posts_query->have_posts()) {
4304 echo '<div class="king-addons-dpg-no-posts">' . esc_html__('No posts found.', 'king-addons') . '</div>';
4305 return;
4306 }
4307
4308 while ($posts_query->have_posts()):
4309 $posts_query->the_post();
4310 $post = get_post();
4311 $post_type_display = $this->get_post_type_display($post);
4312 $category_classes = $this->get_post_category_color_classes($post, $settings);
4313 $cta_text = $this->get_cta_text($post, $settings);
4314 $post_icon = $this->get_post_type_icon($post, $settings);
4315 ?>
4316
4317 <div class="king-addons-dpg-card king-addons-dpg-item <?php echo esc_attr($category_classes); ?>" data-post-id="<?php echo esc_attr($post->ID); ?>">
4318
4319 <!-- Post Type Header -->
4320 <div class="king-addons-dpg-header">
4321 <div class="king-addons-dpg-icon">
4322 <?php echo $post_icon; ?>
4323 </div>
4324 <div class="king-addons-dpg-label">
4325 <?php echo esc_html($post_type_display); ?>
4326 </div>
4327 </div>
4328
4329 <!-- Post Content -->
4330 <div class="king-addons-dpg-content">
4331 <h3 class="king-addons-dpg-title">
4332 <a href="<?php echo esc_url(get_permalink()); ?>">
4333 <?php echo esc_html(get_the_title()); ?>
4334 </a>
4335 </h3>
4336
4337 <?php if (($settings['kng_dynamic_posts_show_excerpt'] ?? 'yes') === 'yes'): ?>
4338 <div class="king-addons-dpg-excerpt">
4339 <?php echo esc_html(wp_trim_words(get_the_excerpt(), 20, '...')); ?>
4340 </div>
4341 <?php endif; ?>
4342 </div>
4343
4344 <!-- CTA Button -->
4345 <div class="king-addons-dpg-cta">
4346 <?php echo $this->get_cta_button_html($post, $settings, $cta_text); ?>
4347 </div>
4348
4349 </div>
4350
4351 <?php
4352 endwhile;
4353 }
4354
4355 /**
4356 * Build WP_Query args. Pro overrides to support Custom CPT mode.
4357 *
4358 * @param array $settings Widget settings.
4359 * @return array
4360 */
4361 protected function build_query_args(array $settings): array
4362 {
4363 return [
4364 'post_type' => $settings['kng_dynamic_posts_post_types'],
4365 'posts_per_page' => $settings['kng_dynamic_posts_per_page'],
4366 'orderby' => $settings['kng_dynamic_posts_orderby'],
4367 'order' => $settings['kng_dynamic_posts_order'],
4368 'post_status' => 'publish',
4369 ];
4370 }
4371
4372 /**
4373 * Build filter terms data for filter bar. Pro overrides for CPT/tabs.
4374 *
4375 * @param array $settings Widget settings.
4376 * @return array
4377 */
4378 protected function get_filter_terms(array $settings): array
4379 {
4380 if (($settings['kng_dynamic_posts_enable_filters'] ?? '') !== 'yes') {
4381 return [];
4382 }
4383
4384 $taxonomy = $settings['kng_dynamic_posts_filter_taxonomy'] ?? 'category';
4385 $terms = get_terms([
4386 'taxonomy' => $taxonomy,
4387 'hide_empty' => true,
4388 ]);
4389
4390 return is_wp_error($terms) ? [] : $terms;
4391 }
4392
4393 /**
4394 * Render filter bar wrapper. Pro overrides for advanced UI.
4395 *
4396 * @param array $settings Widget settings.
4397 * @param array $filter_terms Terms list or structured data.
4398 */
4399 protected function render_filter_bar(array $settings, array $filter_terms): void
4400 {
4401 if (($settings['kng_dynamic_posts_enable_filters'] ?? '') !== 'yes' && ($settings['kng_dynamic_posts_enable_search'] ?? '') !== 'yes') {
4402 return;
4403 }
4404 ?>
4405 <div class="king-addons-dpg-filter-bar">
4406 <div class="king-addons-dpg-filter-header">
4407 <h2 class="king-addons-dpg-filter-title"><?php echo esc_html($settings['kng_dynamic_posts_filter_title_text'] ?? ''); ?></h2>
4408 </div>
4409
4410 <div class="king-addons-dpg-filter-controls">
4411 <?php if (($settings['kng_dynamic_posts_enable_filters'] ?? '') === 'yes' && !empty($filter_terms)): ?>
4412 <div class="king-addons-dpg-filter-dropdown<?php
4413 $has_custom = !empty($settings['kng_dynamic_posts_filter_dropdown_use_custom']) && $settings['kng_dynamic_posts_filter_dropdown_use_custom'] === 'yes';
4414 $has_icon = $has_custom && ($settings['kng_dynamic_posts_filter_dropdown_type'] ?? 'icon') === 'icon' && !empty($settings['kng_dynamic_posts_filter_dropdown_custom_icon']['value'] ?? '');
4415 $has_image = $has_custom && ($settings['kng_dynamic_posts_filter_dropdown_type'] ?? 'icon') === 'image' && !empty($settings['kng_dynamic_posts_filter_dropdown_custom_image']['url'] ?? '');
4416 echo ($has_custom && ($has_icon || $has_image)) ? ' has-custom-icon' : '';
4417 ?>">
4418 <select class="king-addons-dpg-posts-filter" data-taxonomy="<?php echo esc_attr($settings['kng_dynamic_posts_filter_taxonomy'] ?? 'category'); ?>">
4419 <option value="*">&nbsp;<?php echo esc_html__('All resources types', 'king-addons'); ?></option>
4420 <?php foreach ($filter_terms as $term): ?>
4421 <option value="<?php echo esc_attr($term->slug); ?>"><?php echo esc_html($term->name); ?></option>
4422 <?php endforeach; ?>
4423 </select>
4424 <?php if ($has_icon): ?>
4425 <span class="dropdown-icon">
4426 <?php \Elementor\Icons_Manager::render_icon($settings['kng_dynamic_posts_filter_dropdown_custom_icon'], ['class' => 'dropdown-custom-icon']); ?>
4427 </span>
4428 <?php elseif ($has_image): ?>
4429 <span class="dropdown-image">
4430 <img src="<?php echo esc_url($settings['kng_dynamic_posts_filter_dropdown_custom_image']['url']); ?>" alt="<?php echo esc_attr__('Dropdown icon', 'king-addons'); ?>" />
4431 </span>
4432 <?php endif; ?>
4433 </div>
4434 <?php endif; ?>
4435
4436 <?php if (($settings['kng_dynamic_posts_enable_search'] ?? '') === 'yes'): ?>
4437 <div class="king-addons-dpg-search-input">
4438 <input type="text" class="king-addons-dpg-posts-search" placeholder="<?php echo esc_attr($settings['kng_dynamic_posts_search_placeholder'] ?? ''); ?>">
4439 <button class="king-addons-dpg-search-btn" type="button">
4440 <?php if (!empty($settings['kng_dynamic_posts_search_use_custom_icon']) && $settings['kng_dynamic_posts_search_use_custom_icon'] === 'yes' && !empty($settings['kng_dynamic_posts_search_custom_icon']['value'] ?? '')): ?>
4441 <?php \Elementor\Icons_Manager::render_icon($settings['kng_dynamic_posts_search_custom_icon'], ['class' => 'king-addons-dpg-search-custom-icon']); ?>
4442 <?php else: ?>
4443 <svg width="20" height="20" viewBox="0 0 24 24"><path d="M15.5 14h-.79l-.28-.27C15.41 12.59 16 11.11 16 9.5 16 5.91 13.09 3 9.5 3S3 5.91 3 9.5 5.91 16 9.5 16c1.61 0 3.09-.59 4.23-1.57l.27.28v.79l5 4.99L20.49 19l-4.99-5zm-6 0C7.01 14 5 11.99 5 9.5S7.01 5 9.5 5 14 7.01 14 9.5 11.99 14 9.5 14z" /></svg>
4444 <?php endif; ?>
4445 </button>
4446 </div>
4447 <?php endif; ?>
4448 </div>
4449 </div>
4450 <?php
4451 }
4452
4453 /**
4454 * Render pagination wrapper. Pro overrides for advanced types.
4455 *
4456 * @param array $settings
4457 * @param \WP_Query $posts_query
4458 */
4459 protected function render_pagination(array $settings, \WP_Query $posts_query): void
4460 {
4461 if (($settings['kng_dynamic_posts_enable_load_more'] ?? '') !== 'yes') {
4462 return;
4463 }
4464 ?>
4465 <div class="king-addons-dpg-pagination">
4466 <div class="king-addons-dpg-pagination-info">
4467 <?php echo esc_html__('Showing', 'king-addons'); ?> <span class="king-addons-dpg-current-count"><?php echo (int) $posts_query->post_count; ?></span> <?php echo esc_html__('of', 'king-addons'); ?> <span class="king-addons-dpg-total-count"><?php echo (int) $posts_query->found_posts; ?></span> <?php echo esc_html__('items', 'king-addons'); ?>
4468 </div>
4469 <div class="king-addons-dpg-pagination-loading" style="display: none;">
4470 <?php echo esc_html($settings['kng_dynamic_posts_loading_text'] ?? 'Loading...'); ?>
4471 </div>
4472 <?php if ($posts_query->max_num_pages > 1): ?>
4473 <button class="king-addons-dpg-load-more-btn" data-page="1" data-max-pages="<?php echo esc_attr($posts_query->max_num_pages); ?>">
4474 <?php echo esc_html($settings['kng_dynamic_posts_load_more_text'] ?? 'LOAD MORE'); ?>
4475 </button>
4476 <?php endif; ?>
4477 <div class="king-addons-dpg-pagination-finish" style="display: none;">
4478 <?php echo esc_html__('All items loaded', 'king-addons'); ?>
4479 </div>
4480 </div>
4481 <?php
4482 }
4483
4484 /**
4485 * Render CTA button HTML. Pro overrides to inject action button behaviors.
4486 *
4487 * @param \WP_Post $post
4488 * @param array $settings
4489 * @param string $cta_text
4490 * @return string
4491 */
4492 protected function get_cta_button_html($post, array $settings, string $cta_text): string
4493 {
4494 return '<a href="' . esc_url(get_permalink($post)) . '" class="king-addons-dpg-button">' . esc_html($cta_text) . '</a>';
4495 }
4496
4497 /**
4498 * Extension points for Pro controls (content/style). Intentionally empty in Free.
4499 */
4500 // PRO Control Methods (empty in Free, overridden in Pro)
4501 public function add_control_widget_mode() {}
4502 public function add_control_custom_post_types() {}
4503 public function add_control_pagination_type() {}
4504 public function add_control_scroll_threshold() {}
4505 public function add_control_show_meta() {}
4506 public function add_control_meta_fields() {}
4507 public function add_control_cpt_actions() {}
4508 public function add_control_cpt_colors() {}
4509 public function add_control_cpt_button_colors() {}
4510 public function add_control_cpt_ctas() {}
4511 public function add_control_cpt_icons() {}
4512 }
4513