Skip to:
Content

bbPress.org

Changeset 4611


Ignore:
Timestamp:
12/20/2012 04:08:55 PM (9 years ago)
Author:
johnjamesjacoby
Message:

Add some brackets to improve readability in /topics/functions.php. See #1799.

File:
1 edited

Legend:

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

    r4561 r4611  
    22142214
    22152215    // If it's a reply, then get the parent (topic id)
    2216     if ( bbp_is_reply( $topic_id ) )
     2216    if ( bbp_is_reply( $topic_id ) ) {
    22172217        $topic_id = bbp_get_reply_topic_id( $topic_id );
    2218     else
     2218    } else {
    22192219        $topic_id = bbp_get_topic_id( $topic_id );
    2220 
    2221     if ( empty( $forum_id ) )
     2220    }
     2221
     2222    if ( empty( $forum_id ) ) {
    22222223        $forum_id = get_post_field( 'post_parent', $topic_id );
     2224    }
    22232225
    22242226    update_post_meta( $topic_id, '_bbp_forum_id', (int) $forum_id );
     
    22662268
    22672269    // If it's a reply, then get the parent (topic id)
    2268     if ( bbp_is_reply( $topic_id ) )
     2270    if ( bbp_is_reply( $topic_id ) ) {
    22692271        $topic_id = bbp_get_reply_topic_id( $topic_id );
    2270     else
     2272    } else {
    22712273        $topic_id = bbp_get_topic_id( $topic_id );
     2274    }
    22722275
    22732276    // Get replies of topic if not passed
    2274     if ( empty( $reply_count ) )
     2277    if ( empty( $reply_count ) ) {
    22752278        $reply_count = bbp_get_public_child_count( $topic_id, bbp_get_reply_post_type() );
     2279    }
    22762280
    22772281    update_post_meta( $topic_id, '_bbp_reply_count', (int) $reply_count );
     
    23022306
    23032307    // If it's a reply, then get the parent (topic id)
    2304     if ( bbp_is_reply( $topic_id ) )
     2308    if ( bbp_is_reply( $topic_id ) ) {
    23052309        $topic_id = bbp_get_reply_topic_id( $topic_id );
    2306     else
     2310    } else {
    23072311        $topic_id = bbp_get_topic_id( $topic_id );
     2312    }
    23082313
    23092314    // Get replies of topic
    2310     if ( empty( $reply_count ) )
     2315    if ( empty( $reply_count ) ) {
    23112316        $reply_count = $wpdb->get_var( $wpdb->prepare( "SELECT COUNT(ID) FROM {$wpdb->posts} WHERE post_parent = %d AND post_status IN ( '" . join( '\',\'', array( bbp_get_trash_status_id(), bbp_get_spam_status_id() ) ) . "') AND post_type = '%s';", $topic_id, bbp_get_reply_post_type() ) );
     2317    }
    23122318
    23132319    update_post_meta( $topic_id, '_bbp_reply_count_hidden', (int) $reply_count );
     
    23372343
    23382344    // If it's a reply, then get the parent (topic id)
    2339     if ( bbp_is_reply( $topic_id ) )
     2345    if ( bbp_is_reply( $topic_id ) ) {
    23402346        $topic_id = bbp_get_reply_topic_id( $topic_id );
    2341     else
     2347    } else {
    23422348        $topic_id = bbp_get_topic_id( $topic_id );
    2343 
    2344     if ( empty( $active_id ) )
     2349    }
     2350
     2351    if ( empty( $active_id ) ) {
    23452352        $active_id = bbp_get_public_child_last_id( $topic_id, bbp_get_reply_post_type() );
     2353    }
    23462354
    23472355    // Adjust last_id's based on last_reply post_type
    2348     if ( empty( $active_id ) || !bbp_is_reply( $active_id ) )
     2356    if ( empty( $active_id ) || !bbp_is_reply( $active_id ) ) {
    23492357        $active_id = $topic_id;
     2358    }
    23502359
    23512360    // Update only if published
    2352     if ( bbp_get_public_status_id() == get_post_status( $active_id ) )
     2361    if ( bbp_get_public_status_id() == get_post_status( $active_id ) ) {
    23532362        update_post_meta( $topic_id, '_bbp_last_active_id', (int) $active_id );
     2363    }
    23542364
    23552365    return apply_filters( 'bbp_update_topic_last_active_id', (int) $active_id, $topic_id );
     
    23722382
    23732383    // If it's a reply, then get the parent (topic id)
    2374     if ( bbp_is_reply( $topic_id ) )
     2384    if ( bbp_is_reply( $topic_id ) ) {
    23752385        $topic_id = bbp_get_reply_topic_id( $topic_id );
    2376     else
     2386    } else {
    23772387        $topic_id = bbp_get_topic_id( $topic_id );
     2388    }
    23782389
    23792390    // Check time and use current if empty
    2380     if ( empty( $new_time ) )
     2391    if ( empty( $new_time ) ) {
    23812392        $new_time = get_post_field( 'post_date', bbp_get_public_child_last_id( $topic_id, bbp_get_reply_post_type() ) );
     2393    }
    23822394
    23832395    // Update only if published
    2384     if ( !empty( $new_time ) )
     2396    if ( !empty( $new_time ) ) {
    23852397        update_post_meta( $topic_id, '_bbp_last_active_time', $new_time );
     2398    }
    23862399
    23872400    return apply_filters( 'bbp_update_topic_last_active_time', $new_time, $topic_id );
     
    24172430    }
    24182431
    2419     if ( empty( $reply_id ) )
     2432    if ( empty( $reply_id ) ) {
    24202433        $reply_id = bbp_get_public_child_last_id( $topic_id, bbp_get_reply_post_type() );
     2434    }
    24212435
    24222436    // Adjust last_id's based on last_reply post_type
    2423     if ( empty( $reply_id ) || !bbp_is_reply( $reply_id ) )
     2437    if ( empty( $reply_id ) || !bbp_is_reply( $reply_id ) ) {
    24242438        $reply_id = 0;
     2439    }
    24252440
    24262441    // Update if reply is published
    2427     if ( bbp_is_reply_published( $reply_id ) )
     2442    if ( bbp_is_reply_published( $reply_id ) ) {
    24282443        update_post_meta( $topic_id, '_bbp_last_reply_id', (int) $reply_id );
     2444    }
    24292445
    24302446    return apply_filters( 'bbp_update_topic_last_reply_id', (int) $reply_id, $topic_id );
     
    24542470
    24552471    // If it's a reply, then get the parent (topic id)
    2456     if ( bbp_is_reply( $topic_id ) )
     2472    if ( bbp_is_reply( $topic_id ) ) {
    24572473        $topic_id = bbp_get_reply_topic_id( $topic_id );
    2458     elseif ( bbp_is_topic( $topic_id ) )
     2474    } elseif ( bbp_is_topic( $topic_id ) ) {
    24592475        $topic_id = bbp_get_topic_id( $topic_id );
    2460     else
     2476    } else {
    24612477        return;
     2478    }
    24622479
    24632480    // Query the DB to get voices in this topic
     
    24962513
    24972514    // If it's a reply, then get the parent (topic id)
    2498     if ( bbp_is_reply( $topic_id ) )
     2515    if ( bbp_is_reply( $topic_id ) ) {
    24992516        $topic_id = bbp_get_reply_topic_id( $topic_id );
    2500     elseif ( bbp_is_topic( $topic_id ) )
     2517    } elseif ( bbp_is_topic( $topic_id ) ) {
    25012518        $topic_id = bbp_get_topic_id( $topic_id );
    2502     else
     2519    } else {
    25032520        return;
     2521    }
    25042522
    25052523    $anonymous_replies = (int) $wpdb->get_var( $wpdb->prepare( "SELECT COUNT( ID ) FROM {$wpdb->posts} WHERE ( post_parent = %d AND post_status = '%s' AND post_type = '%s' AND post_author = 0 ) OR ( ID = %d AND post_type = '%s' AND post_author = 0 );", $topic_id, bbp_get_public_status_id(), bbp_get_reply_post_type(), $topic_id, bbp_get_topic_post_type() ) );
Note: See TracChangeset for help on using the changeset viewer.