PluginProbe
Ultimate Post Kit – Elementor Post Grid, Post Carousel, Post Slider & Blog Layout Widgets / 4.1.8
Ultimate Post Kit – Elementor Post Grid, Post Carousel, Post Slider & Blog Layout Widgets v4.1.8
4.5.6 4.5.5 4.5.4 4.2.1 4.2.2 4.2.3 4.5.0 4.5.2 4.5.3 4.2.0 4.1.18 4.1.17 4.1.16 4.1.15 4.1.14 4.1.13 4.1.12 4.1.11 4.1.10 4.1.9 4.1.8 4.0.9 4.1.0 4.1.1 4.1.2 All 148 releases
ultimate-post-kit / modules / post-accordion / widgets / post-accordion.php

post-accordion.php in Ultimate Post Kit – Elementor Post Grid, Post Carousel, Post Slider & Blog Layout Widgets 4.1.8, at modules/post-accordion/widgets/post-accordion.php

1,257 lines 33.3 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 namespace UltimatePostKit\Modules\PostAccordion\Widgets;
4
5 use Elementor\Controls_Manager;
6 use Elementor\Group_Control_Border;
7 use Elementor\Group_Control_Box_Shadow;
8 use Elementor\Group_Control_Typography;
9 use Elementor\Group_Control_Text_Shadow;
10 use Elementor\Group_Control_Image_Size;
11 use Elementor\Group_Control_Background;
12 use UltimatePostKit\Utils;
13
14 use UltimatePostKit\Traits\Global_Widget_Controls;
15 use UltimatePostKit\Traits\Global_Widget_Functions;
16 use UltimatePostKit\Includes\Controls\GroupQuery\Group_Control_Query;
17 use WP_Query;
18
19 if (!defined('ABSPATH')) exit; // Exit if accessed directly
20
21 class Post_Accordion extends Group_Control_Query {
22
23 use Global_Widget_Controls;
24 use Global_Widget_Functions;
25
26 private $_query = null;
27
28 public function get_name() {
29 return 'upk-post-accordion';
30 }
31
32 public function get_title() {
33 return BDTUPK . esc_html__('Post Accordion', 'ultimate-post-kit');
34 }
35
36 public function get_icon() {
37 return 'upk-widget-icon upk-icon-post-accordion';
38 }
39
40 public function get_categories() {
41 return ['ultimate-post-kit'];
42 }
43
44 public function get_keywords() {
45 return ['post', 'grid', 'blog', 'recent', 'news', 'accordion'];
46 }
47
48 public function get_style_depends() {
49 if ($this->upk_is_edit_mode()) {
50 return ['upk-all-styles'];
51 } else {
52 return ['upk-font', 'upk-post-accordion'];
53 }
54 }
55
56 public function get_custom_help_url() {
57 return 'https://youtu.be/lxGeTthE_lA';
58 }
59
60 public function get_query() {
61 return $this->_query;
62 }
63
64 public function has_widget_inner_wrapper(): bool {
65 return ! \Elementor\Plugin::$instance->experiments->is_feature_active( 'e_optimized_markup' );
66 }
67
68
69 protected function register_controls() {
70 $this->start_controls_section(
71 'section_content_layout',
72 [
73 'label' => esc_html__('Layout', 'ultimate-post-kit'),
74 ]
75 );
76
77 $this->add_control(
78 'layout_style',
79 [
80 'label' => __('Layout Style', 'ultimate-post-kit'),
81 'type' => Controls_Manager::SELECT,
82 'default' => 'style-1',
83 'options' => [
84 'style-1' => 'Horizontal',
85 'style-2' => 'Vertical',
86 ],
87 ]
88 );
89
90 $this->add_control(
91 'layout_content_style',
92 [
93 'label' => __('Content Style', 'ultimate-post-kit'),
94 'type' => Controls_Manager::SELECT,
95 'default' => 'style-1',
96 'options' => [
97 'style-1' => '01',
98 'style-2' => '02',
99 ],
100 ]
101 );
102
103 $this->add_responsive_control(
104 'default_item_height',
105 [
106 'label' => esc_html__('Height(px)', 'ultimate-post-kit'),
107 'type' => Controls_Manager::SLIDER,
108 'range' => [
109 'px' => [
110 'min' => 200,
111 'max' => 1200,
112 ],
113 ],
114 'selectors' => [
115 '{{WRAPPER}} .upk-accordion-wrapper' => 'height: {{SIZE}}{{UNIT}};',
116 ],
117 ]
118 );
119
120 $this->add_responsive_control(
121 'default_item_gap',
122 [
123 'label' => esc_html__('Item Gap', 'ultimate-post-kit'),
124 'type' => Controls_Manager::SLIDER,
125 'range' => [
126 'px' => [
127 'min' => 0,
128 'max' => 50,
129 ],
130 ],
131 'selectors' => [
132 '{{WRAPPER}} .upk-accordion-wrapper' => 'gap: {{SIZE}}{{UNIT}};',
133 ],
134 ]
135 );
136
137
138 $this->add_responsive_control(
139 'default_item_expand',
140 [
141 'label' => esc_html__('Item Hover Expand', 'ultimate-post-kit'),
142 'type' => Controls_Manager::SLIDER,
143 'range' => [
144 'px' => [
145 'min' => 2,
146 'max' => 10,
147 ],
148 ],
149 'selectors' => [
150 '{{WRAPPER}} .upk-accordion-wrapper .upk-accordion-item:hover' => 'flex: {{SIZE}};',
151 ],
152 ]
153 );
154
155 $this->add_group_control(
156 Group_Control_Image_Size::get_type(),
157 [
158 'name' => 'primary_thumbnail',
159 'exclude' => ['custom'],
160 'default' => 'large',
161 ]
162 );
163
164 $this->end_controls_section();
165
166 // Query Settings
167 $this->start_controls_section(
168 'section_post_query_builder',
169 [
170 'label' => __('Query', 'ultimate-post-kit'),
171 'tab' => Controls_Manager::TAB_CONTENT,
172 ]
173 );
174
175 $this->add_control(
176 'item_limit',
177 [
178 'label' => esc_html__('Item Limit', 'ultimate-post-kit'),
179 'type' => Controls_Manager::SLIDER,
180 'range' => [
181 'px' => [
182 'min' => 1,
183 'max' => 12,
184 ],
185 ],
186 'default' => [
187 'size' => 3,
188 ],
189 'condition' => [
190 'posts_source!' => 'current_query',
191 ]
192 ]
193 );
194
195 $this->register_query_builder_controls();
196
197 $this->end_controls_section();
198
199 $this->start_controls_section(
200 'section_content_additional',
201 [
202 'label' => esc_html__('Additional Options', 'ultimate-post-kit'),
203 ]
204 );
205
206 //Global Title Controls
207 $this->register_title_controls();
208
209 $this->add_control(
210 'show_excerpt',
211 [
212 'label' => esc_html__('Show Text', 'ultimate-post-kit'),
213 'type' => Controls_Manager::SWITCHER,
214 'separator' => 'before',
215 'condition' => [
216 'layout_style' => 'style-1'
217 ],
218 ]
219
220 );
221
222 $this->add_control(
223 'excerpt_length',
224 [
225 'label' => esc_html__('Text Limit', 'ultimate-post-kit'),
226 'description' => esc_html__('It\'s just work for main content, but not working with excerpt. If you set 0 so you will get full main content.', 'ultimate-post-kit'),
227 'type' => Controls_Manager::NUMBER,
228 'default' => 15,
229 'condition' => [
230 'show_excerpt' => 'yes'
231 ],
232 ]
233 );
234
235 $this->add_control(
236 'strip_shortcode',
237 [
238 'label' => esc_html__('Strip Shortcode', 'ultimate-post-kit'),
239 'type' => Controls_Manager::SWITCHER,
240 'default' => 'yes',
241 'condition' => [
242 'show_excerpt' => 'yes',
243 ],
244 ]
245 );
246
247 $this->add_control(
248 'show_author',
249 [
250 'label' => esc_html__('Show Author', 'ultimate-post-kit'),
251 'type' => Controls_Manager::SWITCHER,
252 'separator' => 'before'
253 ]
254 );
255
256 $this->add_control(
257 'show_category',
258 [
259 'label' => esc_html__('Show Category', 'ultimate-post-kit'),
260 'type' => Controls_Manager::SWITCHER,
261 'default' => 'yes',
262 ]
263 );
264
265 $this->add_control(
266 'show_comments',
267 [
268 'label' => esc_html__('Show Comments', 'ultimate-post-kit'),
269 'type' => Controls_Manager::SWITCHER,
270 'default' => 'yes',
271 ]
272 );
273
274 //Global Date Controls
275 $this->register_date_controls();
276
277 //Global Reading Time Controls
278 $this->register_reading_time_controls();
279
280 $this->add_control(
281 'meta_separator',
282 [
283 'label' => __('Separator', 'ultimate-post-kit'),
284 'type' => Controls_Manager::TEXT,
285 'default' => '.',
286 'label_block' => false,
287 ]
288 );
289
290 $this->add_control(
291 'show_pagination',
292 [
293 'label' => esc_html__('Pagination', 'ultimate-post-kit'),
294 'type' => Controls_Manager::SWITCHER,
295 'separator' => 'before'
296 ]
297 );
298
299 $this->add_control(
300 'global_link',
301 [
302 'label' => __('Item Wrapper Link', 'ultimate-post-kit'),
303 'type' => Controls_Manager::SWITCHER,
304 'prefix_class' => 'upk-global-link-',
305 'description' => __('Be aware! When Item Wrapper Link activated then title link and read more link will not work', 'ultimate-post-kit'),
306 ]
307 );
308
309 $this->end_controls_section();
310
311 //Style
312 $this->start_controls_section(
313 'upk_section_style',
314 [
315 'label' => esc_html__('Items', 'ultimate-post-kit'),
316 'tab' => Controls_Manager::TAB_STYLE,
317 ]
318 );
319
320 $this->add_responsive_control (
321 'content_width',
322 [
323 'label' => __('Content Width', 'ultimate-post-kit'),
324 'type' => Controls_Manager::SLIDER,
325 'range' => [
326 'px' => [
327 'min' => 100,
328 'max' => 600,
329 ],
330 ],
331 'selectors' => [
332 '(desktop){{WRAPPER}} .upk-accordion-wrapper .upk-accordion-item .upk-accordion-content' => 'width: {{SIZE}}px;',
333 '(tablet){{WRAPPER}} .upk-accordion-wrapper .upk-accordion-item .upk-accordion-content' => 'width: 100%;',
334 '(mobile){{WRAPPER}} .upk-accordion-wrapper .upk-accordion-item .upk-accordion-content' => 'width: 100%;'
335 ],
336 ]
337 );
338
339 $this->add_responsive_control(
340 'content_padding',
341 [
342 'label' => __('Content Padding', 'ultimate-post-kit'),
343 'type' => Controls_Manager::DIMENSIONS,
344 'size_units' => ['px', 'em', '%'],
345 'selectors' => [
346 '{{WRAPPER}} .upk-accordion-wrapper .upk-accordion-item .upk-accordion-content' => 'padding: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
347 ],
348 ]
349 );
350
351 $this->add_group_control(
352 Group_Control_Border::get_type(),
353 [
354 'name' => 'item_border',
355 'label' => __('Border', 'ultimate-post-kit'),
356 'selector' => '{{WRAPPER}} .upk-accordion-wrapper .upk-accordion-item',
357 ]
358 );
359
360 $this->add_responsive_control(
361 'item_border_radius',
362 [
363 'label' => __('Border Radius', 'ultimate-post-kit'),
364 'type' => Controls_Manager::DIMENSIONS,
365 'size_units' => ['px', '%'],
366 'selectors' => [
367 '{{WRAPPER}} .upk-accordion-wrapper .upk-accordion-item' => 'border-radius: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
368 ],
369 ]
370 );
371
372 $this->start_controls_tabs('tabs_item_style');
373
374 $this->start_controls_tab(
375 'tab_item_normal',
376 [
377 'label' => esc_html__('Normal', 'ultimate-post-kit'),
378 ]
379 );
380
381 $this->add_control(
382 'overlay_blur_effect',
383 [
384 'label' => esc_html__('Glassmorphism', 'ultimate-post-kit'),
385 'type' => Controls_Manager::SWITCHER,
386 // translators: %1s: Opening anchor tag with link to MDN backdrop-filter documentation, %2s: Closing anchor tag
387 'description' => sprintf(__('This feature will not work in the Firefox browser untill you enable browser compatibility so please %1s look here %2s', 'ultimate-post-kit'), '<a href="https://developer.mozilla.org/en-US/docs/Web/CSS/backdrop-filter#Browser_compatibility" target="_blank">', '</a>'),
388 ]
389 );
390
391 $this->add_control(
392 'overlay_blur_level',
393 [
394 'label' => __('Blur Level', 'ultimate-post-kit'),
395 'type' => Controls_Manager::SLIDER,
396 'range' => [
397 'px' => [
398 'min' => 0,
399 'step' => 1,
400 'max' => 50,
401 ]
402 ],
403 'default' => [
404 'size' => 5
405 ],
406 'selectors' => [
407 '{{WRAPPER}} .upk-accordion-wrapper .upk-accordion-item .upk-accordion-item-box::before' => 'backdrop-filter: blur({{SIZE}}px); -webkit-backdrop-filter: blur({{SIZE}}px);'
408 ],
409 'condition' => [
410 'overlay_blur_effect' => 'yes'
411 ]
412 ]
413 );
414
415 $this->add_control(
416 'overlay_color',
417 [
418 'label' => esc_html__('Overlay Color', 'ultimate-post-kit'),
419 'type' => Controls_Manager::COLOR,
420 'selectors' => [
421 '{{WRAPPER}} .upk-accordion-wrapper .upk-accordion-item .upk-accordion-item-box::before' => 'background: {{VALUE}};',
422 ],
423 ]
424 );
425
426 $this->end_controls_tab();
427
428 $this->start_controls_tab(
429 'tab_item_hover',
430 [
431 'label' => esc_html__('Hover', 'ultimate-post-kit'),
432 ]
433 );
434
435 $this->add_control(
436 'overlay_blur_level_hover',
437 [
438 'label' => __('Blur Level', 'ultimate-post-kit'),
439 'type' => Controls_Manager::SLIDER,
440 'range' => [
441 'px' => [
442 'min' => 0,
443 'step' => 1,
444 'max' => 50,
445 ]
446 ],
447 'default' => [
448 'size' => 0
449 ],
450 'selectors' => [
451 '{{WRAPPER}} .upk-accordion-wrapper .upk-accordion-item:hover .upk-accordion-item-box::before' => 'backdrop-filter: blur({{SIZE}}px); -webkit-backdrop-filter: blur({{SIZE}}px);'
452 ],
453 'condition' => [
454 'overlay_blur_effect' => 'yes'
455 ]
456 ]
457 );
458
459 $this->add_control(
460 'overlay_color_hover',
461 [
462 'label' => esc_html__('Overlay Color', 'ultimate-post-kit'),
463 'type' => Controls_Manager::COLOR,
464 'selectors' => [
465 '{{WRAPPER}} .upk-accordion-wrapper .upk-accordion-item:hover .upk-accordion-item-box::before' => 'background: {{VALUE}};',
466 ],
467 ]
468 );
469
470 $this->end_controls_tab();
471
472 $this->end_controls_tabs();
473
474 $this->end_controls_section();
475
476 $this->start_controls_section(
477 'section_style_title',
478 [
479 'label' => esc_html__('Title', 'ultimate-post-kit'),
480 'tab' => Controls_Manager::TAB_STYLE,
481 'condition' => [
482 'show_title' => 'yes',
483 ],
484 ]
485 );
486
487 $this->add_control(
488 'title_style',
489 [
490 'label' => esc_html__('Style', 'ultimate-post-kit') . BDTUPK_NC,
491 'type' => Controls_Manager::SELECT,
492 'default' => '',
493 'options' => [
494 '' => esc_html__('Default', 'ultimate-post-kit'),
495 'underline' => esc_html__('Underline', 'ultimate-post-kit'),
496 'middle-underline' => esc_html__('Middle Underline', 'ultimate-post-kit'),
497 'overline' => esc_html__('Overline', 'ultimate-post-kit'),
498 'middle-overline' => esc_html__('Middle Overline', 'ultimate-post-kit'),
499 ],
500 'condition' => [
501 'layout_content_style' => 'style-1',
502 ],
503 ]
504 );
505
506 $this->add_control(
507 'title_color',
508 [
509 'label' => esc_html__('Color', 'ultimate-post-kit'),
510 'type' => Controls_Manager::COLOR,
511 'selectors' => [
512 '{{WRAPPER}} .upk-accordion-wrapper .upk-accordion-item .upk-accordion-content .upk-title a' => 'color: {{VALUE}};',
513 ],
514 ]
515 );
516
517 $this->add_control(
518 'title_color_hover',
519 [
520 'label' => esc_html__('Hover Color', 'ultimate-post-kit'),
521 'type' => Controls_Manager::COLOR,
522 'selectors' => [
523 '{{WRAPPER}} .upk-accordion-wrapper .upk-accordion-item .upk-accordion-content .upk-title a:hover' => 'color: {{VALUE}};',
524 ],
525 ]
526 );
527
528 $this->add_group_control(
529 Group_Control_Typography::get_type(),
530 [
531 'name' => 'title_typography',
532 'label' => esc_html__('Typography', 'ultimate-post-kit'),
533 'selector' => '{{WRAPPER}} .upk-accordion-wrapper .upk-accordion-item .upk-accordion-content .upk-title',
534 ]
535 );
536
537 $this->add_group_control(
538 Group_Control_Text_Shadow::get_type(),
539 [
540 'name' => 'title_text_shadow',
541 'label' => __('Text Shadow', 'ultimate-post-kit'),
542 'selector' => '{{WRAPPER}} .upk-accordion-wrapper .upk-accordion-item .upk-accordion-content .upk-title',
543 ]
544 );
545
546 $this->add_responsive_control(
547 'title_spacing',
548 [
549 'label' => __('Spacing', 'ultimate-post-kit'),
550 'type' => Controls_Manager::SLIDER,
551 'range' => [
552 'px' => [
553 'min' => 0,
554 'max' => 50,
555 ],
556 ],
557 'selectors' => [
558 '{{WRAPPER}} .upk-accordion-wrapper .upk-accordion-item .upk-accordion-content .upk-title' => 'margin-bottom: {{SIZE}}px;'
559 ],
560 ]
561 );
562
563 $this->end_controls_section();
564
565 $this->start_controls_section(
566 'section_style_text',
567 [
568 'label' => esc_html__('Text', 'ultimate-post-kit'),
569 'tab' => Controls_Manager::TAB_STYLE,
570 'condition' => [
571 'show_excerpt' => 'yes',
572 ],
573 ]
574 );
575
576 $this->add_control(
577 'text_color',
578 [
579 'label' => esc_html__('Color', 'ultimate-post-kit'),
580 'type' => Controls_Manager::COLOR,
581 'selectors' => [
582 '{{WRAPPER}} .upk-accordion-wrapper .upk-accordion-item .upk-accordion-content .upk-text' => 'color: {{VALUE}};',
583 ],
584 ]
585 );
586
587 $this->add_group_control(
588 Group_Control_Typography::get_type(),
589 [
590 'name' => 'text_typography',
591 'label' => esc_html__('Typography', 'ultimate-post-kit'),
592 'selector' => '{{WRAPPER}} .upk-accordion-wrapper .upk-accordion-item .upk-accordion-content .upk-text',
593 ]
594 );
595
596 $this->add_responsive_control(
597 'text_spacing',
598 [
599 'label' => __('Spacing', 'ultimate-post-kit'),
600 'type' => Controls_Manager::SLIDER,
601 'range' => [
602 'px' => [
603 'min' => 0,
604 'max' => 50,
605 ],
606 ],
607 'selectors' => [
608 '{{WRAPPER}} .upk-accordion-wrapper .upk-accordion-item .upk-accordion-content .upk-text' => 'margin-bottom: {{SIZE}}px;'
609 ],
610 ]
611 );
612
613 $this->end_controls_section();
614
615 $this->start_controls_section(
616 'section_style_category',
617 [
618 'label' => esc_html__('Category', 'ultimate-post-kit'),
619 'tab' => Controls_Manager::TAB_STYLE,
620 'condition' => [
621 'show_category' => 'yes'
622 ],
623 ]
624 );
625
626 $this->add_responsive_control(
627 'category_bottom_spacing',
628 [
629 'label' => esc_html__('Spacing', 'ultimate-post-kit'),
630 'type' => Controls_Manager::SLIDER,
631 'range' => [
632 'px' => [
633 'min' => 0,
634 'max' => 50,
635 ],
636 ],
637 'selectors' => [
638 '{{WRAPPER}} .upk-accordion-wrapper .upk-accordion-item .upk-accordion-content .upk-category' => 'margin-bottom: {{SIZE}}{{UNIT}};',
639 ],
640 ]
641 );
642
643 $this->start_controls_tabs('tabs_category_style');
644
645 $this->start_controls_tab(
646 'tab_category_normal',
647 [
648 'label' => esc_html__('Normal', 'ultimate-post-kit'),
649 ]
650 );
651
652 $this->add_control(
653 'category_color',
654 [
655 'label' => esc_html__('Color', 'ultimate-post-kit'),
656 'type' => Controls_Manager::COLOR,
657 'selectors' => [
658 '{{WRAPPER}} .upk-accordion-wrapper .upk-accordion-item .upk-accordion-content .upk-category a ,{{WRAPPER}} .upk-accordion-wrapper .upk-accordion-item .upk-accordion-content .upk-category a::before' => 'color: {{VALUE}};',
659 ],
660 ]
661 );
662
663 $this->add_group_control(
664 Group_Control_Background::get_type(),
665 [
666 'name' => 'category_background',
667 'selector' => '{{WRAPPER}} .upk-accordion-wrapper .upk-accordion-item .upk-accordion-content .upk-category a ,{{WRAPPER}} .upk-accordion-wrapper .upk-accordion-item .upk-accordion-content .upk-category a::before',
668 ]
669 );
670
671 $this->add_group_control(
672 Group_Control_Border::get_type(),
673 [
674 'name' => 'category_border',
675 'selector' => '{{WRAPPER}} .upk-accordion-wrapper .upk-accordion-item .upk-accordion-content .upk-category a ,{{WRAPPER}} .upk-accordion-wrapper .upk-accordion-item .upk-accordion-content .upk-category a::before',
676 ]
677 );
678
679 $this->add_responsive_control(
680 'category_border_radius',
681 [
682 'label' => esc_html__('Border Radius', 'ultimate-post-kit'),
683 'type' => Controls_Manager::DIMENSIONS,
684 'size_units' => ['px', '%'],
685 'selectors' => [
686 '{{WRAPPER}} .upk-accordion-wrapper .upk-accordion-item .upk-accordion-content .upk-category a ,{{WRAPPER}} .upk-accordion-wrapper .upk-accordion-item .upk-accordion-content .upk-category a::before' => 'border-radius: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
687 ],
688 ]
689 );
690
691 $this->add_responsive_control(
692 'category_padding',
693 [
694 'label' => esc_html__('Padding', 'ultimate-post-kit'),
695 'type' => Controls_Manager::DIMENSIONS,
696 'size_units' => ['px', 'em', '%'],
697 'selectors' => [
698 '{{WRAPPER}} .upk-accordion-wrapper .upk-accordion-item .upk-accordion-content .upk-category a ,{{WRAPPER}} .upk-accordion-wrapper .upk-accordion-item .upk-accordion-content .upk-category a::before' => 'padding: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
699 ],
700 ]
701 );
702
703 $this->add_responsive_control(
704 'category_space_between',
705 [
706 'label' => esc_html__('Space Between', 'ultimate-post-kit'),
707 'type' => Controls_Manager::SLIDER,
708 'range' => [
709 'px' => [
710 'min' => 0,
711 'max' => 50,
712 ],
713 ],
714 'selectors' => [
715 '{{WRAPPER}} .upk-accordion-wrapper .upk-accordion-item .upk-accordion-content .upk-category a+a' => 'margin-left: {{SIZE}}{{UNIT}};',
716 ],
717 ]
718 );
719
720 $this->add_group_control(
721 Group_Control_Box_Shadow::get_type(),
722 [
723 'name' => 'category_shadow',
724 'selector' => '{{WRAPPER}} .upk-accordion-wrapper .upk-accordion-item .upk-accordion-content .upk-category a ,{{WRAPPER}} .upk-accordion-wrapper .upk-accordion-item .upk-accordion-content .upk-category a::before',
725 ]
726 );
727
728 $this->add_group_control(
729 Group_Control_Typography::get_type(),
730 [
731 'name' => 'category_typography',
732 'label' => esc_html__('Typography', 'ultimate-post-kit'),
733 'selector' => '{{WRAPPER}} .upk-accordion-wrapper .upk-accordion-item .upk-accordion-content .upk-category a ,{{WRAPPER}} .upk-accordion-wrapper .upk-accordion-item .upk-accordion-content .upk-category a::before',
734 ]
735 );
736
737 $this->end_controls_tab();
738
739 $this->start_controls_tab(
740 'tab_category_hover',
741 [
742 'label' => esc_html__('Hover', 'ultimate-post-kit'),
743 'condition' => [
744 'show_category' => 'yes'
745 ]
746 ]
747 );
748
749 $this->add_control(
750 'category_hover_color',
751 [
752 'label' => esc_html__('Color', 'ultimate-post-kit'),
753 'type' => Controls_Manager::COLOR,
754 'selectors' => [
755 '{{WRAPPER}} .upk-accordion-wrapper .upk-accordion-item .upk-accordion-content .upk-category a:hover ,{{WRAPPER}} .upk-accordion-wrapper .upk-accordion-item .upk-accordion-content .upk-category a:hover::before' => 'color: {{VALUE}};',
756 ],
757 ]
758 );
759
760 $this->add_group_control(
761 Group_Control_Background::get_type(),
762 [
763 'name' => 'category_hover_background',
764 'selector' => '{{WRAPPER}} .upk-accordion-wrapper .upk-accordion-item .upk-accordion-content .upk-category a:hover ,{{WRAPPER}} .upk-accordion-wrapper .upk-accordion-item .upk-accordion-content .upk-category a:hover::before',
765 ]
766 );
767
768 $this->add_control(
769 'category_hover_border_color',
770 [
771 'label' => esc_html__('Border Color', 'ultimate-post-kit'),
772 'type' => Controls_Manager::COLOR,
773 'condition' => [
774 'category_border_border!' => '',
775 ],
776 'selectors' => [
777 '{{WRAPPER}} .upk-accordion-wrapper .upk-accordion-item .upk-accordion-content .upk-category a:hover ,{{WRAPPER}} .upk-accordion-wrapper .upk-accordion-item .upk-accordion-content .upk-category a:hover::before' => 'border-color: {{VALUE}};',
778 ],
779 ]
780 );
781
782 $this->end_controls_tab();
783
784 $this->end_controls_tabs();
785
786 $this->end_controls_section();
787
788 $this->start_controls_section(
789 'section_style_author',
790 [
791 'label' => esc_html__('Author', 'ultimate-post-kit'),
792 'tab' => Controls_Manager::TAB_STYLE,
793 'condition' => [
794 'show_author' => 'yes',
795 ],
796 ]
797 );
798
799 $this->add_control(
800 'author_image_heading',
801 [
802 'label' => esc_html__('Avatar', 'ultimate-post-kit'),
803 'type' => Controls_Manager::HEADING,
804 ]
805 );
806
807 $this->add_responsive_control(
808 'author_image_size',
809 [
810 'label' => esc_html__('Size', 'ultimate-post-kit'),
811 'type' => Controls_Manager::SLIDER,
812 'range' => [
813 'px' => [
814 'min' => 20,
815 'max' => 100,
816 ],
817 ],
818 'selectors' => [
819 '{{WRAPPER}} .upk-accordion-wrapper .upk-accordion-item .upk-author-img img' => 'width: {{SIZE}}{{UNIT}}; height: {{SIZE}}{{UNIT}};',
820 ],
821 ]
822 );
823
824 $this->add_responsive_control(
825 'author_image_spacing',
826 [
827 'label' => esc_html__('Spacing', 'ultimate-post-kit'),
828 'type' => Controls_Manager::SLIDER,
829 'range' => [
830 'px' => [
831 'min' => 0,
832 'max' => 50,
833 ],
834 ],
835 'selectors' => [
836 '{{WRAPPER}} .upk-accordion-wrapper .upk-accordion-item .upk-author-img img' => 'margin-right: {{SIZE}}{{UNIT}};',
837 ],
838 ]
839 );
840
841 $this->add_responsive_control(
842 'author_image_radius',
843 [
844 'label' => esc_html__('Border Radius', 'ultimate-post-kit'),
845 'type' => Controls_Manager::DIMENSIONS,
846 'size_units' => ['px', '%'],
847 'selectors' => [
848 '{{WRAPPER}} .upk-accordion-wrapper .upk-accordion-item .upk-author-img img' => 'border-radius: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
849 ],
850 ]
851 );
852
853 $this->add_control(
854 'author_name_heading',
855 [
856 'label' => esc_html__('Name', 'ultimate-post-kit'),
857 'type' => Controls_Manager::HEADING,
858 'separator' => 'before'
859 ]
860 );
861
862 $this->add_control(
863 'author_name_color',
864 [
865 'label' => esc_html__('Color', 'ultimate-post-kit'),
866 'type' => Controls_Manager::COLOR,
867 'selectors' => [
868 '{{WRAPPER}} .upk-accordion-wrapper .upk-accordion-item .upk-author-name a' => 'color: {{VALUE}};',
869 ],
870 ]
871 );
872
873 $this->add_control(
874 'author_name_hover_color',
875 [
876 'label' => esc_html__('Hover Color', 'ultimate-post-kit'),
877 'type' => Controls_Manager::COLOR,
878 'selectors' => [
879 '{{WRAPPER}} .upk-accordion-wrapper .upk-accordion-item .upk-author-name a:hover' => 'color: {{VALUE}};',
880 ],
881 ]
882 );
883
884 $this->add_group_control(
885 Group_Control_Typography::get_type(),
886 [
887 'name' => 'author_name_typography',
888 'label' => esc_html__('Typography', 'ultimate-post-kit'),
889 'selector' => '{{WRAPPER}} .upk-accordion-wrapper .upk-accordion-item .upk-author-name a',
890 ]
891 );
892
893 $this->add_control(
894 'author_role_heading',
895 [
896 'label' => esc_html__('Role', 'ultimate-post-kit'),
897 'type' => Controls_Manager::HEADING,
898 'separator' => 'before'
899 ]
900 );
901
902 $this->add_control(
903 'author_role_color',
904 [
905 'label' => esc_html__('Color', 'ultimate-post-kit'),
906 'type' => Controls_Manager::COLOR,
907 'selectors' => [
908 '{{WRAPPER}} .upk-accordion-wrapper .upk-accordion-item .upk-author-role' => 'color: {{VALUE}};',
909 ],
910 ]
911 );
912
913 $this->add_group_control(
914 Group_Control_Typography::get_type(),
915 [
916 'name' => 'author_role_typography',
917 'label' => esc_html__('Typography', 'ultimate-post-kit'),
918 'selector' => '{{WRAPPER}} .upk-accordion-wrapper .upk-accordion-item .upk-author-role',
919 ]
920 );
921
922 $this->add_responsive_control(
923 'author_role_spacing',
924 [
925 'label' => esc_html__('Spacing', 'ultimate-post-kit'),
926 'type' => Controls_Manager::SLIDER,
927 'range' => [
928 'px' => [
929 'min' => 0,
930 'max' => 50,
931 ],
932 ],
933 'selectors' => [
934 '{{WRAPPER}} .upk-accordion-wrapper .upk-accordion-item .upk-author-role' => 'padding-top: {{SIZE}}{{UNIT}};',
935 ],
936 ]
937 );
938
939 $this->end_controls_section();
940
941 $this->start_controls_section(
942 'section_style_meta',
943 [
944 'label' => esc_html__('Meta', 'ultimate-post-kit'),
945 'tab' => Controls_Manager::TAB_STYLE,
946 'conditions' => [
947 'relation' => 'or',
948 'terms' => [
949 [
950 'name' => 'show_date',
951 'value' => 'yes'
952 ],
953 [
954 'name' => 'show_comments',
955 'value' => 'yes'
956 ]
957 ]
958 ],
959 ]
960 );
961
962 $this->add_control(
963 'meta_color',
964 [
965 'label' => esc_html__('Color', 'ultimate-post-kit'),
966 'type' => Controls_Manager::COLOR,
967 'selectors' => [
968 '{{WRAPPER}} .upk-accordion-wrapper .upk-accordion-item .upk-accordion-content .upk-accordion-meta' => 'color: {{VALUE}};',
969 ],
970 ]
971 );
972
973 $this->add_group_control(
974 Group_Control_Typography::get_type(),
975 [
976 'name' => 'meta_typography',
977 'label' => esc_html__('Typography', 'ultimate-post-kit'),
978 'selector' => '{{WRAPPER}} .upk-accordion-wrapper .upk-accordion-item .upk-accordion-content .upk-accordion-meta',
979 ]
980 );
981
982 $this->add_responsive_control(
983 'meta_space_between',
984 [
985 'label' => esc_html__('Space Between', 'ultimate-post-kit'),
986 'type' => Controls_Manager::SLIDER,
987 'range' => [
988 'px' => [
989 'min' => 0,
990 'max' => 50,
991 ],
992 ],
993 'selectors' => [
994 '{{WRAPPER}} .upk-accordion-wrapper .upk-accordion-item .upk-accordion-content .upk-accordion-meta > div:before' => 'margin: 0 {{SIZE}}{{UNIT}};',
995 ],
996 ]
997 );
998
999 $this->end_controls_section();
1000
1001 //Global Pagination Controls
1002 $this->register_pagination_controls();
1003 }
1004
1005 /**
1006 * Get post query builder arguments
1007 */
1008 public function query_posts( $posts_per_page ) {
1009 $settings = $this->get_settings();
1010 $posts_per_page = isset( $posts_per_page ) ? (int) $posts_per_page : 0;
1011 $args = $this->getGroupControlQueryArgs();
1012 $is_current_query = ( ! empty( $settings['posts_source'] ) && $settings['posts_source'] === 'current_query' );
1013
1014 if ( $is_current_query ) {
1015 unset( $args['offset'] );
1016 unset( $args['no_found_rows'] );
1017 $posts_per_page = 0;
1018 }
1019
1020 if ( $posts_per_page > 0 ) {
1021 $args['posts_per_page'] = $posts_per_page;
1022 } else {
1023 $args['posts_per_page'] = (int) get_option( 'posts_per_page', 10 );
1024 }
1025
1026 if ( $settings['show_pagination'] ) {
1027 $args['paged'] = max( 1, (int) get_query_var( 'paged' ), (int) get_query_var( 'page' ) );
1028 }
1029
1030 $this->_query = new \WP_Query( $args );
1031 }
1032
1033 protected function _upk_get_category($post_type) {
1034 switch ($post_type) {
1035 case 'campaign':
1036 $taxonomy = 'campaign_category';
1037 break;
1038 case 'lightbox_library':
1039 $taxonomy = 'ngg_tag';
1040 break;
1041 case 'give_forms':
1042 $taxonomy = 'give_forms_category';
1043 break;
1044 case 'tribe_events':
1045 $taxonomy = 'tribe_events_cat';
1046 break;
1047 case 'product':
1048 $taxonomy = 'product_cat';
1049 break;
1050 default:
1051 $taxonomy = 'category';
1052 break;
1053 }
1054
1055 $categories = get_the_terms(get_the_ID(), $taxonomy);
1056 $_categories = [];
1057 if ($categories) {
1058 foreach ($categories as $category) {
1059 $link = '<a data-hover="' . $category->name . '" href="' . esc_url(get_category_link($category->term_id)) . '">' . $category->name . '</a>';
1060 $_categories[$category->slug] = $link;
1061 }
1062 }
1063 return implode(' ', $_categories);
1064 }
1065
1066 public function render_title() {
1067 $settings = $this->get_settings_for_display();
1068
1069 if (!$this->get_settings('show_title')) {
1070 return;
1071 }
1072
1073 printf(
1074 '<%1$s class="upk-title"><a data-hover="%3$s" href="%2$s" title="%3$s" class="title-animation-%4$s">%3$s</a></%1$s>',
1075 esc_attr(Utils::get_valid_html_tag($settings['title_tags'])),
1076 esc_url( get_permalink() ), esc_html( get_the_title() ),
1077 esc_attr($settings['title_style'])
1078 );
1079 }
1080
1081 public function render_date() {
1082 $settings = $this->get_settings_for_display();
1083
1084 if (!$this->get_settings('show_date')) {
1085 return;
1086 }
1087
1088 $date_for_hover = false;
1089 if ($settings['human_diff_time'] == 'yes') {
1090 $date_for_hover = ultimate_post_kit_post_time_diff(($settings['human_diff_time_short'] == 'yes') ? 'short' : '');
1091 } else {
1092 $date_for_hover = get_the_date();
1093 }
1094
1095 ?>
1096 <div class="upk-accordion-date">
1097 <i class="upk-icon-calendar" aria-hidden="true"></i>
1098 <span <?php
1099 if($date_for_hover){
1100 printf('data-hover="%s"', $date_for_hover);
1101 }
1102 ?>>
1103 <?php
1104 echo $date_for_hover;
1105 ?>
1106 </span>
1107 </div>
1108 <?php if ($settings['show_time']) : ?>
1109 <div class="upk-post-time">
1110 <i class="upk-icon-clock" aria-hidden="true"></i>
1111 <?php echo esc_html( get_the_time() ); ?>
1112 </div>
1113 <?php endif; ?>
1114
1115 <?php
1116 }
1117
1118 public function render_comments($id = 0) {
1119
1120 if (!$this->get_settings('show_comments')) {
1121 return;
1122 }
1123
1124 $comment_text = $this->upk_get_formatted_comments_count( $id );
1125 ?>
1126
1127 <div class="upk-accordion-comments">
1128 <i class="upk-icon-bubbles" aria-hidden="true"></i>
1129 <span <?php printf('data-hover="%s"', esc_attr($comment_text)); ?>>
1130 <?php echo esc_html($comment_text); ?>
1131 </span>
1132 </div>
1133
1134 <?php
1135 }
1136
1137 public function render_author() {
1138
1139 if (!$this->get_settings('show_author')) {
1140 return;
1141 }
1142
1143 ?>
1144 <div class="upk-author-wrapper">
1145 <div class="upk-author-img">
1146 <?php echo get_avatar(get_the_author_meta('ID'), 48); ?>
1147 </div>
1148 <div class="upk-author-info-warp upk-flex">
1149 <div class="upk-author-name">
1150 <a href="<?php echo esc_url( get_author_posts_url(get_the_author_meta('ID')) ); ?>">
1151 <?php echo esc_html( get_the_author() ) ?>
1152 </a>
1153 </div>
1154 <div class="upk-author-role">
1155 <?php
1156 $aid = get_the_author_meta('ID');
1157 echo ucwords(get_user_role($aid));
1158 ?>
1159 </div>
1160 </div>
1161 </div>
1162 <?php
1163 }
1164
1165 public function render_post_accordion_item($post_id, $image_size, $excerpt_length) {
1166 $settings = $this->get_settings_for_display();
1167
1168 if ('yes' == $settings['global_link']) {
1169
1170 $this->add_render_attribute('accordion-item', 'onclick', "window.open('" . esc_url(get_permalink()) . "', '_self')", true);
1171 }
1172
1173 $this->add_render_attribute('accordion-item', 'class', 'upk-accordion-item', true);
1174
1175 ?>
1176
1177 <div <?php $this->print_render_attribute_string('accordion-item'); ?>>
1178 <div class="upk-accordion-item-box">
1179
1180 <div class="upk-accordion-image">
1181 <?php $this->render_image(get_post_thumbnail_id($post_id), $image_size); ?>
1182 </div>
1183 <?php $this->render_author(); ?>
1184
1185 <div class="upk-accordion-content">
1186 <?php $this->render_category(); ?>
1187 <?php $this->render_title(substr($this->get_name(), 4)); ?>
1188 <?php $this->render_excerpt($excerpt_length); ?>
1189
1190 <?php if ($settings['show_comments'] or $settings['show_date'] or $settings['show_reading_time']) : ?>
1191 <div class="upk-accordion-meta">
1192 <?php $this->render_date(); ?>
1193
1194 <?php if ($settings['show_comments'] == 'yes') : ?>
1195 <div data-separator="<?php echo esc_html($settings['meta_separator']); ?>">
1196 <?php $this->render_comments($post_id); ?>
1197 </div>
1198 <?php endif; ?>
1199
1200 <?php if (_is_upk_pro_activated()) :
1201 if ('yes' === $settings['show_reading_time']) : ?>
1202 <div class="upk-reading-time" data-separator="<?php echo esc_html($settings['meta_separator']); ?>">
1203 <?php echo esc_html( ultimate_post_kit_reading_time( get_the_content(), $settings['avg_reading_speed'], $settings['hide_seconds'] ?? 'no', $settings['hide_minutes'] ?? 'no' ) ); ?>
1204 </div>
1205 <?php endif; ?>
1206 <?php endif; ?>
1207 </div>
1208 <?php endif; ?>
1209
1210 </div>
1211
1212 </div>
1213 </div>
1214
1215 <?php
1216 }
1217
1218 protected function render() {
1219 $settings = $this->get_settings_for_display();
1220
1221 $this->query_posts($settings['item_limit']['size']);
1222 $wp_query = $this->get_query();
1223
1224 if (!$wp_query->found_posts) {
1225 return;
1226 }
1227
1228 ?>
1229 <div class="upk-accordion">
1230 <div class="upk-accordion-wrapper upk-accordion-content<?php echo esc_attr($settings['layout_content_style'])?> upk-accordion-<?php echo esc_attr($settings['layout_style'])?>">
1231
1232 <?php while ($wp_query->have_posts()) :
1233 $wp_query->the_post();
1234
1235 $thumbnail_size = $settings['primary_thumbnail_size'];
1236
1237 ?>
1238
1239 <?php $this->render_post_accordion_item(get_the_ID(), $thumbnail_size, $settings['excerpt_length']); ?>
1240
1241 <?php endwhile; ?>
1242
1243 </div>
1244 </div>
1245
1246 <?php
1247
1248 if ($settings['show_pagination']) { ?>
1249 <div class="ep-pagination">
1250 <?php ultimate_post_kit_post_pagination($wp_query, $this->get_id()); ?>
1251 </div>
1252 <?php
1253 }
1254 wp_reset_postdata();
1255 }
1256 }
1257