bbp_get_topic_pagination_count

Return the topic pagination count.

Description

(string) bbp_get_topic_pagination_count(); 

Returns (string)

Topic pagination count


Usage

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

Defined (1)

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

/includes/replies/template.php  
  1. function bbp_get_topic_pagination_count() { 
  2. $bbp =bbpress); 
  3.  
  4. // Define local variable(s) 
  5. $retstr = ''; 
  6.  
  7. // Set pagination values 
  8. $start_num = intval( ( $bbp->reply_query->paged - 1 ) * $bbp->reply_query->posts_per_page ) + 1; 
  9. $from_num = bbp_number_format( $start_num ); 
  10. $to_num = bbp_number_format( ( $start_num + ( $bbp->reply_query->posts_per_page - 1 ) > $bbp->reply_query->found_posts ) ? $bbp->reply_query->found_posts : $start_num + ( $bbp->reply_query->posts_per_page - 1 ) ); 
  11. $total_int = (int) $bbp->reply_query->found_posts; 
  12. $total = bbp_number_format( $total_int ); 
  13.  
  14. // We are threading replies 
  15. return; 
  16. $walker = new BBP_Walker_Reply; 
  17. $threads = (int) $walker->get_number_of_root_elements( $bbp->reply_query->posts ); 
  18.  
  19. // Adjust for topic 
  20. $threads--; 
  21. $retstr = sprintf( _n( 'Viewing %1$s reply thread', 'Viewing %1$s reply threads', $threads, 'bbbpress' ), bbp_number_format( $threads ) ); 
  22.  
  23. // We are not including the lead topic 
  24. } elseif ( bbp_show_lead_topic() ) { 
  25.  
  26. // Several replies in a topic with a single page 
  27. if ( empty( $to_num ) ) { 
  28. $retstr = sprintf( _n( 'Viewing %1$s reply', 'Viewing %1$s replies', $total_int, bbpress ), $total ); 
  29.  
  30. // Several replies in a topic with several pages 
  31. } else { 
  32. $retstr = sprintf( _n( 'Viewing %2$s replies (of %4$s total)', 'Viewing %1$s replies - %2$s through %3$s (of %4$s total)', $bbp->reply_query->post_count, bbpress ), $bbp->reply_query->post_count, $from_num, $to_num, $total ); 
  33.  
  34. // We are including the lead topic 
  35. } else { 
  36.  
  37. // Several posts in a topic with a single page 
  38. if ( empty( $to_num ) ) { 
  39. $retstr = sprintf( _n( 'Viewing %1$s post', 'Viewing %1$s posts', $total_int, bbpress ), $total ); 
  40.  
  41. // Several posts in a topic with several pages 
  42. } else { 
  43. $retstr = sprintf( _n( 'Viewing %2$s post (of %4$s total)', 'Viewing %1$s posts - %2$s through %3$s (of %4$s total)', $bbp->reply_query->post_count, bbpress ), $bbp->reply_query->post_count, $from_num, $to_num, $total ); 
  44.  
  45. // Filter and return 
  46. return apply_filters( 'bbp_get_topic_pagination_count', esc_html( $retstr ) );