Skip to:
Content

bbPress.org

Ticket #2811: 2811.forums_fixes.01.patch

File 2811.forums_fixes.01.patch, 6.1 KB (added by thebrandonallen, 9 years ago)
  • src/includes/forums/functions.php

    diff --git src/includes/forums/functions.php src/includes/forums/functions.php
    index 56ec78c..f9ce602 100644
    function bbp_bump_forum_reply_count( $forum_id = 0, $difference = 1, $update_anc 
    12051205 * @uses update_post_meta() To update the forum's last active id meta
    12061206 * @uses apply_filters() Calls 'bbp_update_forum_last_topic_id' with the last
    12071207 *                        reply id and forum id
    1208  * @return bool True on success, false on failure
     1208 * @return int Id of the forum's most recent topic
    12091209 */
    12101210function bbp_update_forum_last_topic_id( $forum_id = 0, $topic_id = 0 ) {
    12111211        $forum_id = bbp_get_forum_id( $forum_id );
    function bbp_update_forum_last_topic_id( $forum_id = 0, $topic_id = 0 ) { 
    12181218
    12191219                // Loop through children and add together forum reply counts
    12201220                $children = bbp_forum_query_subforum_ids( $forum_id );
    1221                 if ( !empty( $children ) ) {
     1221                if ( ! empty( $children ) ) {
    12221222                        foreach ( $children as $child ) {
    12231223                                $children_last_topic = bbp_update_forum_last_topic_id( $child ); // Recursive
    12241224                        }
    function bbp_update_forum_last_topic_id( $forum_id = 0, $topic_id = 0 ) { 
    12361236
    12371237                // Get the most recent topic in this forum_id
    12381238                $recent_topic = get_posts( $post_vars );
    1239                 if ( !empty( $recent_topic ) ) {
     1239                if ( ! empty( $recent_topic ) ) {
    12401240                        $topic_id = $recent_topic[0]->ID;
    12411241                }
    12421242        }
    function bbp_update_forum_last_topic_id( $forum_id = 0, $topic_id = 0 ) { 
    12461246        $children_last_topic = (int) $children_last_topic;
    12471247
    12481248        // If child forums have higher id, use that instead
    1249         if ( !empty( $children ) && ( $children_last_topic > $topic_id ) ) {
     1249        if ( ! empty( $children ) && ( $children_last_topic > $topic_id ) ) {
    12501250                $topic_id = $children_last_topic;
    12511251        }
    12521252
    function bbp_update_forum_last_topic_id( $forum_id = 0, $topic_id = 0 ) { 
    12751275 * @uses update_post_meta() To update the forum's last active id meta
    12761276 * @uses apply_filters() Calls 'bbp_update_forum_last_reply_id' with the last
    12771277 *                        reply id and forum id
    1278  * @return bool True on success, false on failure
     1278 * @return int Id of the forum's most recent reply
    12791279 */
    12801280function bbp_update_forum_last_reply_id( $forum_id = 0, $reply_id = 0 ) {
    12811281        $forum_id = bbp_get_forum_id( $forum_id );
    function bbp_update_forum_last_reply_id( $forum_id = 0, $reply_id = 0 ) { 
    12881288
    12891289                // Loop through children and get the most recent reply id
    12901290                $children = bbp_forum_query_subforum_ids( $forum_id );
    1291                 if ( !empty( $children ) ) {
     1291                if ( ! empty( $children ) ) {
    12921292                        foreach ( $children as $child ) {
    12931293                                $children_last_reply = bbp_update_forum_last_reply_id( $child ); // Recursive
    12941294                        }
    function bbp_update_forum_last_reply_id( $forum_id = 0, $reply_id = 0 ) { 
    12961296
    12971297                // If this forum has topics...
    12981298                $topic_ids = bbp_forum_query_topic_ids( $forum_id );
    1299                 if ( !empty( $topic_ids ) ) {
     1299                if ( ! empty( $topic_ids ) ) {
    13001300
    13011301                        // ...get the most recent reply from those topics...
    13021302                        $reply_id = bbp_forum_query_last_reply_id( $forum_id, $topic_ids );
    function bbp_update_forum_last_reply_id( $forum_id = 0, $reply_id = 0 ) { 
    13111311        $children_last_reply = (int) $children_last_reply;
    13121312
    13131313        // If child forums have higher ID, check for newer reply id
    1314         if ( !empty( $children ) && ( $children_last_reply > $reply_id ) ) {
     1314        if ( ! empty( $children ) && ( $children_last_reply > $reply_id ) ) {
    13151315                $reply_id = $children_last_reply;
    13161316        }
    13171317
    function bbp_update_forum_last_reply_id( $forum_id = 0, $reply_id = 0 ) { 
    13401340 * @uses update_post_meta() To update the forum's last active id meta
    13411341 * @uses apply_filters() Calls 'bbp_update_forum_last_active_id' with the last
    13421342 *                        active post id and forum id
    1343  * @return bool True on success, false on failure
     1343 * @return int Id of the forum's last active post
    13441344 */
    13451345function bbp_update_forum_last_active_id( $forum_id = 0, $active_id = 0 ) {
    13461346
    function bbp_update_forum_last_active_id( $forum_id = 0, $active_id = 0 ) { 
    13541354
    13551355                // Loop through children and add together forum reply counts
    13561356                $children = bbp_forum_query_subforum_ids( $forum_id );
    1357                 if ( !empty( $children ) ) {
     1357                if ( ! empty( $children ) ) {
    13581358                        foreach ( $children as $child ) {
    13591359                                $children_last_active = bbp_update_forum_last_active_id( $child, $active_id );
    13601360                        }
    function bbp_update_forum_last_active_id( $forum_id = 0, $active_id = 0 ) { 
    13621362
    13631363                // Don't count replies if the forum is a category
    13641364                $topic_ids = bbp_forum_query_topic_ids( $forum_id );
    1365                 if ( !empty( $topic_ids ) ) {
     1365                if ( ! empty( $topic_ids ) ) {
    13661366                        $active_id = bbp_forum_query_last_reply_id( $forum_id, $topic_ids );
    13671367                        $active_id = $active_id > max( $topic_ids ) ? $active_id : max( $topic_ids );
    13681368
    function bbp_update_forum_last_active_id( $forum_id = 0, $active_id = 0 ) { 
    13771377        $children_last_active = (int) $children_last_active;
    13781378
    13791379        // If child forums have higher id, use that instead
    1380         if ( !empty( $children ) && ( $children_last_active > $active_id ) ) {
     1380        if ( ! empty( $children ) && ( $children_last_active > $active_id ) ) {
    13811381                $active_id = $children_last_active;
    13821382        }
    13831383
    function bbp_update_forum_last_active_id( $forum_id = 0, $active_id = 0 ) { 
    14021402 * @uses update_post_meta() To update the forum last active time
    14031403 * @uses apply_filters() Calls 'bbp_update_forum_last_active' with the new time
    14041404 *                        and forum id
    1405  * @return bool True on success, false on failure
     1405 * @return string MySQL timestamp of last active topic/reply
    14061406 */
    14071407function bbp_update_forum_last_active_time( $forum_id = 0, $new_time = '' ) {
    14081408        $forum_id = bbp_get_forum_id( $forum_id );
    function bbp_update_forum_last_active_time( $forum_id = 0, $new_time = '' ) { 
    14131413        }
    14141414
    14151415        // Update only if there is a time
    1416         if ( !empty( $new_time ) ) {
     1416        if ( ! empty( $new_time ) ) {
    14171417                update_post_meta( $forum_id, '_bbp_last_active_time', $new_time );
    14181418        }
    14191419
    1420         return (int) apply_filters( 'bbp_update_forum_last_active', $new_time, $forum_id );
     1420        return apply_filters( 'bbp_update_forum_last_active', $new_time, $forum_id );
    14211421}
    14221422
    14231423/**