| @@ -1,354 +1,354 @@ | ||
| 1 | -<?php | |
| 2 | -namespace admin\Elementor; | |
| 3 | - | |
| 4 | -use Elementor\Controls_Manager; | |
| 5 | -use Elementor\Widget_Base; | |
| 6 | -use WP_Query; | |
| 7 | - | |
| 8 | -// Exit if accessed directly | |
| 9 | -if ( ! defined( 'ABSPATH' ) ) { | |
| 10 | - exit; | |
| 11 | -} | |
| 12 | - | |
| 13 | -class Forum_Ajax extends Widget_Base { | |
| 14 | - public function get_name(): string { | |
| 15 | - return 'ama_ajax_forum'; | |
| 16 | - } | |
| 17 | - | |
| 18 | - public function get_title(): string { | |
| 19 | - return esc_html__( 'BBPC Ajax Forums', 'bbp-core' ); | |
| 20 | - } | |
| 21 | - | |
| 22 | - public function get_icon(): string { | |
| 23 | - return 'bbpc_icon_ama_ajax_forum'; | |
| 24 | - } | |
| 25 | - | |
| 26 | - public function get_keywords(): array { | |
| 27 | - return [ 'forum', 'ajax' ]; | |
| 28 | - } | |
| 29 | - | |
| 30 | - public function get_categories(): array { | |
| 31 | - return [ 'bbp-core' ]; | |
| 32 | - } | |
| 33 | - | |
| 34 | - public function get_style_depends(): array { | |
| 35 | - return [ 'bbpc-el-widgets' ]; | |
| 36 | - } | |
| 37 | - | |
| 38 | - public function get_script_depends(): array { | |
| 39 | - return [ 'bbpc-ajax' ]; | |
| 40 | - } | |
| 41 | - | |
| 42 | - protected function register_controls(): void { | |
| 43 | - //========================== Filter Options =====================// | |
| 44 | - $this->start_controls_section( | |
| 45 | - 'filter_sec', [ | |
| 46 | - 'label' => esc_html__( 'Filter Options', 'bbp-core' ), | |
| 47 | - ] | |
| 48 | - ); | |
| 49 | - | |
| 50 | - $this->add_control( | |
| 51 | - 'ppp2', [ | |
| 52 | - 'label' => esc_html__( 'Show Forums', 'bbp-core' ), | |
| 53 | - 'description' => esc_html__( 'Show the forums count at the initial view. Default is 9 forums in a row.', 'bbp-core' ), | |
| 54 | - 'type' => \Elementor\Controls_Manager::NUMBER, | |
| 55 | - 'default' => 9 | |
| 56 | - ] | |
| 57 | - ); | |
| 58 | - | |
| 59 | - $this->add_control( | |
| 60 | - 'order', [ | |
| 61 | - 'label' => esc_html__( 'Order', 'bbp-core' ), | |
| 62 | - 'type' => \Elementor\Controls_Manager::SELECT, | |
| 63 | - 'options' => [ | |
| 64 | - 'ASC' => 'ASC', | |
| 65 | - 'DESC' => 'DESC' | |
| 66 | - ], | |
| 67 | - 'default' => 'ASC' | |
| 68 | - ] | |
| 69 | - ); | |
| 70 | - | |
| 71 | - // button show hide switcher | |
| 72 | - $this->add_control( | |
| 73 | - 'filter_btns', | |
| 74 | - [ | |
| 75 | - 'label' => esc_html__( 'Tab Filter', 'bbp-core' ), | |
| 76 | - 'type' => \Elementor\Controls_Manager::SWITCHER, | |
| 77 | - 'label_on' => esc_html__( 'Show', 'bbp-core' ), | |
| 78 | - 'label_off' => esc_html__( 'Hide', 'bbp-core' ), | |
| 79 | - 'return_value' => 'yes', | |
| 80 | - 'default' => 'yes', | |
| 81 | - ] | |
| 82 | - ); | |
| 83 | - | |
| 84 | - $this->end_controls_section(); | |
| 85 | - | |
| 86 | - /** | |
| 87 | - * Styling section starts | |
| 88 | - */ | |
| 89 | - $this->start_controls_section( | |
| 90 | - 'styling_sec', [ | |
| 91 | - 'label' => esc_html__( 'Title Style', 'bbp-core' ), | |
| 92 | - 'tab' => Controls_Manager::TAB_STYLE, | |
| 93 | - ] | |
| 94 | - ); | |
| 95 | - //forum title | |
| 96 | - $this->add_control( | |
| 97 | - 'forum_heading', | |
| 98 | - [ | |
| 99 | - 'label' => esc_html__( 'Forum Title', 'bbp-core' ), | |
| 100 | - 'type' => \Elementor\Controls_Manager::HEADING, | |
| 101 | - 'separator' => 'before', | |
| 102 | - ] | |
| 103 | - ); | |
| 104 | - | |
| 105 | - | |
| 106 | - $this->add_control( | |
| 107 | - 'forum_title_color', | |
| 108 | - [ | |
| 109 | - 'label' => esc_html__( 'Color', 'bbp-core' ), | |
| 110 | - 'type' => \Elementor\Controls_Manager::COLOR, | |
| 111 | - 'selectors' => [ | |
| 112 | - '{{WRAPPER}} .single-forum-post-widget .post-title a' => 'color: {{VALUE}}', | |
| 113 | - ], | |
| 114 | - ] | |
| 115 | - ); | |
| 116 | - | |
| 117 | - $this->add_control( | |
| 118 | - 'forum_title_hover_color', | |
| 119 | - [ | |
| 120 | - 'label' => esc_html__( 'Hover Color', 'bbp-core' ), | |
| 121 | - 'type' => \Elementor\Controls_Manager::COLOR, | |
| 122 | - 'selectors' => [ | |
| 123 | - '{{WRAPPER}} .single-forum-post-widget .post-title a:hover' => 'color: {{VALUE}}', | |
| 124 | - ], | |
| 125 | - ] | |
| 126 | - ); | |
| 127 | - | |
| 128 | - $this->add_group_control( | |
| 129 | - \Elementor\Group_Control_Typography::get_type(), | |
| 130 | - [ | |
| 131 | - 'name' => 'forum_title_typography', | |
| 132 | - 'selector' => '{{WRAPPER}} .single-forum-post-widget .post-title a', | |
| 133 | - ] | |
| 134 | - ); | |
| 135 | - | |
| 136 | - // Forum meta | |
| 137 | - $this->add_control( | |
| 138 | - 'forum_meta', | |
| 139 | - [ | |
| 140 | - 'label' => esc_html__( 'Forum Meta', 'bbp-core' ), | |
| 141 | - 'type' => \Elementor\Controls_Manager::HEADING, | |
| 142 | - 'separator' => 'before', | |
| 143 | - ] | |
| 144 | - ); | |
| 145 | - | |
| 146 | - $this->add_control( | |
| 147 | - 'forum_meta_color', | |
| 148 | - [ | |
| 149 | - 'label' => esc_html__( 'Color', 'bbp-core' ), | |
| 150 | - 'type' => \Elementor\Controls_Manager::COLOR, | |
| 151 | - 'selectors' => [ | |
| 152 | - '{{WRAPPER}} .single-forum-post-widget .post-info .author,{{WRAPPER}} .single-forum-post-widget .post-info .post-time' => 'color: {{VALUE}}', | |
| 153 | - ], | |
| 154 | - ] | |
| 155 | - ); | |
| 156 | - | |
| 157 | - | |
| 158 | - $this->add_group_control( | |
| 159 | - \Elementor\Group_Control_Typography::get_type(), | |
| 160 | - [ | |
| 161 | - 'name' => 'forum_meta_typography', | |
| 162 | - 'selector' => '{{WRAPPER}} .single-forum-post-widget .post-info .author,{{WRAPPER}} .single-forum-post-widget .post-info .post-time', | |
| 163 | - ] | |
| 164 | - ); | |
| 165 | - | |
| 166 | - //parent forum | |
| 167 | - $this->add_control( | |
| 168 | - 'parent_forum', | |
| 169 | - [ | |
| 170 | - 'label' => esc_html__( 'Parent Forum', 'bbp-core' ), | |
| 171 | - 'type' => \Elementor\Controls_Manager::HEADING, | |
| 172 | - 'separator' => 'before', | |
| 173 | - ] | |
| 174 | - ); | |
| 175 | - | |
| 176 | - $this->add_control( | |
| 177 | - 'parent_forum_color', | |
| 178 | - [ | |
| 179 | - 'label' => esc_html__( 'Color', 'bbp-core' ), | |
| 180 | - 'type' => \Elementor\Controls_Manager::COLOR, | |
| 181 | - 'selectors' => [ | |
| 182 | - '{{WRAPPER}} .post-content .post-category a' => 'color: {{VALUE}}', | |
| 183 | - ], | |
| 184 | - ] | |
| 185 | - ); | |
| 186 | - | |
| 187 | - $this->add_control( | |
| 188 | - 'parent_forum_color_hover', | |
| 189 | - [ | |
| 190 | - 'label' => esc_html__( 'Hover color', 'bbp-core' ), | |
| 191 | - 'type' => \Elementor\Controls_Manager::COLOR, | |
| 192 | - 'selectors' => [ | |
| 193 | - '{{WRAPPER}} .post-content .post-category a:hover' => 'color: {{VALUE}}', | |
| 194 | - ], | |
| 195 | - ] | |
| 196 | - ); | |
| 197 | - | |
| 198 | - $this->add_group_control( | |
| 199 | - \Elementor\Group_Control_Typography::get_type(), | |
| 200 | - [ | |
| 201 | - 'name' => 'parent_forum_typo', | |
| 202 | - 'selector' => '{{WRAPPER}} .post-content .post-category a', | |
| 203 | - ] | |
| 204 | - ); | |
| 205 | - | |
| 206 | - $this->end_controls_section(); | |
| 207 | - } | |
| 208 | - | |
| 209 | - protected function render() { | |
| 210 | - $settings = $this->get_settings(); | |
| 211 | - $filter_btns = $settings['filter_btns'] ?? true; | |
| 212 | - | |
| 213 | - $topics = new WP_Query( array( | |
| 214 | - 'post_type' => 'topic', | |
| 215 | - 'posts_per_page' => ! empty( $settings['ppp2'] ) ? $settings['ppp2'] : 9, | |
| 216 | - 'order' => $settings['order'] ? $settings['order'] : 'DESC', | |
| 217 | - ) ); | |
| 218 | - ?> | |
| 219 | - | |
| 220 | - <div class="forum-post-widget" data_id="<?php echo esc_attr( $this->get_id() ); ?>"> | |
| 221 | - | |
| 222 | - <?php | |
| 223 | - if ( $filter_btns ) : | |
| 224 | - ?> | |
| 225 | - <div class="post-filter-widget mb-20 wow fadeInUp"> | |
| 226 | - <div class="single-filter-item"> | |
| 227 | - <a href="#" id="all_filt" data-forum="all" class="data-active"> | |
| 228 | - <i class="icon_grid-2x2"></i><?php esc_html_e( 'All', 'bbp-core' ) ?> | |
| 229 | - </a> | |
| 230 | - </div> | |
| 231 | - <div class="single-filter-item"> | |
| 232 | - <a href="#" id="populer_filt" data-forum="popular"> | |
| 233 | - <i class="icon_easel"></i><?php esc_html_e( 'Popular', 'bbp-core' ) ?> | |
| 234 | - </a> | |
| 235 | - </div> | |
| 236 | - <div class="single-filter-item"> | |
| 237 | - <a href="#" id="featured_filt" data-forum="featured"> | |
| 238 | - <i class="icon_ribbon_alt"></i><?php esc_html_e( 'Featured', 'bbp-core' ) ?> | |
| 239 | - </a> | |
| 240 | - </div> | |
| 241 | - <div class="single-filter-item"> | |
| 242 | - <a href="#" id="recent_filt" data-forum="recent"> | |
| 243 | - <i class="icon_clock_alt"></i><?php esc_html_e( 'Recent', 'bbp-core' ) ?> | |
| 244 | - </a> | |
| 245 | - </div> | |
| 246 | - <div class="single-filter-item"> | |
| 247 | - <a href="#" id="unsolved_filt" data-forum="unsolved"> | |
| 248 | - <i class="icon_close_alt2"></i><?php esc_html_e( 'Unsolved', 'bbp-core' ) ?> | |
| 249 | - </a> | |
| 250 | - </div> | |
| 251 | - <div class="single-filter-item"> | |
| 252 | - <a href="#" id="solved_filt" data-forum="solved"> | |
| 253 | - <i class="icon_check_alt2"></i><?php esc_html_e( 'Solved', 'bbp-core' ) ?> | |
| 254 | - </a> | |
| 255 | - </div> | |
| 256 | - </div> | |
| 257 | - <?php | |
| 258 | - endif; | |
| 259 | - ?> | |
| 260 | - | |
| 261 | - <div id="aj-post-filter-widget"> | |
| 262 | - <?php | |
| 263 | - $delay = 0.0; | |
| 264 | - $i = 0; | |
| 265 | - while ( $topics->have_posts() ) : $topics->the_post(); | |
| 266 | - $topic_id = $topics->posts[ $i ]->ID; | |
| 267 | - $vote_count = get_post_meta( $topic_id, "bbpv-votes", true ); | |
| 268 | - $forum_id = bbp_get_topic_forum_id(); | |
| 269 | - ?> | |
| 270 | - <div class="single-forum-post-widget wow fadeInUp" data-wow-delay="<?php echo $delay ?>s"> | |
| 271 | - <div class="post-content"> | |
| 272 | - <div class="post-title"> | |
| 273 | - <h6><a href="<?php the_permalink(); ?>"> <?php the_title() ?> </a></h6> | |
| 274 | - </div> | |
| 275 | - <div class="post-info"> | |
| 276 | - <div class="author"> | |
| 277 | - <img src="<?php echo BBPC_IMG . '/forum_tab/user-circle-alt.svg' ?>" alt="<?php esc_attr_e( 'User circle alt icon', | |
| 278 | - 'bbpc-core' ); ?>"> | |
| 279 | - <?php | |
| 280 | - echo bbp_get_topic_author_link( | |
| 281 | - array( | |
| 282 | - 'post_id' => $topic_id, | |
| 283 | - 'type' => 'name' | |
| 284 | - ) | |
| 285 | - ); | |
| 286 | - ?> | |
| 287 | - </div> | |
| 288 | - | |
| 289 | - <div class="post-time"> | |
| 290 | - <img src="<?php echo BBPC_IMG . '/forum_tab/time-outline.svg' ?>" | |
| 291 | - alt="<?php esc_attr_e( 'Time outline icon', 'bbpc-core' ); ?>"> | |
| 292 | - <?php bbp_forum_last_active_time( get_the_ID() ); ?> | |
| 293 | - </div> | |
| 294 | - </div> | |
| 295 | - | |
| 296 | - <div class="post-category"> | |
| 297 | - <a href="<?php echo get_the_permalink( $forum_id ) ?>"> | |
| 298 | - <?php echo get_the_post_thumbnail( $forum_id ); ?> | |
| 299 | - <?php echo bbp_get_topic_forum_title(); ?> | |
| 300 | - </a> | |
| 301 | - </div> | |
| 302 | - </div> | |
| 303 | - <div class="post-reach"> | |
| 304 | - <div class="post-view"> | |
| 305 | - <img src="<?php echo BBPC_IMG . '/forum_tab/eye-outline.svg' ?>" alt="<?php esc_attr_e( 'Eye outline icon', 'bbpc-core' ); ?>"> | |
| 306 | - | |
| 307 | - <?php | |
| 308 | - bbp_topic_view_count( $topic_id ); | |
| 309 | - echo ' '; | |
| 310 | - esc_html_e( 'Views', 'bbp-core' ); | |
| 311 | - ?> | |
| 312 | - </div> | |
| 313 | - <div class="post-like"> | |
| 314 | - <img src="<?php echo BBPC_IMG . '/forum_tab/thumbs-up-outline.svg' ?>" | |
| 315 | - alt="<?php esc_attr_e( 'Thumbs-up outline icon', 'bbpc-core' ); ?>"> | |
| 316 | - | |
| 317 | - <?php | |
| 318 | - if ( $vote_count ) { | |
| 319 | - echo $vote_count; | |
| 320 | - } else { | |
| 321 | - echo "0"; | |
| 322 | - } | |
| 323 | - | |
| 324 | - echo ' '; | |
| 325 | - esc_html_e( 'Likes', 'bbp-core' ); | |
| 326 | - ?> | |
| 327 | - </div> | |
| 328 | - <div class="post-comment"> | |
| 329 | - <img src="<?php echo BBPC_IMG . '/forum_tab/chatbubbles-outline.svg' ?>" | |
| 330 | - alt="<?php esc_attr_e( 'Chat bubbles icon', 'bbpc-core' ); ?>"> | |
| 331 | - <?php | |
| 332 | - bbp_topic_reply_count( $topic_id ); | |
| 333 | - echo ' '; | |
| 334 | - esc_html_e( 'Replies', 'bbp-core' ); | |
| 335 | - ?> | |
| 336 | - </div> | |
| 337 | - </div> | |
| 338 | - </div> | |
| 339 | - <?php | |
| 340 | - $delay += 0.2; | |
| 341 | - if ( $delay > 0.6 ) { | |
| 342 | - $delay = 0.0; | |
| 343 | - } | |
| 344 | - $i ++; | |
| 345 | - endwhile; | |
| 346 | - unset( $delay ); | |
| 347 | - unset( $i ); | |
| 348 | - wp_reset_postdata(); | |
| 349 | - ?> | |
| 350 | - </div> | |
| 351 | - </div> | |
| 352 | - <?php | |
| 353 | - } | |
| 1 | +<?php | |
| 2 | +namespace admin\Elementor; | |
| 3 | + | |
| 4 | +use Elementor\Controls_Manager; | |
| 5 | +use Elementor\Widget_Base; | |
| 6 | +use WP_Query; | |
| 7 | + | |
| 8 | +// Exit if accessed directly | |
| 9 | +if ( ! defined( 'ABSPATH' ) ) { | |
| 10 | + exit; | |
| 11 | +} | |
| 12 | + | |
| 13 | +class Forum_Ajax extends Widget_Base { | |
| 14 | + public function get_name(): string { | |
| 15 | + return 'ama_ajax_forum'; | |
| 16 | + } | |
| 17 | + | |
| 18 | + public function get_title(): string { | |
| 19 | + return esc_html__( 'Forumax Ajax Forums', 'forumax' ); | |
| 20 | + } | |
| 21 | + | |
| 22 | + public function get_icon(): string { | |
| 23 | + return 'bbpc_icon_ama_ajax_forum'; | |
| 24 | + } | |
| 25 | + | |
| 26 | + public function get_keywords(): array { | |
| 27 | + return [ 'forum', 'ajax' ]; | |
| 28 | + } | |
| 29 | + | |
| 30 | + public function get_categories(): array { | |
| 31 | + return [ 'forumax' ]; | |
| 32 | + } | |
| 33 | + | |
| 34 | + public function get_style_depends(): array { | |
| 35 | + return [ 'bbpc-el-widgets' ]; | |
| 36 | + } | |
| 37 | + | |
| 38 | + public function get_script_depends(): array { | |
| 39 | + return [ 'bbpc-ajax' ]; | |
| 40 | + } | |
| 41 | + | |
| 42 | + protected function register_controls(): void { | |
| 43 | + //========================== Filter Options =====================// | |
| 44 | + $this->start_controls_section( | |
| 45 | + 'filter_sec', [ | |
| 46 | + 'label' => esc_html__( 'Filter Options', 'forumax' ), | |
| 47 | + ] | |
| 48 | + ); | |
| 49 | + | |
| 50 | + $this->add_control( | |
| 51 | + 'ppp2', [ | |
| 52 | + 'label' => esc_html__( 'Show Forums', 'forumax' ), | |
| 53 | + 'description' => esc_html__( 'Show the forums count at the initial view. Default is 9 forums in a row.', 'forumax' ), | |
| 54 | + 'type' => \Elementor\Controls_Manager::NUMBER, | |
| 55 | + 'default' => 9 | |
| 56 | + ] | |
| 57 | + ); | |
| 58 | + | |
| 59 | + $this->add_control( | |
| 60 | + 'order', [ | |
| 61 | + 'label' => esc_html__( 'Order', 'forumax' ), | |
| 62 | + 'type' => \Elementor\Controls_Manager::SELECT, | |
| 63 | + 'options' => [ | |
| 64 | + 'ASC' => 'ASC', | |
| 65 | + 'DESC' => 'DESC' | |
| 66 | + ], | |
| 67 | + 'default' => 'ASC' | |
| 68 | + ] | |
| 69 | + ); | |
| 70 | + | |
| 71 | + // button show hide switcher | |
| 72 | + $this->add_control( | |
| 73 | + 'filter_btns', | |
| 74 | + [ | |
| 75 | + 'label' => esc_html__( 'Tab Filter', 'forumax' ), | |
| 76 | + 'type' => \Elementor\Controls_Manager::SWITCHER, | |
| 77 | + 'label_on' => esc_html__( 'Show', 'forumax' ), | |
| 78 | + 'label_off' => esc_html__( 'Hide', 'forumax' ), | |
| 79 | + 'return_value' => 'yes', | |
| 80 | + 'default' => 'yes', | |
| 81 | + ] | |
| 82 | + ); | |
| 83 | + | |
| 84 | + $this->end_controls_section(); | |
| 85 | + | |
| 86 | + /** | |
| 87 | + * Styling section starts | |
| 88 | + */ | |
| 89 | + $this->start_controls_section( | |
| 90 | + 'styling_sec', [ | |
| 91 | + 'label' => esc_html__( 'Title Style', 'forumax' ), | |
| 92 | + 'tab' => Controls_Manager::TAB_STYLE, | |
| 93 | + ] | |
| 94 | + ); | |
| 95 | + //forum title | |
| 96 | + $this->add_control( | |
| 97 | + 'forum_heading', | |
| 98 | + [ | |
| 99 | + 'label' => esc_html__( 'Forum Title', 'forumax' ), | |
| 100 | + 'type' => \Elementor\Controls_Manager::HEADING, | |
| 101 | + 'separator' => 'before', | |
| 102 | + ] | |
| 103 | + ); | |
| 104 | + | |
| 105 | + | |
| 106 | + $this->add_control( | |
| 107 | + 'forum_title_color', | |
| 108 | + [ | |
| 109 | + 'label' => esc_html__( 'Color', 'forumax' ), | |
| 110 | + 'type' => \Elementor\Controls_Manager::COLOR, | |
| 111 | + 'selectors' => [ | |
| 112 | + '{{WRAPPER}} .single-forum-post-widget .post-title a' => 'color: {{VALUE}}', | |
| 113 | + ], | |
| 114 | + ] | |
| 115 | + ); | |
| 116 | + | |
| 117 | + $this->add_control( | |
| 118 | + 'forum_title_hover_color', | |
| 119 | + [ | |
| 120 | + 'label' => esc_html__( 'Hover Color', 'forumax' ), | |
| 121 | + 'type' => \Elementor\Controls_Manager::COLOR, | |
| 122 | + 'selectors' => [ | |
| 123 | + '{{WRAPPER}} .single-forum-post-widget .post-title a:hover' => 'color: {{VALUE}}', | |
| 124 | + ], | |
| 125 | + ] | |
| 126 | + ); | |
| 127 | + | |
| 128 | + $this->add_group_control( | |
| 129 | + \Elementor\Group_Control_Typography::get_type(), | |
| 130 | + [ | |
| 131 | + 'name' => 'forum_title_typography', | |
| 132 | + 'selector' => '{{WRAPPER}} .single-forum-post-widget .post-title a', | |
| 133 | + ] | |
| 134 | + ); | |
| 135 | + | |
| 136 | + // Forum meta | |
| 137 | + $this->add_control( | |
| 138 | + 'forum_meta', | |
| 139 | + [ | |
| 140 | + 'label' => esc_html__( 'Forum Meta', 'forumax' ), | |
| 141 | + 'type' => \Elementor\Controls_Manager::HEADING, | |
| 142 | + 'separator' => 'before', | |
| 143 | + ] | |
| 144 | + ); | |
| 145 | + | |
| 146 | + $this->add_control( | |
| 147 | + 'forum_meta_color', | |
| 148 | + [ | |
| 149 | + 'label' => esc_html__( 'Color', 'forumax' ), | |
| 150 | + 'type' => \Elementor\Controls_Manager::COLOR, | |
| 151 | + 'selectors' => [ | |
| 152 | + '{{WRAPPER}} .single-forum-post-widget .post-info .author,{{WRAPPER}} .single-forum-post-widget .post-info .post-time' => 'color: {{VALUE}}', | |
| 153 | + ], | |
| 154 | + ] | |
| 155 | + ); | |
| 156 | + | |
| 157 | + | |
| 158 | + $this->add_group_control( | |
| 159 | + \Elementor\Group_Control_Typography::get_type(), | |
| 160 | + [ | |
| 161 | + 'name' => 'forum_meta_typography', | |
| 162 | + 'selector' => '{{WRAPPER}} .single-forum-post-widget .post-info .author,{{WRAPPER}} .single-forum-post-widget .post-info .post-time', | |
| 163 | + ] | |
| 164 | + ); | |
| 165 | + | |
| 166 | + //parent forum | |
| 167 | + $this->add_control( | |
| 168 | + 'parent_forum', | |
| 169 | + [ | |
| 170 | + 'label' => esc_html__( 'Parent Forum', 'forumax' ), | |
| 171 | + 'type' => \Elementor\Controls_Manager::HEADING, | |
| 172 | + 'separator' => 'before', | |
| 173 | + ] | |
| 174 | + ); | |
| 175 | + | |
| 176 | + $this->add_control( | |
| 177 | + 'parent_forum_color', | |
| 178 | + [ | |
| 179 | + 'label' => esc_html__( 'Color', 'forumax' ), | |
| 180 | + 'type' => \Elementor\Controls_Manager::COLOR, | |
| 181 | + 'selectors' => [ | |
| 182 | + '{{WRAPPER}} .post-content .post-category a' => 'color: {{VALUE}}', | |
| 183 | + ], | |
| 184 | + ] | |
| 185 | + ); | |
| 186 | + | |
| 187 | + $this->add_control( | |
| 188 | + 'parent_forum_color_hover', | |
| 189 | + [ | |
| 190 | + 'label' => esc_html__( 'Hover color', 'forumax' ), | |
| 191 | + 'type' => \Elementor\Controls_Manager::COLOR, | |
| 192 | + 'selectors' => [ | |
| 193 | + '{{WRAPPER}} .post-content .post-category a:hover' => 'color: {{VALUE}}', | |
| 194 | + ], | |
| 195 | + ] | |
| 196 | + ); | |
| 197 | + | |
| 198 | + $this->add_group_control( | |
| 199 | + \Elementor\Group_Control_Typography::get_type(), | |
| 200 | + [ | |
| 201 | + 'name' => 'parent_forum_typo', | |
| 202 | + 'selector' => '{{WRAPPER}} .post-content .post-category a', | |
| 203 | + ] | |
| 204 | + ); | |
| 205 | + | |
| 206 | + $this->end_controls_section(); | |
| 207 | + } | |
| 208 | + | |
| 209 | + protected function render() { | |
| 210 | + $settings = $this->get_settings(); | |
| 211 | + $filter_btns = $settings['filter_btns'] ?? true; | |
| 212 | + | |
| 213 | + $topics = new WP_Query( array( | |
| 214 | + 'post_type' => 'topic', | |
| 215 | + 'posts_per_page' => ! empty( $settings['ppp2'] ) ? $settings['ppp2'] : 9, | |
| 216 | + 'order' => $settings['order'] ? $settings['order'] : 'DESC', | |
| 217 | + ) ); | |
| 218 | + ?> | |
| 219 | + | |
| 220 | + <div class="forum-post-widget" data_id="<?php echo esc_attr( $this->get_id() ); ?>"> | |
| 221 | + | |
| 222 | + <?php | |
| 223 | + if ( $filter_btns ) : | |
| 224 | + ?> | |
| 225 | + <div class="post-filter-widget mb-20 wow fadeInUp"> | |
| 226 | + <div class="single-filter-item"> | |
| 227 | + <a href="#" id="all_filt" data-forum="all" class="data-active"> | |
| 228 | + <i class="icon_grid-2x2"></i><?php esc_html_e( 'All', 'forumax' ) ?> | |
| 229 | + </a> | |
| 230 | + </div> | |
| 231 | + <div class="single-filter-item"> | |
| 232 | + <a href="#" id="populer_filt" data-forum="popular"> | |
| 233 | + <i class="icon_easel"></i><?php esc_html_e( 'Popular', 'forumax' ) ?> | |
| 234 | + </a> | |
| 235 | + </div> | |
| 236 | + <div class="single-filter-item"> | |
| 237 | + <a href="#" id="featured_filt" data-forum="featured"> | |
| 238 | + <i class="icon_ribbon_alt"></i><?php esc_html_e( 'Featured', 'forumax' ) ?> | |
| 239 | + </a> | |
| 240 | + </div> | |
| 241 | + <div class="single-filter-item"> | |
| 242 | + <a href="#" id="recent_filt" data-forum="recent"> | |
| 243 | + <i class="icon_clock_alt"></i><?php esc_html_e( 'Recent', 'forumax' ) ?> | |
| 244 | + </a> | |
| 245 | + </div> | |
| 246 | + <div class="single-filter-item"> | |
| 247 | + <a href="#" id="unloved_filt" data-forum="unloved"> | |
| 248 | + <i class="icon_close_alt2"></i><?php esc_html_e( 'Unloved', 'forumax' ) ?> | |
| 249 | + </a> | |
| 250 | + </div> | |
| 251 | + <div class="single-filter-item"> | |
| 252 | + <a href="#" id="loved_filt" data-forum="loved"> | |
| 253 | + <i class="icon_check_alt2"></i><?php esc_html_e( 'Loved', 'forumax' ) ?> | |
| 254 | + </a> | |
| 255 | + </div> | |
| 256 | + </div> | |
| 257 | + <?php | |
| 258 | + endif; | |
| 259 | + ?> | |
| 260 | + | |
| 261 | + <div id="aj-post-filter-widget"> | |
| 262 | + <?php | |
| 263 | + $delay = 0.0; | |
| 264 | + $i = 0; | |
| 265 | + while ( $topics->have_posts() ) : $topics->the_post(); | |
| 266 | + $topic_id = $topics->posts[ $i ]->ID; | |
| 267 | + $vote_count = get_post_meta( $topic_id, "bbpv-votes", true ); | |
| 268 | + $forum_id = bbp_get_topic_forum_id(); | |
| 269 | + ?> | |
| 270 | + <div class="single-forum-post-widget wow fadeInUp" data-wow-delay="<?php echo esc_attr( $delay ); ?>s"> | |
| 271 | + <div class="post-content"> | |
| 272 | + <div class="post-title"> | |
| 273 | + <h6><a href="<?php the_permalink(); ?>"> <?php the_title() ?> </a></h6> | |
| 274 | + </div> | |
| 275 | + <div class="post-info"> | |
| 276 | + <div class="author"> | |
| 277 | + <img src="<?php echo esc_url( FORUMAX_IMG . 'forum_tab/user-circle-alt.svg' ); ?>" alt="<?php esc_attr_e( 'User circle alt icon', | |
| 278 | + 'forumax' ); ?>"> | |
| 279 | + <?php | |
| 280 | + echo wp_kses_post( bbp_get_topic_author_link( | |
| 281 | + array( | |
| 282 | + 'post_id' => $topic_id, | |
| 283 | + 'type' => 'name' | |
| 284 | + ) | |
| 285 | + ) ); | |
| 286 | + ?> | |
| 287 | + </div> | |
| 288 | + | |
| 289 | + <div class="post-time"> | |
| 290 | + <img src="<?php echo esc_url( FORUMAX_IMG . 'forum_tab/time-outline.svg' ); ?>" | |
| 291 | + alt="<?php esc_attr_e( 'Time outline icon', 'forumax' ); ?>"> | |
| 292 | + <?php bbp_forum_last_active_time( get_the_ID() ); ?> | |
| 293 | + </div> | |
| 294 | + </div> | |
| 295 | + | |
| 296 | + <div class="post-category"> | |
| 297 | + <a href="<?php echo esc_url( get_the_permalink( $forum_id ) ); ?>"> | |
| 298 | + <?php echo get_the_post_thumbnail( $forum_id ); ?> | |
| 299 | + <?php echo esc_html( bbp_get_topic_forum_title() ); ?> | |
| 300 | + </a> | |
| 301 | + </div> | |
| 302 | + </div> | |
| 303 | + <div class="post-reach"> | |
| 304 | + <div class="post-view"> | |
| 305 | + <img src="<?php echo esc_url( FORUMAX_IMG . 'forum_tab/eye-outline.svg' ); ?>" alt="<?php esc_attr_e( 'Eye outline icon', 'forumax' ); ?>"> | |
| 306 | + | |
| 307 | + <?php | |
| 308 | + forumax_topic_view_count( $topic_id ); | |
| 309 | + echo ' '; | |
| 310 | + esc_html_e( 'Views', 'forumax' ); | |
| 311 | + ?> | |
| 312 | + </div> | |
| 313 | + <div class="post-like"> | |
| 314 | + <img src="<?php echo esc_url( FORUMAX_IMG . 'forum_tab/thumbs-up-outline.svg' ); ?>" | |
| 315 | + alt="<?php esc_attr_e( 'Thumbs-up outline icon', 'forumax' ); ?>"> | |
| 316 | + | |
| 317 | + <?php | |
| 318 | + if ( $vote_count ) { | |
| 319 | + echo esc_html( $vote_count ); | |
| 320 | + } else { | |
| 321 | + echo "0"; | |
| 322 | + } | |
| 323 | + | |
| 324 | + echo ' '; | |
| 325 | + esc_html_e( 'Likes', 'forumax' ); | |
| 326 | + ?> | |
| 327 | + </div> | |
| 328 | + <div class="post-comment"> | |
| 329 | + <img src="<?php echo esc_url( FORUMAX_IMG . 'forum_tab/chatbubbles-outline.svg' ); ?>" | |
| 330 | + alt="<?php esc_attr_e( 'Chat bubbles icon', 'forumax' ); ?>"> | |
| 331 | + <?php | |
| 332 | + bbp_topic_reply_count( $topic_id ); | |
| 333 | + echo ' '; | |
| 334 | + esc_html_e( 'Replies', 'forumax' ); | |
| 335 | + ?> | |
| 336 | + </div> | |
| 337 | + </div> | |
| 338 | + </div> | |
| 339 | + <?php | |
| 340 | + $delay += 0.2; | |
| 341 | + if ( $delay > 0.6 ) { | |
| 342 | + $delay = 0.0; | |
| 343 | + } | |
| 344 | + $i ++; | |
| 345 | + endwhile; | |
| 346 | + unset( $delay ); | |
| 347 | + unset( $i ); | |
| 348 | + wp_reset_postdata(); | |
| 349 | + ?> | |
| 350 | + </div> | |
| 351 | + </div> | |
| 352 | + <?php | |
| 353 | + } | |
| 354 | 354 | } |