PluginProbe
Forumax – AI Powered Advanced Community Forum Plugin / 1.2.4
Forumax – AI Powered Advanced Community Forum Plugin v1.2.4
2.4.4 2.4.3 2.4.2 2.4.1 2.4.0 trunk 1.0.8 1.1.0 1.2.1 1.2.2 1.2.3 1.2.4 1.2.5 1.2.6 1.2.7 1.2.8 1.2.9 1.3.0 1.3.1 1.3.2 1.3.3 1.4.0 1.4.1 2.0.0 2.1.0 All 29 releases
bbp-core / includes / Elementor / Forum_posts.php

Forum_posts.php in Forumax – AI Powered Advanced Community Forum Plugin 1.2.4, at includes/Elementor/Forum_posts.php

145 lines 3.9 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 namespace admin\Elementor;
4
5 use Elementor\Widget_Base;
6 use Elementor\Controls_Manager;
7 use Elementor\Core\Schemes\Color;
8 use Elementor\Core\Schemes\Typography;
9 use Elementor\Group_Control_Typography;
10 use Elementor\Group_Control_Text_Shadow;
11 use WP_Query;
12 use WP_Post;
13
14 // Exit if accessed directly
15 if ( ! defined( 'ABSPATH' ) ) {
16 exit;
17 }
18
19 /**
20 * Class Forum_posts
21 *
22 * @package amaCore\Widgets
23 */
24 class Forum_posts extends Widget_Base {
25
26 public function get_name() {
27 return 'ama_forum_posts';
28 }
29
30 public function get_title() {
31 return __( 'BBPC Forum Topics', 'bbp-core' );
32 }
33
34 public function get_icon() {
35 return 'bbpc_icon_ama_forum_posts';
36 }
37
38 public function get_keywords() {
39 return [ 'topics', 'replies' ];
40 }
41
42 // style dependency
43 public function get_style_depends() {
44 return [ 'bbpc-el-widgets' ];
45 }
46
47 public function get_categories() {
48 return [ 'bbp-core' ];
49 }
50
51 protected function register_controls() {
52
53 // --- Filter Options
54 $this->start_controls_section(
55 'filter_opt', [
56 'label' => __( 'Filter Options', 'bbp-core' ),
57 ]
58 );
59
60 $this->add_control(
61 'ppp', [
62 'label' => esc_html__( 'Show Forum Topics', 'bbp-core' ),
63 'type' => Controls_Manager::NUMBER,
64 'default' => 5
65 ]
66 );
67
68 $this->add_control(
69 'order', [
70 'label' => esc_html__( 'Order', 'bbp-core' ),
71 'type' => Controls_Manager::SELECT,
72 'options' => [
73 'ASC' => 'ASC',
74 'DESC' => 'DESC'
75 ],
76 'default' => 'ASC'
77 ]
78 );
79
80 $this->end_controls_section();
81 // end Document Setting Section
82 }
83
84 protected function render() {
85 $settings = $this->get_settings();
86 $forum_posts = new WP_Query( array(
87 'post_type' => 'topic',
88 'posts_per_page' => ! empty( $settings['ppp'] ) ? $settings['ppp'] : - 1,
89 'order' => $settings['order'] ? $settings['order'] : 'ASC',
90 ) );
91 ?>
92 <div class="community-posts-wrapper">
93 <?php
94 while ( $forum_posts->have_posts() ) : $forum_posts->the_post();
95 $favoriters = bbp_get_topic_favoriters();
96 $favorite_count = ! empty( $favoriters ) ? $favoriters[0] : '0';
97 ?>
98 <div class="community-post wow fadeInUp" data-wow-delay="0.5s">
99 <div class="post-content">
100 <div class="author-avatar">
101 <?php
102 echo bbp_get_topic_author_link(
103 array(
104 'post_id' => get_the_ID(),
105 'size' => 40,
106 'type' => 'avatar'
107 )
108 );
109 ?>
110 </div>
111 <div class="entry-content">
112 <h3 class="post-title">
113 <a href="<?php the_permalink(); ?>"> <?php the_title(); ?> </a>
114 </h3>
115
116 <?php
117 esc_html_e( 'Last active: ', 'bbp-core' );
118 echo bbp_get_forum_last_active_time( get_the_ID() );
119 ?>
120
121 </div>
122 </div>
123 <div class="post-meta-wrapper">
124 <ul class="post-meta-info">
125 <li>
126 <a href="<?php bbp_topic_permalink(); ?>">
127 <i class="icon_chat_alt"></i>
128 <?php bbp_show_lead_topic() ? bbp_topic_reply_count( get_the_ID() ) : bbp_topic_post_count( get_the_ID() ); ?>
129 </a>
130 </li>
131 <li>
132 <a href="<?php bbp_topic_permalink(); ?>">
133 <i class="icon_star_alt"></i> <?php echo esc_html( $favorite_count ); ?>
134 </a>
135 </li>
136 </ul>
137 </div>
138 </div>
139 <?php
140 endwhile;
141 ?>
142 </div>
143 <?php
144 }
145 }