PluginProbe
Ultimate Post Kit – Elementor Post Grid, Post Carousel, Post Slider & Blog Layout Widgets / 4.5.5
Ultimate Post Kit – Elementor Post Grid, Post Carousel, Post Slider & Blog Layout Widgets v4.5.5
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.5.5, at modules/post-accordion/widgets/post-accordion.php

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