Skip to:
Content

bbPress.org


Ignore:
Timestamp:
02/21/2017 11:25:09 PM (9 years ago)
Author:
johnjamesjacoby
Message:

Pagination: prefer intval() for numeric values, and always format numbers used for display.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/includes/replies/template.php

    r6291 r6300  
    24572457
    24582458        // Set pagination values
    2459         $start_num = intval( ( $bbp->reply_query->paged - 1 ) * $bbp->reply_query->posts_per_page ) + 1;
    2460         $from_num  = bbp_number_format( $start_num );
    2461         $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 ) );
    2462         $total_int = (int) $bbp->reply_query->found_posts;
    2463         $total     = bbp_number_format( $total_int );
     2459        $total_int = intval( $bbp->reply_query->found_posts    );
     2460        $ppp_int   = intval( $bbp->reply_query->posts_per_page );
     2461        $start_int = intval( ( $bbp->reply_query->paged - 1 ) * $ppp_int ) + 1;
     2462        $to_int    = intval( ( $start_int + ( $ppp_int - 1 ) > $total_int )
     2463                ? $total_int
     2464                : $start_int + ( $ppp_int - 1 ) );
     2465
     2466        // Format numbers for display
     2467        $total_num = bbp_number_format( $total_int );
     2468        $from_num  = bbp_number_format( $start_int );
     2469        $to_num    = bbp_number_format( $to_int    );
    24642470
    24652471        // We are threading replies
     
    24742480            // Several replies in a topic with a single page
    24752481            if ( empty( $to_num ) ) {
    2476                 $retstr = sprintf( _n( 'Viewing %1$s reply', 'Viewing %1$s replies', $total_int, 'bbpress' ), $total );
     2482                $retstr = sprintf( _n( 'Viewing %1$s reply', 'Viewing %1$s replies', $total_int, 'bbpress' ), $total_num );
    24772483
    24782484            // Several replies in a topic with several pages
    24792485            } else {
    2480                 $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 );
     2486                $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_num );
    24812487            }
    24822488
     
    24862492            // Several posts in a topic with a single page
    24872493            if ( empty( $to_num ) ) {
    2488                 $retstr = sprintf( _n( 'Viewing %1$s post', 'Viewing %1$s posts', $total_int, 'bbpress' ), $total );
     2494                $retstr = sprintf( _n( 'Viewing %1$s post', 'Viewing %1$s posts', $total_int, 'bbpress' ), $total_num );
    24892495
    24902496            // Several posts in a topic with several pages
    24912497            } else {
    2492                 $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 );
     2498                $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_num );
    24932499            }
    24942500        }
Note: See TracChangeset for help on using the changeset viewer.