Skip to:
Content

bbPress.org


Ignore:
Timestamp:
02/06/2011 05:05:23 AM (15 years ago)
Author:
johnjamesjacoby
Message:

Cast return values as (int) where appropriate. Adjust _last_ functions to be more friendly with anonymous user data. Test some logic with _last_ forum/topic/reply where if reply_id does not exist, fall back to topic_id. Remove various strict empty string checks as they should no longer be needed.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/plugin/bbp-includes/bbp-forum-template.php

    r2831 r2851  
    373373 */
    374374function bbp_get_forum_parent( $forum_id = 0 ) {
    375     $forum_id = bbp_get_forum_id( $forum_id );
    376     return apply_filters( 'bbp_get_forum_parent', (int) get_post_field( 'post_parent', $forum_id ), $forum_id );
     375    $forum_id  = bbp_get_forum_id( $forum_id );
     376    $parent_id = get_post_field( 'post_parent', $forum_id );
     377
     378    return apply_filters( 'bbp_get_forum_parent', (int) $parent_id, $forum_id );
    377379}
    378380
     
    546548        $topic_id = get_post_meta( $forum_id, '_bbp_forum_last_topic_id', true );
    547549
    548         return apply_filters( 'bbp_get_forum_last_topic_id', $topic_id, $forum_id );
     550        return apply_filters( 'bbp_get_forum_last_topic_id', (int) $topic_id, $forum_id );
    549551    }
    550552
     
    624626    $forum_id  = bbp_get_forum_id( $forum_id );
    625627    $author_id = bbp_get_topic_author_id( bbp_get_forum_last_topic_id( $forum_id ) );
    626     return apply_filters( 'bbp_get_forum_last_topic_author_id', $author_id, $forum_id );
     628    return apply_filters( 'bbp_get_forum_last_topic_author_id', (int) $author_id, $forum_id );
    627629}
    628630
     
    691693        $reply_id = get_post_meta( $forum_id, '_bbp_forum_last_reply_id', true );
    692694
    693         if ( '' === $reply_id )
    694             $reply_id = bbp_update_forum_last_reply_id( $forum_id );
    695 
    696         return apply_filters( 'bbp_get_forum_last_reply_id', $reply_id, $forum_id );
     695        if ( empty( $reply_id ) )
     696            $reply_id = bbp_get_forum_last_topic_id( $forum_id );
     697
     698        return apply_filters( 'bbp_get_forum_last_reply_id', (int) $reply_id, $forum_id );
    697699    }
    698700
     
    891893    function bbp_get_forum_subforum_count( $forum_id = 0 ) {
    892894        $forum_id    = bbp_get_forum_id( $forum_id );
    893         $forum_count = get_post_meta( $forum_id, '_bbp_forum_subforum_count', true );
    894 
    895         if ( '' === $forum_count )
    896             $forum_count = bbp_update_forum_subforum_count( $forum_id );
     895        $forum_count = (int) get_post_meta( $forum_id, '_bbp_forum_subforum_count', true );
    897896
    898897        return apply_filters( 'bbp_get_forum_subforum_count', (int) $forum_count, $forum_id );
     
    929928    function bbp_get_forum_topic_count( $forum_id = 0, $total_count = true ) {
    930929        $forum_id = bbp_get_forum_id( $forum_id );
    931         $topics  = get_post_meta( $forum_id, empty( $total_count ) ? '_bbp_forum_topic_count' : '_bbp_forum_total_topic_count', true );
    932 
    933         if ( '' === $topics )
    934             $topics = bbp_update_forum_topic_count( $forum_id, $total_count );
     930        $topics   = get_post_meta( $forum_id, empty( $total_count ) ? '_bbp_forum_topic_count' : '_bbp_forum_total_topic_count', true );
    935931
    936932        return apply_filters( 'bbp_get_forum_topic_count', (int) $topics, $forum_id );
     
    969965        $replies  = get_post_meta( $forum_id, empty( $total_count ) ? '_bbp_forum_reply_count' : '_bbp_forum_total_reply_count', true );
    970966
    971         if ( '' === $replies )
    972             $replies = bbp_update_forum_reply_count( $forum_id, $total_count );
    973 
    974967        return apply_filters( 'bbp_get_forum_reply_count', (int) $replies, $forum_id );
    975968    }
     
    1003996        $forum_id = bbp_get_forum_id( $forum_id );
    1004997        $voices   = get_post_meta( $forum_id, '_bbp_forum_voice_count', true );
    1005 
    1006         if ( '' === $voices )
    1007             $voices = bbp_update_forum_voice_count( $forum_id );
    1008998
    1009999        return apply_filters( 'bbp_get_forum_voice_count', (int) $voices, $forum_id );
Note: See TracChangeset for help on using the changeset viewer.