Skip to:
Content

bbPress.org


Ignore:
Timestamp:
10/19/2012 07:42:49 AM (12 years ago)
Author:
johnjamesjacoby
Message:

Number Formatting:

  • Introduce $integer parameter to template-tags to switch filter for integer usage.
  • Use absint() where appropriate when getting counts.
  • Smarter int type casting.
  • Fixes bug where calculations were being done against formatted strings.
  • Fixes #1974.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/bbp-includes/topics/functions.php

    r4255 r4258  
    30493049 * @since bbPress (r3540)
    30503050 *
     3051 * @param int $default Default replies per page (15)
    30513052 * @uses get_option() To get the setting
    30523053 * @uses apply_filters() To allow the return value to be manipulated
    30533054 * @return int
    30543055 */
    3055 function bbp_get_topics_per_page() {
    3056 
    3057     // The default per setting
    3058     $default = 15;
     3056function bbp_get_topics_per_page( $default = 15 ) {
    30593057
    30603058    // Get database option and cast as integer
    3061     $per = $retval = (int) get_option( '_bbp_topics_per_page', $default );
     3059    $retval = get_option( '_bbp_topics_per_page', $default );
    30623060
    30633061    // If return val is empty, set it to default
     
    30663064
    30673065    // Filter and return
    3068     return (int) apply_filters( 'bbp_get_topics_per_page', $retval, $per );
     3066    return absint( apply_filters( 'bbp_get_topics_per_page', $retval, $default ) );
    30693067}
    30703068
     
    30743072 * @since bbPress (r3540)
    30753073 *
     3074 * @param int $default Default replies per page (25)
    30763075 * @uses get_option() To get the setting
    30773076 * @uses apply_filters() To allow the return value to be manipulated
    30783077 * @return int
    30793078 */
    3080 function bbp_get_topics_per_rss_page() {
    3081 
    3082     // The default per setting
    3083     $default = 25;
     3079function bbp_get_topics_per_rss_page( $default = 25 ) {
    30843080
    30853081    // Get database option and cast as integer
    3086     $per = $retval = (int) get_option( '_bbp_topics_per_rss_page', $default );
     3082    $retval = get_option( '_bbp_topics_per_rss_page', $default );
    30873083
    30883084    // If return val is empty, set it to default
     
    30913087
    30923088    // Filter and return
    3093     return (int) apply_filters( 'bbp_get_topics_per_rss_page', $retval, $per );
     3089    return absint( apply_filters( 'bbp_get_topics_per_rss_page', $retval, $default ) );
    30943090}
    30953091
Note: See TracChangeset for help on using the changeset viewer.