Skip to:
Content

bbPress.org


Ignore:
Timestamp:
07/09/2014 10:21:52 PM (12 years ago)
Author:
johnjamesjacoby
Message:

Bracketize replies component.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/includes/replies/functions.php

    r5399 r5431  
    109109
    110110        // Bail if action is not bbp-new-reply
    111         if ( 'bbp-new-reply' !== $action )
     111        if ( 'bbp-new-reply' !== $action ) {
    112112                return;
     113        }
    113114
    114115        // Nonce check
     
    261262        /** Reply Title ***********************************************************/
    262263
    263         if ( !empty( $_POST['bbp_reply_title'] ) )
     264        if ( !empty( $_POST['bbp_reply_title'] ) ) {
    264265                $reply_title = esc_attr( strip_tags( $_POST['bbp_reply_title'] ) );
     266        }
    265267
    266268        // Filter and sanitize
     
    269271        /** Reply Content *********************************************************/
    270272
    271         if ( !empty( $_POST['bbp_reply_content'] ) )
     273        if ( !empty( $_POST['bbp_reply_content'] ) ) {
    272274                $reply_content = $_POST['bbp_reply_content'];
     275        }
    273276
    274277        // Filter and sanitize
     
    276279
    277280        // No reply content
    278         if ( empty( $reply_content ) )
     281        if ( empty( $reply_content ) ) {
    279282                bbp_add_error( 'bbp_reply_content', __( '<strong>ERROR</strong>: Your reply cannot be empty.', 'bbpress' ) );
     283        }
    280284
    281285        /** Reply Flooding ********************************************************/
    282286
    283         if ( !bbp_check_for_flood( $anonymous_data, $reply_author ) )
     287        if ( !bbp_check_for_flood( $anonymous_data, $reply_author ) ) {
    284288                bbp_add_error( 'bbp_reply_flood', __( '<strong>ERROR</strong>: Slow down; you move too fast.', 'bbpress' ) );
     289        }
    285290
    286291        /** Reply Duplicate *******************************************************/
    287292
    288         if ( !bbp_check_for_duplicate( array( 'post_type' => bbp_get_reply_post_type(), 'post_author' => $reply_author, 'post_content' => $reply_content, 'post_parent' => $topic_id, 'anonymous_data' => $anonymous_data ) ) )
     293        if ( !bbp_check_for_duplicate( array( 'post_type' => bbp_get_reply_post_type(), 'post_author' => $reply_author, 'post_content' => $reply_content, 'post_parent' => $topic_id, 'anonymous_data' => $anonymous_data ) ) ) {
    289294                bbp_add_error( 'bbp_reply_duplicate', __( '<strong>ERROR</strong>: Duplicate reply detected; it looks as though you&#8217;ve already said that!', 'bbpress' ) );
     295        }
    290296
    291297        /** Reply Blacklist *******************************************************/
    292298
    293         if ( !bbp_check_for_blacklist( $anonymous_data, $reply_author, $reply_title, $reply_content ) )
     299        if ( !bbp_check_for_blacklist( $anonymous_data, $reply_author, $reply_title, $reply_content ) ) {
    294300                bbp_add_error( 'bbp_reply_blacklist', __( '<strong>ERROR</strong>: Your reply cannot be created at this time.', 'bbpress' ) );
     301        }
    295302
    296303        /** Reply Status **********************************************************/
     
    339346
    340347        // Bail if errors
    341         if ( bbp_has_errors() )
     348        if ( bbp_has_errors() ) {
    342349                return;
     350        }
    343351
    344352        /** No Errors *************************************************************/
     
    491499
    492500        // Bail if action is not bbp-edit-reply
    493         if ( 'bbp-edit-reply' !== $action )
     501        if ( 'bbp-edit-reply' !== $action ) {
    494502                return;
     503        }
    495504
    496505        // Define local variable(s)
     
    593602        /** Reply Title ***********************************************************/
    594603
    595         if ( !empty( $_POST['bbp_reply_title'] ) )
     604        if ( !empty( $_POST['bbp_reply_title'] ) ) {
    596605                $reply_title = esc_attr( strip_tags( $_POST['bbp_reply_title'] ) );
     606        }
    597607
    598608        // Filter and sanitize
     
    601611        /** Reply Content *********************************************************/
    602612
    603         if ( !empty( $_POST['bbp_reply_content'] ) )
     613        if ( !empty( $_POST['bbp_reply_content'] ) ) {
    604614                $reply_content = $_POST['bbp_reply_content'];
     615        }
    605616
    606617        // Filter and sanitize
     
    608619
    609620        // No reply content
    610         if ( empty( $reply_content ) )
     621        if ( empty( $reply_content ) ) {
    611622                bbp_add_error( 'bbp_edit_reply_content', __( '<strong>ERROR</strong>: Your reply cannot be empty.', 'bbpress' ) );
     623        }
    612624
    613625        /** Reply Blacklist *******************************************************/
    614626
    615         if ( !bbp_check_for_blacklist( $anonymous_data, $reply_author, $reply_title, $reply_content ) )
     627        if ( !bbp_check_for_blacklist( $anonymous_data, $reply_author, $reply_title, $reply_content ) ) {
    616628                bbp_add_error( 'bbp_reply_blacklist', __( '<strong>ERROR</strong>: Your reply cannot be edited at this time.', 'bbpress' ) );
     629        }
    617630
    618631        /** Reply Status **********************************************************/
     
    658671
    659672        // Bail if errors
    660         if ( bbp_has_errors() )
     673        if ( bbp_has_errors() ) {
    661674                return;
     675        }
    662676
    663677        /** No Errors *************************************************************/
     
    706720
    707721        // Revision Reason
    708         if ( !empty( $_POST['bbp_reply_edit_reason'] ) )
     722        if ( !empty( $_POST['bbp_reply_edit_reason'] ) ) {
    709723                $reply_edit_reason = esc_attr( strip_tags( $_POST['bbp_reply_edit_reason'] ) );
     724        }
    710725
    711726        // Update revision log
     
    798813
    799814        // Bail if there is no reply
    800         if ( empty( $reply_id ) )
     815        if ( empty( $reply_id ) ) {
    801816                return;
     817        }
    802818
    803819        // Check author_id
    804         if ( empty( $author_id ) )
     820        if ( empty( $author_id ) ) {
    805821                $author_id = bbp_get_current_user_id();
     822        }
    806823
    807824        // Check topic_id
    808         if ( empty( $topic_id ) )
     825        if ( empty( $topic_id ) ) {
    809826                $topic_id = bbp_get_reply_topic_id( $reply_id );
     827        }
    810828
    811829        // Check forum_id
    812         if ( !empty( $topic_id ) && empty( $forum_id ) )
     830        if ( !empty( $topic_id ) && empty( $forum_id ) ) {
    813831                $forum_id = bbp_get_topic_forum_id( $topic_id );
     832        }
    814833
    815834        // If anonymous post, store name, email, website and ip in post_meta.
     
    935954
    936955        // If we want a full refresh, unset any of the possibly passed variables
    937         if ( true === $refresh )
     956        if ( true === $refresh ) {
    938957                $forum_id = $topic_id = $reply_id = $active_id = $last_active_time = 0;
     958        }
    939959
    940960        // Walk up ancestors
     
    12591279
    12601280        // Bail if action is not 'bbp-move-reply'
    1261         if ( 'bbp-move-reply' !== $action )
     1281        if ( 'bbp-move-reply' !== $action ) {
    12621282                return;
     1283        }
    12631284
    12641285        // Prevent debug notices
     
    12781299
    12791300        // Reply exists
    1280         if ( empty( $move_reply ) )
     1301        if ( empty( $move_reply ) ) {
    12811302                bbp_add_error( 'bbp_mover_reply_r_not_found', __( '<strong>ERROR</strong>: The reply you want to move was not found.', 'bbpress' ) );
     1303        }
    12821304
    12831305        /** Topic to Move From ***************************************************/
     
    14431465                'meta_value' => $move_reply->ID,
    14441466        ) );
    1445         foreach ( $children as $child )
     1467        foreach ( $children as $child ) {
    14461468                bbp_update_reply_to( $child->ID, $parent );
     1469        }
    14471470
    14481471        // Remove reply_to from moved reply
     
    15531576
    15541577        // Bail if required GET actions aren't passed
    1555         if ( empty( $_GET['reply_id'] ) )
     1578        if ( empty( $_GET['reply_id'] ) ) {
    15561579                return;
     1580        }
    15571581
    15581582        // Setup possible get actions
     
    15631587
    15641588        // Bail if actions aren't meant for this function
    1565         if ( !in_array( $action, $possible_actions ) )
     1589        if ( !in_array( $action, $possible_actions ) ) {
    15661590                return;
     1591        }
    15671592
    15681593        $failure   = '';                         // Empty failure string
     
    15741599        // Make sure reply exists
    15751600        $reply = bbp_get_reply( $reply_id );
    1576         if ( empty( $reply ) )
     1601        if ( empty( $reply ) ) {
    15771602                return;
     1603        }
    15781604
    15791605        // What is the user doing here?
     
    16021628                        $sub_action = in_array( $_GET['sub_action'], array( 'trash', 'untrash', 'delete' ) ) ? $_GET['sub_action'] : false;
    16031629
    1604                         if ( empty( $sub_action ) )
     1630                        if ( empty( $sub_action ) ) {
    16051631                                break;
     1632                        }
    16061633
    16071634                        switch ( $sub_action ) {
     
    16501677
    16511678                // Add view all if needed
    1652                 if ( !empty( $view_all ) )
     1679                if ( !empty( $view_all ) ) {
    16531680                        $reply_url = bbp_add_view_all( $reply_url, true );
     1681                }
    16541682
    16551683                // Redirect back to reply
     
    17021730        // Get reply
    17031731        $reply = bbp_get_reply( $reply_id );
    1704         if ( empty( $reply ) )
     1732        if ( empty( $reply ) ) {
    17051733                return $reply;
     1734        }
    17061735
    17071736        // Bail if already spam
    1708         if ( bbp_get_spam_status_id() === $reply->post_status )
     1737        if ( bbp_get_spam_status_id() === $reply->post_status ) {
    17091738                return false;
     1739        }
    17101740
    17111741        // Execute pre spam code
     
    17491779        // Get reply
    17501780        $reply = bbp_get_reply( $reply_id );
    1751         if ( empty( $reply ) )
     1781        if ( empty( $reply ) ) {
    17521782                return $reply;
     1783        }
    17531784
    17541785        // Bail if already not spam
    1755         if ( bbp_get_spam_status_id() !== $reply->post_status )
     1786        if ( bbp_get_spam_status_id() !== $reply->post_status ) {
    17561787                return false;
     1788        }
    17571789
    17581790        // Execute pre unspam code
     
    17951827        $reply_id = bbp_get_reply_id( $reply_id );
    17961828
    1797         if ( empty( $reply_id ) || !bbp_is_reply( $reply_id ) )
     1829        if ( empty( $reply_id ) || !bbp_is_reply( $reply_id ) ) {
    17981830                return false;
     1831        }
    17991832
    18001833        do_action( 'bbp_delete_reply', $reply_id );
     
    18111844        $reply_id = bbp_get_reply_id( $reply_id );
    18121845
    1813         if ( empty( $reply_id ) || !bbp_is_reply( $reply_id ) )
     1846        if ( empty( $reply_id ) || !bbp_is_reply( $reply_id ) ) {
    18141847                return false;
     1848        }
    18151849
    18161850        do_action( 'bbp_trash_reply', $reply_id );
     
    18271861        $reply_id = bbp_get_reply_id( $reply_id );
    18281862
    1829         if ( empty( $reply_id ) || !bbp_is_reply( $reply_id ) )
     1863        if ( empty( $reply_id ) || !bbp_is_reply( $reply_id ) ) {
    18301864                return false;
     1865        }
    18311866
    18321867        do_action( 'bbp_untrash_reply', $reply_id );
     
    18451880        $reply_id = bbp_get_reply_id( $reply_id );
    18461881
    1847         if ( empty( $reply_id ) || !bbp_is_reply( $reply_id ) )
     1882        if ( empty( $reply_id ) || !bbp_is_reply( $reply_id ) ) {
    18481883                return false;
     1884        }
    18491885
    18501886        do_action( 'bbp_deleted_reply', $reply_id );
     
    18611897        $reply_id = bbp_get_reply_id( $reply_id );
    18621898
    1863         if ( empty( $reply_id ) || !bbp_is_reply( $reply_id ) )
     1899        if ( empty( $reply_id ) || !bbp_is_reply( $reply_id ) ) {
    18641900                return false;
     1901        }
    18651902
    18661903        do_action( 'bbp_trashed_reply', $reply_id );
     
    18771914        $reply_id = bbp_get_reply_id( $reply_id );
    18781915
    1879         if ( empty( $reply_id ) || !bbp_is_reply( $reply_id ) )
     1916        if ( empty( $reply_id ) || !bbp_is_reply( $reply_id ) ) {
    18801917                return false;
     1918        }
    18811919
    18821920        do_action( 'bbp_untrashed_reply', $reply_id );
     
    19011939
    19021940        // If return val is empty, set it to default
    1903         if ( empty( $retval ) )
     1941        if ( empty( $retval ) ) {
    19041942                $retval = $default;
     1943        }
    19051944
    19061945        // Filter and return
     
    19241963
    19251964        // If return val is empty, set it to default
    1926         if ( empty( $retval ) )
     1965        if ( empty( $retval ) ) {
    19271966                $retval = $default;
     1967        }
    19281968
    19291969        // Filter and return
     
    20522092
    20532093        // User cannot access forum this topic is in
    2054         if ( bbp_is_single_topic() && !bbp_user_can_view_forum( array( 'forum_id' => bbp_get_topic_forum_id() ) ) )
     2094        if ( bbp_is_single_topic() && !bbp_user_can_view_forum( array( 'forum_id' => bbp_get_topic_forum_id() ) ) ) {
    20552095                return;
     2096        }
    20562097
    20572098        // Adjust the title based on context
    2058         if ( bbp_is_single_topic() && bbp_user_can_view_forum( array( 'forum_id' => bbp_get_topic_forum_id() ) ) )
     2099        if ( bbp_is_single_topic() && bbp_user_can_view_forum( array( 'forum_id' => bbp_get_topic_forum_id() ) ) ) {
    20592100                $title = apply_filters( 'wp_title_rss', get_wp_title_rss( ' &#187; ' ) );
    2060         elseif ( !bbp_show_lead_topic() )
     2101        } elseif ( !bbp_show_lead_topic() ) {
    20612102                $title = ' &#187; ' .  __( 'All Posts',   'bbpress' );
    2062         else
     2103        } else {
    20632104                $title = ' &#187; ' .  __( 'All Replies', 'bbpress' );
     2105        }
    20642106
    20652107        // Display the feed
     
    21682210
    21692211        // Bail if not editing a topic
    2170         if ( !bbp_is_reply_edit() )
     2212        if ( !bbp_is_reply_edit() ) {
    21712213                return;
     2214        }
    21722215
    21732216        // User cannot edit topic, so redirect back to reply
     
    21992242        // Bail if reply_id is empty
    22002243        $reply_id = bbp_get_reply_id( $reply_id );
    2201         if ( empty( $reply_id ) )
     2244        if ( empty( $reply_id ) ) {
    22022245                return false;
     2246        }
    22032247
    22042248        // If no position was passed, get it from the db and update the menu_order
Note: See TracChangeset for help on using the changeset viewer.