PluginProbe
Forumax – AI Powered Advanced Community Forum Plugin / 1.4.0
Forumax – AI Powered Advanced Community Forum Plugin v1.4.0
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.4.0, at includes/Elementor/Forum_posts.php

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