コード例 #1
0
ファイル: template.php プロジェクト: danielcoats/schoolpress
/**
 * Return the topic pagination count
 *
 * @since bbPress (r2519)
 *
 * @uses bbp_number_format() To format the number value
 * @uses bbp_show_lead_topic() Are we showing the topic as a lead?
 * @uses apply_filters() Calls 'bbp_get_topic_pagination_count' with the
 *                        pagination count
 * @return string Topic pagination count
 */
function bbp_get_topic_pagination_count()
{
    $bbp = bbpress();
    // Define local variable(s)
    $retstr = '';
    // Set pagination values
    $start_num = intval(($bbp->reply_query->paged - 1) * $bbp->reply_query->posts_per_page) + 1;
    $from_num = bbp_number_format($start_num);
    $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));
    $total_int = (int) $bbp->reply_query->found_posts;
    $total = bbp_number_format($total_int);
    // We are threading replies
    if (bbp_thread_replies() && bbp_is_single_topic()) {
        return;
        $walker = new BBP_Walker_Reply();
        $threads = (int) $walker->get_number_of_root_elements($bbp->reply_query->posts);
        // Adjust for topic
        $threads--;
        $retstr = sprintf(_n('Viewing %1$s reply thread', 'Viewing %1$s reply threads', $threads, 'bbbpress'), 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);
            // 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)', $bbp->reply_query->post_count, 'bbpress'), $bbp->reply_query->post_count, $from_num, $to_num, $total);
        }
        // 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);
            // 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)', $bbp->reply_query->post_count, 'bbpress'), $bbp->reply_query->post_count, $from_num, $to_num, $total);
        }
    }
    // Filter and return
    return apply_filters('bbp_get_topic_pagination_count', esc_html($retstr));
}
コード例 #2
0
/**
 * List replies
 *
 * @since bbPress (r4944)
 */
function bbp_list_replies($args = array())
{
    // Reset the reply depth
    bbpress()->reply_query->reply_depth = 0;
    // In reply loop
    bbpress()->reply_query->in_the_loop = true;
    $r = bbp_parse_args($args, array('walker' => null, 'max_depth' => bbp_thread_replies_depth(), 'style' => 'ul', 'callback' => null, 'end_callback' => null, 'page' => 1, 'per_page' => -1), 'list_replies');
    // Get replies to loop through in $_replies
    $walker = new BBP_Walker_Reply();
    $walker->paged_walk(bbpress()->reply_query->posts, $r['max_depth'], $r['page'], $r['per_page'], $r);
    bbpress()->max_num_pages = $walker->max_pages;
    bbpress()->reply_query->in_the_loop = false;
}