bbp_get_forum_topics_link

Return the topics link of the forum.

Description

bbp_get_forum_topics_link( (int) $forum_id = 0 ); 

Parameters (1)

0. $forum_id — Optional. (int)
Topic id

Usage

  1. if ( !function_exists( 'bbp_get_forum_topics_link' ) ) { 
  2. require_once ABSPATH . PLUGINDIR . 'bbpress/includes/forums/template.php'; 
  3.  
  4. // Optional. Topic id 
  5. $forum_id = -1; 
  6.  
  7. // NOTICE! Understand what this does before running. 
  8. $result = bbp_get_forum_topics_link($forum_id); 
  9.  

Defined (1)

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

/includes/forums/template.php  
  1. function bbp_get_forum_topics_link( $forum_id = 0 ) { 
  2. $forum = bbp_get_forum( $forum_id ); 
  3. $forum_id = $forum->ID; 
  4. $topics = sprintf( _n( '%s topic', '%s topics', bbp_get_forum_topic_count( $forum_id, true, false ), bbpress ), bbp_get_forum_topic_count( $forum_id ) ); 
  5. $retval = ''; 
  6.  
  7. // First link never has view=all 
  8. if ( bbp_get_view_all( 'edit_others_topics' ) ) 
  9. $retval .= "<a href='" . esc_url( bbp_remove_view_all( bbp_get_forum_permalink( $forum_id ) ) ) . "'>" . esc_html( $topics ) . "</a>"; 
  10. else 
  11. $retval .= esc_html( $topics ); 
  12.  
  13. // Get deleted topics 
  14. $deleted = bbp_get_forum_topic_count_hidden( $forum_id ); 
  15.  
  16. // This forum has hidden topics 
  17. if ( !empty( $deleted ) && current_user_can( 'edit_others_topics' ) ) { 
  18.  
  19. // Extra text 
  20. $extra = sprintf( __( ' (+ %d hidden)', bbpress ), $deleted ); 
  21.  
  22. // No link 
  23. if ( bbp_get_view_all() ) { 
  24. $retval .= " $extra"; 
  25.  
  26. // Link 
  27. } else { 
  28. $retval .= " <a href='" . esc_url( bbp_add_view_all( bbp_get_forum_permalink( $forum_id ), true ) ) . "'>" . esc_html( $extra ) . "</a>"; 
  29.  
  30. return apply_filters( 'bbp_get_forum_topics_link', $retval, $forum_id );