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 / Forums.php

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

222 lines 6.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 Forums
19 *
20 * @package amaCore\Widgets
21 */
22 class Forums extends Widget_Base {
23
24 public function get_name() {
25 return 'ama_forums';
26 }
27
28 public function get_title() {
29 return __( 'BBPC Forums', 'bbp-core' );
30 }
31
32 public function get_icon() {
33 return 'bbpc_icon_ama_forums';
34 }
35
36 public function get_categories() {
37 return [ 'bbp-core' ];
38 }
39
40 // style dependency
41 public function get_style_depends() {
42 return [ 'bbpc-el-widgets' ];
43 }
44
45 public function get_script_depends() {
46 return [ 'bbpc-ajax' ];
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 Forums', 'bbp-core' ),
61 'description' => esc_html__( 'Show the forums count at the initial view. Default is 5 forums in a row.', 'bbp-core' ),
62 'type' => Controls_Manager::NUMBER,
63 'label_block' => true,
64 'default' => 5
65 ]
66 );
67
68 $this->add_control(
69 'ppp2', [
70 'label' => esc_html__( 'Hidden Forums', 'bbp-core' ),
71 'description' => esc_html__( 'Hidden forums will show on clicking on the More button.', 'bbp-core' ),
72 'type' => Controls_Manager::NUMBER,
73 'label_block' => true,
74 'default' => 10
75 ]
76 );
77
78 $this->add_control(
79 'order', [
80 'label' => esc_html__( 'Order', 'bbp-core' ),
81 'type' => Controls_Manager::SELECT,
82 'options' => [
83 'ASC' => 'ASC',
84 'DESC' => 'DESC'
85 ],
86 'default' => 'ASC'
87 ]
88 );
89
90 $this->add_control(
91 'more_txt', [
92 'label' => esc_html__( 'Read More Text', 'bbp-core' ),
93 'type' => Controls_Manager::TEXT,
94 'label_block' => true,
95 'default' => 'More Communities'
96 ]
97 );
98
99 $this->end_controls_section();
100 // end Document Setting Section
101
102 $this->start_controls_section(
103 'forum_styling', [
104 'label' => esc_html__( 'Forum Style', 'bbp-core' ),
105 'tab' => Controls_Manager::TAB_STYLE,
106 ]
107 );
108
109 $this->add_group_control(
110 \Elementor\Group_Control_Typography::get_type(),
111 [
112 'name' => 'forum_title_typography',
113 'label' => esc_html__( 'Forum Title Typography', 'bbp-core' ),
114 'selector' => '{{WRAPPER}} .com-box-content .title a',
115 ]
116 );
117
118
119 $this->add_group_control(
120 \Elementor\Group_Control_Typography::get_type(),
121 [
122 'name' => 'more_text_typography',
123 'label' => esc_html__( 'More text typography', 'bbp-core' ),
124 'selector' => '{{WRAPPER}} .collapse-btn',
125
126 ]
127 );
128
129 $this->add_control(
130 'more_text_color',
131 [
132 'label' => esc_html__( 'More text color', 'bbp-core' ),
133 'type' => \Elementor\Controls_Manager::COLOR,
134 'selectors' => [
135 '{{WRAPPER}} .collapse-btn' => 'color: {{VALUE}}',
136 '{{WRAPPER}} .more-communities .collapse-btn svg path' => 'stroke: {{VALUE}}',
137 ],
138 ]
139 );
140
141 $this->end_controls_section();
142 }
143
144 protected function render() {
145 $settings = $this->get_settings();
146 $forums = new WP_Query( array(
147 'post_type' => 'forum',
148 'posts_per_page' => ! empty( $settings['ppp'] ) ? $settings['ppp'] : 5,
149 'order' => $settings['order'] ? $settings['order'] : 'ASC',
150 ) );
151 ?>
152 <div class="communities-boxes">
153 <?php
154 while ( $forums->have_posts() ) : $forums->the_post();
155 ?>
156 <div class="com-box wow fadeInRight" data-wow-delay="0.5s">
157 <div class="icon-container">
158 <?php the_post_thumbnail( 'full' ); ?>
159 </div>
160 <div class="com-box-content">
161 <h3 class="title">
162 <a href="<?php the_permalink(); ?>"> <?php the_title() ?> </a>
163 </h3>
164 <p class="total-post"> <?php bbp_forum_topic_count( get_the_ID() ); ?> <?php esc_html_e( ' Posts', 'bbp-core' ) ?> </p>
165 </div>
166 <!-- /.ama-com-box-content -->
167 </div>
168 <!-- /.ama-com-box -->
169 <?php
170 endwhile;
171 wp_reset_postdata();
172 ?>
173 </div>
174 <!-- /.communities-boxes -->
175
176 <div class="more-communities" data_id="<?php echo esc_attr( $this->get_id() );?>">
177
178 <a href="#more-category" class="collapse-btn-wrap">
179 <?php echo esc_html( $settings['more_txt'] ); ?>
180
181 <svg fill="#000000" width="16px" height="16px" viewBox="0 0 24 24" id="minus" data-name="Line Color" xmlns="http://www.w3.org/2000/svg" class="icon line-color icon_minus"> <line id="primary" x1="19" y1="12" x2="5" y2="12" style="fill: none; stroke-linecap: round; stroke-linejoin: round; stroke-width: 2;"></line> </svg>
182
183 <svg fill="#000000" width="16px" height="16px" viewBox="0 0 24 24" id="plus" data-name="Line Color" xmlns="http://www.w3.org/2000/svg" class="icon line-color icon_plus"><path id="secondary" d="M5,12H19M12,5V19" style="fill: none; stroke-linecap: round; stroke-linejoin: round; stroke-width: 2;"></path></svg>
184 </a>
185
186 <div class="collapse-wrap" id="more-category" data_id="<?php echo esc_attr( $this->get_id() );?>">
187 <div class="communities-boxes">
188 <?php
189 $forums2 = new WP_Query( array(
190 'post_type' => 'forum',
191 'posts_per_page' => ! empty( $settings['ppp2'] ) ? $settings['ppp2'] : 10,
192 'offset' => ! empty( $settings['ppp'] ) ? $settings['ppp'] : 5,
193 'order' => $settings['order'],
194 ) );
195 while ( $forums2->have_posts() ) : $forums2->the_post();
196 ?>
197 <div class="com-box">
198 <div class="icon-container">
199 <?php the_post_thumbnail( 'full' ); ?>
200 </div>
201 <div class="com-box-content">
202 <h3 class="title">
203 <a href="<?php the_permalink(); ?>"> <?php the_title() ?> </a>
204 </h3>
205 <p class="total-post"> <?php bbp_forum_topic_count( get_the_ID() ); ?> <?php esc_html_e( ' Posts', 'bbp-core' ); ?> </p>
206 </div>
207 <!-- /.ama-com-box-content -->
208 </div>
209 <!-- /.ama-com-box -->
210 <?php
211 endwhile;
212 wp_reset_postdata();
213 ?>
214 </div>
215 <!-- /.communities-boxes -->
216 </div>
217 <!-- /.collapse-wrap -->
218 </div>
219 <!-- /.more-communities -->
220 <?php
221 }
222 }