bbp_get_single_forum_description

Return a fancy description of the current forum, including total topics, total replies, and last activity.

Description

(string) bbp_get_single_forum_description( (string) $args = '' ); 

Returns (string)

Filtered forum description

Parameters (1)

0. $args — Optional. (string) => ''
This function supports these arguments: - forum_id: Forum id - before: Before the text - after: After the text - size: Size of the avatar

Usage

  1. if ( !function_exists( 'bbp_get_single_forum_description' ) ) { 
  2. require_once ABSPATH . PLUGINDIR . 'bbpress/includes/forums/template.php'; 
  3. $args = ''; 
  4.  
  5. // NOTICE! Understand what this does before running. 
  6. $result = bbp_get_single_forum_description($args); 
  7.  

Defined (1)

The function is defined in the following location(s).

/includes/forums/template.php  
  1. function bbp_get_single_forum_description( $args = '' ) { 
  2.  
  3. // Parse arguments against default values 
  4. $r = bbp_parse_args( $args, array( 
  5. 'forum_id' => 0,  
  6. 'before' => '<div class="bbp-template-notice info"><p class="bbp-forum-description">',  
  7. 'after' => '</p></div>',  
  8. 'size' => 14,  
  9. 'feed' => true 
  10. ), 'get_single_forum_description' ); 
  11.  
  12. // Validate forum_id 
  13. $forum_id = bbp_get_forum_id( $r['forum_id'] ); 
  14.  
  15. // Unhook the 'view all' query var adder 
  16.  
  17. // Get some forum data 
  18. $tc_int = bbp_get_forum_topic_count( $forum_id, false ); 
  19. $rc_int = bbp_get_forum_reply_count( $forum_id, false ); 
  20. $topic_count = bbp_get_forum_topic_count( $forum_id ); 
  21. $reply_count = bbp_get_forum_reply_count( $forum_id ); 
  22. $last_active = bbp_get_forum_last_active_id( $forum_id ); 
  23.  
  24. // Has replies 
  25. if ( !empty( $reply_count ) ) { 
  26. $reply_text = sprintf( _n( '%s reply', '%s replies', $rc_int, bbpress ), $reply_count ); 
  27.  
  28. // Forum has active data 
  29. if ( !empty( $last_active ) ) { 
  30. $topic_text = bbp_get_forum_topics_link( $forum_id ); 
  31. $time_since = bbp_get_forum_freshness_link( $forum_id ); 
  32. $last_updated_by = bbp_get_author_link( array( 'post_id' => $last_active, 'size' => $r['size'] ) ); 
  33.  
  34. // Forum has no last active data 
  35. } else { 
  36. $topic_text = sprintf( _n( '%s topic', '%s topics', $tc_int, bbpress ), $topic_count ); 
  37.  
  38. // Forum has active data 
  39. if ( !empty( $last_active ) ) { 
  40.  
  41. if ( !empty( $reply_count ) ) { 
  42.  
  43. if ( bbp_is_forum_category( $forum_id ) ) { 
  44. $retstr = sprintf( esc_html__( 'This category contains %1$s and %2$s, and was last updated by %3$s %4$s.', bbpress ), $topic_text, $reply_text, $last_updated_by, $time_since ); 
  45. } else { 
  46. $retstr = sprintf( esc_html__( 'This forum contains %1$s and %2$s, and was last updated by %3$s %4$s.', bbpress ), $topic_text, $reply_text, $last_updated_by, $time_since ); 
  47.  
  48. } else { 
  49.  
  50. if ( bbp_is_forum_category( $forum_id ) ) { 
  51. $retstr = sprintf( esc_html__( 'This category contains %1$s, and was last updated by %2$s %3$s.', bbpress ), $topic_text, $last_updated_by, $time_since ); 
  52. } else { 
  53. $retstr = sprintf( esc_html__( 'This forum contains %1$s, and was last updated by %2$s %3$s.', bbpress ), $topic_text, $last_updated_by, $time_since ); 
  54.  
  55. // Forum has no last active data 
  56. } else { 
  57.  
  58. if ( !empty( $reply_count ) ) { 
  59.  
  60. if ( bbp_is_forum_category( $forum_id ) ) { 
  61. $retstr = sprintf( esc_html__( 'This category contains %1$s and %2$s.', bbpress ), $topic_text, $reply_text ); 
  62. } else { 
  63. $retstr = sprintf( esc_html__( 'This forum contains %1$s and %2$s.', bbpress ), $topic_text, $reply_text ); 
  64.  
  65. } else { 
  66.  
  67. if ( !empty( $topic_count ) ) { 
  68.  
  69. if ( bbp_is_forum_category( $forum_id ) ) { 
  70. $retstr = sprintf( esc_html__( 'This category contains %1$s.', bbpress ), $topic_text ); 
  71. } else { 
  72. $retstr = sprintf( esc_html__( 'This forum contains %1$s.', bbpress ), $topic_text ); 
  73.  
  74. } else { 
  75. $retstr = esc_html__( 'This forum is empty.', bbpress ); 
  76.  
  77. // Add feeds 
  78. //$feed_links = ( !empty( $r['feed'] ) ) ? bbp_get_forum_topics_feed_link ( $forum_id ) . bbp_get_forum_replies_feed_link( $forum_id ) : ''; 
  79.  
  80. // Add the 'view all' filter back 
  81.  
  82. // Combine the elements together 
  83. $retstr = $r['before'] . $retstr . $r['after']; 
  84.  
  85. // Return filtered result 
  86. return apply_filters( 'bbp_get_single_forum_description', $retstr, $r );