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/replies/template-tags.php

    r4255 r4258  
    253253        }
    254254
    255         return (int) apply_filters( 'bbp_get_reply_id', (int) $bbp_reply_id, $reply_id );
     255        return (int) apply_filters( 'bbp_get_reply_id', $bbp_reply_id, $reply_id );
    256256    }
    257257
     
    691691 *
    692692 * @param int $reply_id Optional. Reply id
     693 * @param boolean $integer Optional. Whether or not to format the result
    693694 * @uses bbp_get_reply_revisions() To get the reply revisions
    694695 * @uses apply_filters() Calls 'bbp_get_reply_revision_count'
     
    696697 * @return string reply revision count
    697698 */
    698 function bbp_get_reply_revision_count( $reply_id = 0 ) {
    699     return apply_filters( 'bbp_get_reply_revisions', count( bbp_get_reply_revisions( $reply_id ) ), $reply_id );
     699function bbp_get_reply_revision_count( $reply_id = 0, $integer = false ) {
     700    $count = absint( count( bbp_get_reply_revisions( $reply_id ) ) );
     701    $filter = ( true === $integer ) ? 'bbp_get_reply_revision_count_int' : 'bbp_get_reply_revision_count';
     702
     703    return apply_filters( $filter, $count, $reply_id );
    700704}
    701705
     
    863867        $author_id = get_post_field( 'post_author', $reply_id );
    864868
    865         return (int) apply_filters( 'bbp_get_reply_author_id', (int) $author_id, $reply_id );
     869        return (int) apply_filters( 'bbp_get_reply_author_id', $author_id, $reply_id );
    866870    }
    867871
     
    12671271                $topic_id = bbp_get_topic_id( $topic_id );
    12681272
    1269         return apply_filters( 'bbp_get_reply_topic_id', (int) $topic_id, $reply_id );
     1273        return (int) apply_filters( 'bbp_get_reply_topic_id', $topic_id, $reply_id );
    12701274    }
    12711275
     
    13071311                $forum_id = bbp_get_forum_id( $forum_id );
    13081312
    1309         return apply_filters( 'bbp_get_reply_forum_id', (int) $forum_id, $reply_id );
     1313        return (int) apply_filters( 'bbp_get_reply_forum_id', $forum_id, $reply_id );
    13101314    }
    13111315
     
    13701374            $reply_position++;
    13711375
    1372         return (int) apply_filters( 'bbp_get_reply_position', (int) $reply_position, $reply_id, $topic_id );
     1376        return (int) apply_filters( 'bbp_get_reply_position', $reply_position, $reply_id, $topic_id );
    13731377    }
    13741378
Note: See TracChangeset for help on using the changeset viewer.