BBP_Forums_Widget::widget( mixed $args, array $instance )
Displays the output, the forum list
Description
Parameters
- $args
-
(Required) Arguments
- $instance
-
(Required) Instance
Source
File: bp-forums/common/widgets.php
577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 | public function widget( $args , $instance ) { // Get widget settings $settings = $this ->parse_settings( $instance ); // Typical WordPress filter $settings [ 'title' ] = apply_filters( 'widget_title' , $settings [ 'title' ], $instance , $this ->id_base ); // Forums filter $settings [ 'title' ] = apply_filters( 'bbp_forum_widget_title' , $settings [ 'title' ], $instance , $this ->id_base ); // Note: private and hidden forums will be excluded via the // bbp_pre_get_posts_normalize_forum_visibility action and function. $widget_query = new WP_Query( array ( 'post_type' => bbp_get_forum_post_type(), //'post_parent' => $settings['parent_forum'], 'post_parent' => 0, 'post_status' => bbp_get_public_status_id(), 'posts_per_page' => bbp_get_forums_per_page(), 'ignore_sticky_posts' => true, 'no_found_rows' => true, 'orderby' => 'menu_order title' , 'order' => 'ASC' ) ); // Bail if no posts if ( ! $widget_query ->have_posts() ) { return ; } echo $args [ 'before_widget' ]; if ( ! empty ( $settings [ 'title' ] ) ) { echo $args [ 'before_title' ] . $settings [ 'title' ] . $args [ 'after_title' ]; } ?> <ul class = "bb-sidebar-forums" > <?php while ( $widget_query ->have_posts() ) : $widget_query ->the_post(); ?> <li> <a class = "bbp-forum-title" href= "<?php bbp_forum_permalink( $widget_query->post->ID ); ?>" ><?php bbp_forum_title( $widget_query ->post->ID ); ?></a> <span class = "topics-count" > <?php $topics_count = bbp_get_forum_topic_count( $widget_query ->post->ID ); echo $topics_count ; ?> </span> <?php $r = array ( 'before' => '<ul class="bb-sidebar-forums">' , 'after' => '</ul>' , 'link_before' => '<li class="bbp-sub-forum">' , 'link_after' => '</li>' , 'count_before' => ' (' , 'count_after' => ')' , 'count_sep' => ', ' , 'separator' => ' ' , 'forum_id' => $widget_query ->post->ID, 'show_topic_count' => false, 'show_reply_count' => false, ); bbp_list_forums( $r ); ?> </li> <?php endwhile ; ?> </ul> <?php echo $args [ 'after_widget' ]; // Reset the $post global wp_reset_postdata(); } |
Changelog
Version | Description |
---|---|
bbPress (r2653) | Introduced. |
Questions?
We're always happy to help with code or other questions you might have! Search our developer docs, contact support, or connect with our sales team.