bbp_get_topic_pagination_count()

Return the topic pagination count


Description Description


Return Return

(string) Topic pagination count


Top ↑

Source Source

File: includes/replies/template.php

	function bbp_get_topic_pagination_count() {
		$bbp = bbpress();

		// Define local variable(s)
		$retstr = '';

		// Set pagination values
		$count_int = intval( $bbp->reply_query->post_count     );
		$total_int = intval( $bbp->reply_query->found_posts    );
		$ppp_int   = intval( $bbp->reply_query->posts_per_page );
		$start_int = intval( ( $bbp->reply_query->paged - 1 ) * $ppp_int ) + 1;
		$to_int    = intval( ( $start_int + ( $ppp_int - 1 ) > $total_int )
			? $total_int
			: $start_int + ( $ppp_int - 1 ) );

		// Format numbers for display
		$count_num = bbp_number_format( $count_int );
		$total_num = bbp_number_format( $total_int );
		$from_num  = bbp_number_format( $start_int );
		$to_num    = bbp_number_format( $to_int    );

		// We are threading replies
		if ( bbp_thread_replies() ) {
			$walker  = new BBP_Walker_Reply();
			$threads = absint( $walker->get_number_of_root_elements( $bbp->reply_query->posts ) - 1 );
			$retstr  = sprintf( _n( 'Viewing %1$s reply thread', 'Viewing %1$s reply threads', $threads, 'bbpress' ), bbp_number_format( $threads ) );

		// We are not including the lead topic
		} elseif ( bbp_show_lead_topic() ) {

			// Several replies in a topic with a single page
			if ( empty( $to_num ) ) {
				$retstr = sprintf( _n( 'Viewing %1$s reply', 'Viewing %1$s replies', $total_int, 'bbpress' ), $total_num );

			// Several replies in a topic with several pages
			} else {
				$retstr = sprintf( _n( 'Viewing %2$s replies (of %4$s total)', 'Viewing %1$s replies - %2$s through %3$s (of %4$s total)', $count_int, 'bbpress' ), $count_num, $from_num, $to_num, $total_num );
			}

		// We are including the lead topic
		} else {

			// Several posts in a topic with a single page
			if ( empty( $to_num ) ) {
				$retstr = sprintf( _n( 'Viewing %1$s post', 'Viewing %1$s posts', $total_int, 'bbpress' ), $total_num );

			// Several posts in a topic with several pages
			} else {
				$retstr = sprintf( _n( 'Viewing %2$s post (of %4$s total)', 'Viewing %1$s posts - %2$s through %3$s (of %4$s total)', $count_int, 'bbpress' ), $count_num, $from_num, $to_num, $total_num );
			}
		}

		// Escape results of _n()
		$retstr = esc_html( $retstr );

		// Filter & return
		return apply_filters( 'bbp_get_topic_pagination_count', $retstr );
	}

Top ↑

Changelog Changelog

Changelog
Version Description
2.0.0 Introduced.

Top ↑

User Contributed Notes User Contributed Notes

You must log in before being able to contribute a note or feedback.