PluginProbe
King Addons for Elementor – 100+ Elementor Widgets, 4 000+ Elementor Templates, WooCommerce Builder, Mega Menu, Popup Builder / 51.1.14
King Addons for Elementor – 100+ Elementor Widgets, 4 000+ Elementor Templates, WooCommerce Builder, Mega Menu, Popup Builder v51.1.14
51.1.87 51.1.86 51.1.84 51.1.85 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 All 41 releases
king-addons / includes / widgets / Dynamic_Posts_Grid / Dynamic_Posts_Grid.php

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

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