bbp_get_forum_pagination_count()
Return the pagination count
Description Description
Return Return
(string) Forum Pagination count
Source Source
File: includes/topics/template.php
function bbp_get_forum_pagination_count() {
$bbp = bbpress();
// Define local variable(s)
$retstr = '';
// Topic query exists
if ( ! empty( $bbp->topic_query ) ) {
// Set pagination values
$count_int = intval( $bbp->topic_query->post_count );
$start_num = intval( ( $bbp->topic_query->paged - 1 ) * $bbp->topic_query->posts_per_page ) + 1;
$total_int = ! empty( $bbp->topic_query->found_posts )
? (int) $bbp->topic_query->found_posts
: $count_int;
// Format numbers for display
$count_num = bbp_number_format( $count_int );
$from_num = bbp_number_format( $start_num );
$total = bbp_number_format( $total_int );
$to_num = bbp_number_format( ( $start_num + ( $bbp->topic_query->posts_per_page - 1 ) > $bbp->topic_query->found_posts )
? $bbp->topic_query->found_posts
: $start_num + ( $bbp->topic_query->posts_per_page - 1 ) );
// Several topics in a forum with a single page
if ( empty( $to_num ) ) {
$retstr = sprintf( _n( 'Viewing %1$s topic', 'Viewing %1$s topics', $total_int, 'bbpress' ), $total );
// Several topics in a forum with several pages
} else {
$retstr = sprintf( _n( 'Viewing topic %2$s (of %4$s total)', 'Viewing %1$s topics - %2$s through %3$s (of %4$s total)', $total_int, 'bbpress' ), $count_num, $from_num, $to_num, $total );
}
// Escape results of _n()
$retstr = esc_html( $retstr );
}
// Filter & return
return apply_filters( 'bbp_get_forum_pagination_count', $retstr );
}
Changelog Changelog
| Version | Description |
|---|---|
| 2.0.0 | Introduced. |