Skip to:
Content

bbPress.org


Ignore:
Timestamp:
07/11/2014 09:57:54 PM (11 years ago)
Author:
johnjamesjacoby
Message:

Breathing room for ! usages in Topics component.

File:
1 edited

Legend:

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

    r5432 r5443  
    7070    // Update the forum
    7171    $forum_id = bbp_get_topic_forum_id( $topic_id );
    72     if ( !empty( $forum_id ) ) {
     72    if ( ! empty( $forum_id ) ) {
    7373        bbp_update_forum( array( 'forum_id' => $forum_id ) );
    7474    }
     
    141141
    142142        // Anonymous data checks out, so set cookies, etc...
    143         if ( !empty( $anonymous_data ) && is_array( $anonymous_data ) ) {
     143        if ( ! empty( $anonymous_data ) && is_array( $anonymous_data ) ) {
    144144            bbp_set_current_anonymous_user_data( $anonymous_data );
    145145        }
     
    149149
    150150        // User cannot create topics
    151         if ( !current_user_can( 'publish_topics' ) ) {
     151        if ( ! current_user_can( 'publish_topics' ) ) {
    152152            bbp_add_error( 'bbp_topic_permissions', __( '<strong>ERROR</strong>: You do not have permission to create new topics.', 'bbpress' ) );
    153153            return;
     
    159159
    160160    // Remove kses filters from title and content for capable users and if the nonce is verified
    161     if ( current_user_can( 'unfiltered_html' ) && !empty( $_POST['_bbp_unfiltered_html_topic'] ) && wp_create_nonce( 'bbp-unfiltered-html-topic_new' ) === $_POST['_bbp_unfiltered_html_topic'] ) {
     161    if ( current_user_can( 'unfiltered_html' ) && ! empty( $_POST['_bbp_unfiltered_html_topic'] ) && wp_create_nonce( 'bbp-unfiltered-html-topic_new' ) === $_POST['_bbp_unfiltered_html_topic'] ) {
    162162        remove_filter( 'bbp_new_topic_pre_title',   'wp_filter_kses'      );
    163163        remove_filter( 'bbp_new_topic_pre_content', 'bbp_encode_bad',  10 );
     
    167167    /** Topic Title ***********************************************************/
    168168
    169     if ( !empty( $_POST['bbp_topic_title'] ) ) {
     169    if ( ! empty( $_POST['bbp_topic_title'] ) ) {
    170170        $topic_title = esc_attr( strip_tags( $_POST['bbp_topic_title'] ) );
    171171    }
     
    181181    /** Topic Content *********************************************************/
    182182
    183     if ( !empty( $_POST['bbp_topic_content'] ) ) {
     183    if ( ! empty( $_POST['bbp_topic_content'] ) ) {
    184184        $topic_content = $_POST['bbp_topic_content'];
    185185    }
     
    232232
    233233    // Forum exists
    234     if ( !empty( $forum_id ) ) {
     234    if ( ! empty( $forum_id ) ) {
    235235
    236236        // Forum is a category
     
    242242
    243243            // Forum is closed and user cannot access
    244             if ( bbp_is_forum_closed( $forum_id ) && !current_user_can( 'edit_forum', $forum_id ) ) {
     244            if ( bbp_is_forum_closed( $forum_id ) && ! current_user_can( 'edit_forum', $forum_id ) ) {
    245245                bbp_add_error( 'bbp_new_topic_forum_closed', __( '<strong>ERROR</strong>: This forum has been closed to new topics.', 'bbpress' ) );
    246246            }
     
    248248            // Forum is private and user cannot access
    249249            if ( bbp_is_forum_private( $forum_id ) ) {
    250                 if ( !current_user_can( 'read_private_forums' ) ) {
     250                if ( ! current_user_can( 'read_private_forums' ) ) {
    251251                    bbp_add_error( 'bbp_new_topic_forum_private', __( '<strong>ERROR</strong>: This forum is private and you do not have the capability to read or create new topics in it.', 'bbpress' ) );
    252252                }
     
    254254            // Forum is hidden and user cannot access
    255255            } elseif ( bbp_is_forum_hidden( $forum_id ) ) {
    256                 if ( !current_user_can( 'read_hidden_forums' ) ) {
     256                if ( ! current_user_can( 'read_hidden_forums' ) ) {
    257257                    bbp_add_error( 'bbp_new_topic_forum_hidden', __( '<strong>ERROR</strong>: This forum is hidden and you do not have the capability to read or create new topics in it.', 'bbpress' ) );
    258258                }
     
    263263    /** Topic Flooding ********************************************************/
    264264
    265     if ( !bbp_check_for_flood( $anonymous_data, $topic_author ) ) {
     265    if ( ! bbp_check_for_flood( $anonymous_data, $topic_author ) ) {
    266266        bbp_add_error( 'bbp_topic_flood', __( '<strong>ERROR</strong>: Slow down; you move too fast.', 'bbpress' ) );
    267267    }
     
    269269    /** Topic Duplicate *******************************************************/
    270270
    271     if ( !bbp_check_for_duplicate( array( 'post_type' => bbp_get_topic_post_type(), 'post_author' => $topic_author, 'post_content' => $topic_content, 'anonymous_data' => $anonymous_data ) ) ) {
     271    if ( ! bbp_check_for_duplicate( array( 'post_type' => bbp_get_topic_post_type(), 'post_author' => $topic_author, 'post_content' => $topic_content, 'anonymous_data' => $anonymous_data ) ) ) {
    272272        bbp_add_error( 'bbp_topic_duplicate', __( '<strong>ERROR</strong>: Duplicate topic detected; it looks as though you&#8217;ve already said that!', 'bbpress' ) );
    273273    }
     
    275275    /** Topic Blacklist *******************************************************/
    276276
    277     if ( !bbp_check_for_blacklist( $anonymous_data, $topic_author, $topic_title, $topic_content ) ) {
     277    if ( ! bbp_check_for_blacklist( $anonymous_data, $topic_author, $topic_title, $topic_content ) ) {
    278278        bbp_add_error( 'bbp_topic_blacklist', __( '<strong>ERROR</strong>: Your topic cannot be created at this time.', 'bbpress' ) );
    279279    }
     
    282282
    283283    // Maybe put into moderation
    284     if ( !bbp_check_for_moderation( $anonymous_data, $topic_author, $topic_title, $topic_content ) ) {
     284    if ( ! bbp_check_for_moderation( $anonymous_data, $topic_author, $topic_title, $topic_content ) ) {
    285285        $topic_status = bbp_get_pending_status_id();
    286286
    287287    // Check a whitelist of possible topic status ID's
    288     } elseif ( !empty( $_POST['bbp_topic_status'] ) && in_array( $_POST['bbp_topic_status'], array_keys( bbp_get_topic_statuses() ) ) ) {
     288    } elseif ( ! empty( $_POST['bbp_topic_status'] ) && in_array( $_POST['bbp_topic_status'], array_keys( bbp_get_topic_statuses() ) ) ) {
    289289        $topic_status = $_POST['bbp_topic_status'];
    290290
     
    296296    /** Topic Tags ************************************************************/
    297297
    298     if ( bbp_allow_topic_tags() && !empty( $_POST['bbp_topic_tags'] ) ) {
     298    if ( bbp_allow_topic_tags() && ! empty( $_POST['bbp_topic_tags'] ) ) {
    299299
    300300        // Escape tag input
     
    339339    /** No Errors *************************************************************/
    340340
    341     if ( !empty( $topic_id ) && !is_wp_error( $topic_id ) ) {
     341    if ( ! empty( $topic_id ) && ! is_wp_error( $topic_id ) ) {
    342342
    343343        /** Trash Check *******************************************************/
     
    371371
    372372        // Sticky check after 'bbp_new_topic' action so forum ID meta is set
    373         if ( !empty( $_POST['bbp_stick_topic'] ) && in_array( $_POST['bbp_stick_topic'], array( 'stick', 'super', 'unstick' ) ) ) {
     373        if ( ! empty( $_POST['bbp_stick_topic'] ) && in_array( $_POST['bbp_stick_topic'], array( 'stick', 'super', 'unstick' ) ) ) {
    374374
    375375            // What's the caps?
     
    410410
    411411        // Add view all?
    412         if ( bbp_get_view_all() || !empty( $view_all ) ) {
     412        if ( bbp_get_view_all() || ! empty( $view_all ) ) {
    413413
    414414            // User can moderate, so redirect to topic with view all set
     
    512512
    513513            // User cannot edit this topic
    514             if ( !current_user_can( 'edit_topic', $topic_id ) ) {
     514            if ( ! current_user_can( 'edit_topic', $topic_id ) ) {
    515515                bbp_add_error( 'bbp_edit_topic_permissions', __( '<strong>ERROR</strong>: You do not have permission to edit that topic.', 'bbpress' ) );
    516516            }
     
    534534
    535535    // Remove kses filters from title and content for capable users and if the nonce is verified
    536     if ( current_user_can( 'unfiltered_html' ) && !empty( $_POST['_bbp_unfiltered_html_topic'] ) && ( wp_create_nonce( 'bbp-unfiltered-html-topic_' . $topic_id ) === $_POST['_bbp_unfiltered_html_topic'] ) ) {
     536    if ( current_user_can( 'unfiltered_html' ) && ! empty( $_POST['_bbp_unfiltered_html_topic'] ) && ( wp_create_nonce( 'bbp-unfiltered-html-topic_' . $topic_id ) === $_POST['_bbp_unfiltered_html_topic'] ) ) {
    537537        remove_filter( 'bbp_edit_topic_pre_title',   'wp_filter_kses'      );
    538538        remove_filter( 'bbp_edit_topic_pre_content', 'bbp_encode_bad',  10 );
     
    555555
    556556    // Forum exists
    557     if ( !empty( $forum_id ) && ( $forum_id !== $current_forum_id ) ) {
     557    if ( ! empty( $forum_id ) && ( $forum_id !== $current_forum_id ) ) {
    558558
    559559        // Forum is a category
     
    565565
    566566            // Forum is closed and user cannot access
    567             if ( bbp_is_forum_closed( $forum_id ) && !current_user_can( 'edit_forum', $forum_id ) ) {
     567            if ( bbp_is_forum_closed( $forum_id ) && ! current_user_can( 'edit_forum', $forum_id ) ) {
    568568                bbp_add_error( 'bbp_edit_topic_forum_closed', __( '<strong>ERROR</strong>: This forum has been closed to new topics.', 'bbpress' ) );
    569569            }
     
    571571            // Forum is private and user cannot access
    572572            if ( bbp_is_forum_private( $forum_id ) ) {
    573                 if ( !current_user_can( 'read_private_forums' ) ) {
     573                if ( ! current_user_can( 'read_private_forums' ) ) {
    574574                    bbp_add_error( 'bbp_edit_topic_forum_private', __( '<strong>ERROR</strong>: This forum is private and you do not have the capability to read or create new topics in it.', 'bbpress' ) );
    575575                }
     
    577577            // Forum is hidden and user cannot access
    578578            } elseif ( bbp_is_forum_hidden( $forum_id ) ) {
    579                 if ( !current_user_can( 'read_hidden_forums' ) ) {
     579                if ( ! current_user_can( 'read_hidden_forums' ) ) {
    580580                    bbp_add_error( 'bbp_edit_topic_forum_hidden', __( '<strong>ERROR</strong>: This forum is hidden and you do not have the capability to read or create new topics in it.', 'bbpress' ) );
    581581                }
     
    586586    /** Topic Title ***********************************************************/
    587587
    588     if ( !empty( $_POST['bbp_topic_title'] ) ) {
     588    if ( ! empty( $_POST['bbp_topic_title'] ) ) {
    589589        $topic_title = esc_attr( strip_tags( $_POST['bbp_topic_title'] ) );
    590590    }
     
    600600    /** Topic Content *********************************************************/
    601601
    602     if ( !empty( $_POST['bbp_topic_content'] ) ) {
     602    if ( ! empty( $_POST['bbp_topic_content'] ) ) {
    603603        $topic_content = $_POST['bbp_topic_content'];
    604604    }
     
    614614    /** Topic Blacklist *******************************************************/
    615615
    616     if ( !bbp_check_for_blacklist( $anonymous_data, $topic_author, $topic_title, $topic_content ) ) {
     616    if ( ! bbp_check_for_blacklist( $anonymous_data, $topic_author, $topic_title, $topic_content ) ) {
    617617        bbp_add_error( 'bbp_topic_blacklist', __( '<strong>ERROR</strong>: Your topic cannot be edited at this time.', 'bbpress' ) );
    618618    }
     
    621621
    622622    // Maybe put into moderation
    623     if ( !bbp_check_for_moderation( $anonymous_data, $topic_author, $topic_title, $topic_content ) ) {
     623    if ( ! bbp_check_for_moderation( $anonymous_data, $topic_author, $topic_title, $topic_content ) ) {
    624624
    625625        // Set post status to pending if public or closed
     
    629629
    630630    // Check a whitelist of possible topic status ID's
    631     } elseif ( !empty( $_POST['bbp_topic_status'] ) && in_array( $_POST['bbp_topic_status'], array_keys( bbp_get_topic_statuses() ) ) ) {
     631    } elseif ( ! empty( $_POST['bbp_topic_status'] ) && in_array( $_POST['bbp_topic_status'], array_keys( bbp_get_topic_statuses() ) ) ) {
    632632        $topic_status = $_POST['bbp_topic_status'];
    633633
     
    703703    /** No Errors *************************************************************/
    704704
    705     if ( !empty( $topic_id ) && !is_wp_error( $topic_id ) ) {
     705    if ( ! empty( $topic_id ) && ! is_wp_error( $topic_id ) ) {
    706706
    707707        // Update counts, etc...
     
    711711
    712712        // Revision Reason
    713         if ( !empty( $_POST['bbp_topic_edit_reason'] ) ) {
     713        if ( ! empty( $_POST['bbp_topic_edit_reason'] ) ) {
    714714            $topic_edit_reason = esc_attr( strip_tags( $_POST['bbp_topic_edit_reason'] ) );
    715715        }
    716716
    717717        // Update revision log
    718         if ( !empty( $_POST['bbp_log_topic_edit'] ) && ( "1" === $_POST['bbp_log_topic_edit'] ) )  {
     718        if ( ! empty( $_POST['bbp_log_topic_edit'] ) && ( "1" === $_POST['bbp_log_topic_edit'] ) )  {
    719719            $revision_id = wp_save_post_revision( $topic_id );
    720720            if ( ! empty( $revision_id ) ) {
     
    739739        /** Stickies **********************************************************/
    740740
    741         if ( !empty( $_POST['bbp_stick_topic'] ) && in_array( $_POST['bbp_stick_topic'], array_keys( bbp_get_topic_types() ) ) ) {
     741        if ( ! empty( $_POST['bbp_stick_topic'] ) && in_array( $_POST['bbp_stick_topic'], array_keys( bbp_get_topic_types() ) ) ) {
    742742
    743743            // What's the caps?
     
    782782
    783783        // Add view all?
    784         if ( !empty( $view_all ) ) {
     784        if ( ! empty( $view_all ) ) {
    785785            $topic_url = bbp_add_view_all( $topic_url );
    786786        }
     
    859859    // It expects anonymous_data to be sanitized.
    860860    // Check bbp_filter_anonymous_post_data() for sanitization.
    861     if ( !empty( $anonymous_data ) && is_array( $anonymous_data ) ) {
     861    if ( ! empty( $anonymous_data ) && is_array( $anonymous_data ) ) {
    862862
    863863        // Parse arguments against default values
     
    879879
    880880    } else {
    881         if ( empty( $is_edit ) && !current_user_can( 'throttle' ) ) {
     881        if ( empty( $is_edit ) && ! current_user_can( 'throttle' ) ) {
    882882            bbp_update_user_last_posted( $author_id );
    883883        }
     
    885885
    886886    // Handle Subscription Checkbox
    887     if ( bbp_is_subscriptions_active() && !empty( $author_id ) ) {
     887    if ( bbp_is_subscriptions_active() && ! empty( $author_id ) ) {
    888888        $subscribed = bbp_is_user_subscribed( $author_id, $topic_id );
    889         $subscheck  = ( !empty( $_POST['bbp_topic_subscription'] ) && ( 'bbp_subscribe' === $_POST['bbp_topic_subscription'] ) ) ? true : false;
     889        $subscheck  = ( ! empty( $_POST['bbp_topic_subscription'] ) && ( 'bbp_subscribe' === $_POST['bbp_topic_subscription'] ) ) ? true : false;
    890890
    891891        // Subscribed and unsubscribing
     
    952952
    953953    // Topic was passed
    954     if ( !empty( $topic_id ) ) {
     954    if ( ! empty( $topic_id ) ) {
    955955
    956956        // Get the forum ID if none was passed
     
    976976
    977977    // Loop through ancestors
    978     if ( !empty( $ancestors ) ) {
     978    if ( ! empty( $ancestors ) ) {
    979979        foreach ( $ancestors as $ancestor ) {
    980980
     
    10331033
    10341034    // Only proceed if stickies are found
    1035     if ( !empty( $old_stickies ) ) {
     1035    if ( ! empty( $old_stickies ) ) {
    10361036
    10371037        // Define local variables
     
    10781078
    10791079    // Loop through ancestors and update them
    1080     if ( !empty( $old_forum_ancestors ) ) {
     1080    if ( ! empty( $old_forum_ancestors ) ) {
    10811081        foreach ( $old_forum_ancestors as $ancestor ) {
    10821082            if ( bbp_is_forum( $ancestor ) ) {
     
    10911091
    10921092    // Make sure we're not walking twice
    1093     if ( !in_array( $new_forum_id, $old_forum_ancestors ) ) {
     1093    if ( ! in_array( $new_forum_id, $old_forum_ancestors ) ) {
    10941094
    10951095        // Get topic ancestors
     
    11001100
    11011101        // Loop through ancestors and update them
    1102         if ( !empty( $new_forum_ancestors ) ) {
     1102        if ( ! empty( $new_forum_ancestors ) ) {
    11031103            foreach ( $new_forum_ancestors as $ancestor ) {
    11041104                if ( bbp_is_forum( $ancestor ) ) {
     
    11841184
    11851185    // Cannot edit source topic
    1186     if ( !current_user_can( 'edit_topic', $source_topic->ID ) ) {
     1186    if ( ! current_user_can( 'edit_topic', $source_topic->ID ) ) {
    11871187        bbp_add_error( 'bbp_merge_topic_source_permission', __( '<strong>ERROR</strong>: You do not have the permissions to edit the source topic.', 'bbpress' ) );
    11881188        return;
     
    12041204
    12051205    // Cannot edit destination topic
    1206     if ( !current_user_can( 'edit_topic', $destination_topic->ID ) ) {
     1206    if ( ! current_user_can( 'edit_topic', $destination_topic->ID ) ) {
    12071207        bbp_add_error( 'bbp_merge_topic_destination_permission', __( '<strong>ERROR</strong>: You do not have the permissions to edit the destination topic.', 'bbpress' ) );
    12081208    }
     
    12401240
    12411241    // Remove the topic from everybody's subscriptions
    1242     if ( !empty( $subscribers ) ) {
     1242    if ( ! empty( $subscribers ) ) {
    12431243
    12441244        // Loop through each user
     
    12461246
    12471247            // Shift the subscriber if told to
    1248             if ( !empty( $_POST['bbp_topic_subscribers'] ) && ( "1" === $_POST['bbp_topic_subscribers'] ) && bbp_is_subscriptions_active() ) {
     1248            if ( ! empty( $_POST['bbp_topic_subscribers'] ) && ( "1" === $_POST['bbp_topic_subscribers'] ) && bbp_is_subscriptions_active() ) {
    12491249                bbp_add_user_subscription( $subscriber, $destination_topic->ID );
    12501250            }
     
    12611261
    12621262    // Remove the topic from everybody's favorites
    1263     if ( !empty( $favoriters ) ) {
     1263    if ( ! empty( $favoriters ) ) {
    12641264
    12651265        // Loop through each user
     
    12671267
    12681268            // Shift the favoriter if told to
    1269             if ( !empty( $_POST['bbp_topic_favoriters'] ) && "1" === $_POST['bbp_topic_favoriters'] ) {
     1269            if ( ! empty( $_POST['bbp_topic_favoriters'] ) && "1" === $_POST['bbp_topic_favoriters'] ) {
    12701270                bbp_add_user_favorite( $favoriter, $destination_topic->ID );
    12711271            }
     
    12821282
    12831283    // Tags to possibly merge
    1284     if ( !empty( $source_topic_tags ) && !is_wp_error( $source_topic_tags ) ) {
     1284    if ( ! empty( $source_topic_tags ) && ! is_wp_error( $source_topic_tags ) ) {
    12851285
    12861286        // Shift the tags if told to
    1287         if ( !empty( $_POST['bbp_topic_tags'] ) && ( "1" === $_POST['bbp_topic_tags'] ) ) {
     1287        if ( ! empty( $_POST['bbp_topic_tags'] ) && ( "1" === $_POST['bbp_topic_tags'] ) ) {
    12881288            wp_set_post_terms( $destination_topic->ID, $source_topic_tags, bbp_get_topic_tag_tax_id(), true );
    12891289        }
     
    13121312    array_unshift( $replies, $source_topic );
    13131313
    1314     if ( !empty( $replies ) ) {
     1314    if ( ! empty( $replies ) ) {
    13151315
    13161316        /** Merge Replies *****************************************************/
     
    14941494
    14951495    // Use cannot edit topic
    1496     if ( !current_user_can( 'edit_topic', $source_topic->ID ) ) {
     1496    if ( ! current_user_can( 'edit_topic', $source_topic->ID ) ) {
    14971497        bbp_add_error( 'bbp_split_topic_source_permission', __( '<strong>ERROR</strong>: You do not have the permissions to edit the source topic.', 'bbpress' ) );
    14981498    }
    14991499
    15001500    // How to Split
    1501     if ( !empty( $_POST['bbp_topic_split_option'] ) ) {
     1501    if ( ! empty( $_POST['bbp_topic_split_option'] ) ) {
    15021502        $split_option = (string) trim( $_POST['bbp_topic_split_option'] );
    15031503    }
    15041504
    15051505    // Invalid split option
    1506     if ( empty( $split_option ) || !in_array( $split_option, array( 'existing', 'reply' ) ) ) {
     1506    if ( empty( $split_option ) || ! in_array( $split_option, array( 'existing', 'reply' ) ) ) {
    15071507        bbp_add_error( 'bbp_split_topic_option', __( '<strong>ERROR</strong>: You need to choose a valid split option.', 'bbpress' ) );
    15081508
     
    15321532
    15331533                // User cannot edit the destination topic
    1534                 if ( !current_user_can( 'edit_topic', $destination_topic->ID ) ) {
     1534                if ( ! current_user_can( 'edit_topic', $destination_topic->ID ) ) {
    15351535                    bbp_add_error( 'bbp_split_topic_destination_permission', __( '<strong>ERROR</strong>: You do not have the permissions to edit the destination topic!', 'bbpress' ) );
    15361536                }
     
    15461546
    15471547                    // Use the new title that was passed
    1548                     if ( !empty( $_POST['bbp_topic_split_destination_title'] ) ) {
     1548                    if ( ! empty( $_POST['bbp_topic_split_destination_title'] ) ) {
    15491549                        $destination_topic_title = esc_attr( strip_tags( $_POST['bbp_topic_split_destination_title'] ) );
    15501550
     
    16121612
    16131613    // Copy the subscribers
    1614     if ( !empty( $_POST['bbp_topic_subscribers'] ) && "1" === $_POST['bbp_topic_subscribers'] && bbp_is_subscriptions_active() ) {
     1614    if ( ! empty( $_POST['bbp_topic_subscribers'] ) && "1" === $_POST['bbp_topic_subscribers'] && bbp_is_subscriptions_active() ) {
    16151615
    16161616        // Get the subscribers
    16171617        $subscribers = bbp_get_topic_subscribers( $source_topic->ID );
    16181618
    1619         if ( !empty( $subscribers ) ) {
     1619        if ( ! empty( $subscribers ) ) {
    16201620
    16211621            // Add subscribers to new topic
     
    16291629
    16301630    // Copy the favoriters if told to
    1631     if ( !empty( $_POST['bbp_topic_favoriters'] ) && ( "1" === $_POST['bbp_topic_favoriters'] ) ) {
     1631    if ( ! empty( $_POST['bbp_topic_favoriters'] ) && ( "1" === $_POST['bbp_topic_favoriters'] ) ) {
    16321632
    16331633        // Get the favoriters
    16341634        $favoriters = bbp_get_topic_favoriters( $source_topic->ID );
    16351635
    1636         if ( !empty( $favoriters ) ) {
     1636        if ( ! empty( $favoriters ) ) {
    16371637
    16381638            // Add the favoriters to new topic
     
    16461646
    16471647    // Copy the tags if told to
    1648     if ( !empty( $_POST['bbp_topic_tags'] ) && ( "1" === $_POST['bbp_topic_tags'] ) ) {
     1648    if ( ! empty( $_POST['bbp_topic_tags'] ) && ( "1" === $_POST['bbp_topic_tags'] ) ) {
    16491649
    16501650        // Get the source topic tags
    16511651        $source_topic_tags = wp_get_post_terms( $source_topic->ID, bbp_get_topic_tag_tax_id(), array( 'fields' => 'names' ) );
    16521652
    1653         if ( !empty( $source_topic_tags ) ) {
     1653        if ( ! empty( $source_topic_tags ) ) {
    16541654            wp_set_post_terms( $destination_topic->ID, $source_topic_tags, bbp_get_topic_tag_tax_id(), true );
    16551655        }
     
    16631663
    16641664    // Make sure there are replies to loop through
    1665     if ( !empty( $replies ) && !is_wp_error( $replies ) ) {
     1665    if ( ! empty( $replies ) && ! is_wp_error( $replies ) ) {
    16661666
    16671667        // Calculate starting point for reply positions
     
    17091709
    17101710            // Not a reply to a reply that moved over
    1711             if ( !in_array( $reply_to, $reply_ids ) ) {
     1711            if ( ! in_array( $reply_to, $reply_ids ) ) {
    17121712                bbp_update_reply_to( $reply->ID, 0 );
    17131713            }
     
    18391839
    18401840    // Bail if actions aren't meant for this function
    1841     if ( !in_array( $action, $possible_actions ) ) {
     1841    if ( ! in_array( $action, $possible_actions ) ) {
    18421842        return;
    18431843    }
     
    18661866
    18671867            // Can user edit topic tags?
    1868             if ( !current_user_can( 'edit_topic_tags' ) ) {
     1868            if ( ! current_user_can( 'edit_topic_tags' ) ) {
    18691869                bbp_add_error( 'bbp_manage_topic_tag_update_permissions', __( '<strong>ERROR</strong>: You do not have the permissions to edit the topic tags.', 'bbpress' ) );
    18701870                return;
     
    18781878
    18791879            // Attempt to update the tag
    1880             $slug        = !empty( $_POST['tag-slug']        ) ? $_POST['tag-slug']        : '';
    1881             $description = !empty( $_POST['tag-description'] ) ? $_POST['tag-description'] : '';
     1880            $slug        = ! empty( $_POST['tag-slug']        ) ? $_POST['tag-slug']        : '';
     1881            $description = ! empty( $_POST['tag-description'] ) ? $_POST['tag-description'] : '';
    18821882            $tag         = wp_update_term( $tag_id, bbp_get_topic_tag_tax_id(), array( 'name' => $name, 'slug' => $slug, 'description' => $description ) );
    18831883
     
    19061906
    19071907            // Can user edit topic tags?
    1908             if ( !current_user_can( 'edit_topic_tags' ) ) {
     1908            if ( ! current_user_can( 'edit_topic_tags' ) ) {
    19091909                bbp_add_error( 'bbp_manage_topic_tag_merge_permissions', __( '<strong>ERROR</strong>: You do not have the permissions to edit the topic tags.', 'bbpress' ) );
    19101910                return;
     
    19641964
    19651965            // Can user delete topic tags?
    1966             if ( !current_user_can( 'delete_topic_tags' ) ) {
     1966            if ( ! current_user_can( 'delete_topic_tags' ) ) {
    19671967                bbp_add_error( 'bbp_manage_topic_tag_delete_permissions', __( '<strong>ERROR</strong>: You do not have the permissions to delete the topic tags.', 'bbpress' ) );
    19681968                return;
     
    19901990
    19911991    // Redirect back
    1992     $redirect = ( !empty( $redirect ) && !is_wp_error( $redirect ) ) ? $redirect : home_url();
     1992    $redirect = ( ! empty( $redirect ) && ! is_wp_error( $redirect ) ) ? $redirect : home_url();
    19931993    wp_safe_redirect( $redirect );
    19941994
     
    20462046function bbp_get_stickies( $forum_id = 0 ) {
    20472047    $stickies = empty( $forum_id ) ? bbp_get_super_stickies() : get_post_meta( $forum_id, '_bbp_sticky_topics', true );
    2048     $stickies = ( empty( $stickies ) || !is_array( $stickies ) ) ? array() : $stickies;
     2048    $stickies = ( empty( $stickies ) || ! is_array( $stickies ) ) ? array() : $stickies;
    20492049
    20502050    return apply_filters( 'bbp_get_stickies', $stickies, (int) $forum_id );
     
    20622062function bbp_get_super_stickies() {
    20632063    $stickies = get_option( '_bbp_super_sticky_topics', array() );
    2064     $stickies = ( empty( $stickies ) || !is_array( $stickies ) ) ? array() : $stickies;
     2064    $stickies = ( empty( $stickies ) || ! is_array( $stickies ) ) ? array() : $stickies;
    20652065
    20662066    return apply_filters( 'bbp_get_super_stickies', $stickies );
     
    21172117
    21182118    // Bail if actions aren't meant for this function
    2119     if ( !in_array( $action, $possible_actions ) ) {
     2119    if ( ! in_array( $action, $possible_actions ) ) {
    21202120        return;
    21212121    }
     
    21352135
    21362136    // What is the user doing here?
    2137     if ( !current_user_can( 'edit_topic', $topic->ID ) || ( 'bbp_toggle_topic_trash' === $action && !current_user_can( 'delete_topic', $topic->ID ) ) ) {
     2137    if ( ! current_user_can( 'edit_topic', $topic->ID ) || ( 'bbp_toggle_topic_trash' === $action && ! current_user_can( 'delete_topic', $topic->ID ) ) ) {
    21382138        bbp_add_error( 'bbp_toggle_topic_permission', __( '<strong>ERROR:</strong> You do not have the permission to do that.', 'bbpress' ) );
    21392139        return;
     
    21582158
    21592159            $is_sticky = bbp_is_topic_sticky( $topic_id );
    2160             $is_super  = false === $is_sticky && !empty( $_GET['super'] ) && ( "1" === $_GET['super'] ) ? true : false;
     2160            $is_super  = false === $is_sticky && ! empty( $_GET['super'] ) && ( "1" === $_GET['super'] ) ? true : false;
    21612161            $success   = true  === $is_sticky ? bbp_unstick_topic( $topic_id ) : bbp_stick_topic( $topic_id, $is_super );
    21622162            $failure   = true  === $is_sticky ? __( '<strong>ERROR</strong>: There was a problem unsticking the topic.', 'bbpress' ) : __( '<strong>ERROR</strong>: There was a problem sticking the topic.', 'bbpress' );
     
    21782178        case 'bbp_toggle_topic_trash' :
    21792179
    2180             $sub_action = !empty( $_GET['sub_action'] ) && in_array( $_GET['sub_action'], array( 'trash', 'untrash', 'delete' ) ) ? $_GET['sub_action'] : false;
     2180            $sub_action = ! empty( $_GET['sub_action'] ) && in_array( $_GET['sub_action'], array( 'trash', 'untrash', 'delete' ) ) ? $_GET['sub_action'] : false;
    21812181
    21822182            if ( empty( $sub_action ) ) {
     
    22182218
    22192219    // No errors
    2220     if ( false !== $success && !is_wp_error( $success ) ) {
     2220    if ( false !== $success && ! is_wp_error( $success ) ) {
    22212221
    22222222        // Redirect back to the topic's forum
     
    22672267
    22682268    // Users exist
    2269     if ( !empty( $users ) ) {
     2269    if ( ! empty( $users ) ) {
    22702270
    22712271        // Loop through users
     
    22922292
    22932293    // Subscriptions are not active
    2294     if ( !bbp_is_subscriptions_active() ) {
     2294    if ( ! bbp_is_subscriptions_active() ) {
    22952295        return;
    22962296    }
     
    23072307
    23082308    // Users exist
    2309     if ( !empty( $users ) ) {
     2309    if ( ! empty( $users ) ) {
    23102310
    23112311        // Loop through users
     
    25362536
    25372537    // Adjust last_id's based on last_reply post_type
    2538     if ( empty( $active_id ) || !bbp_is_reply( $active_id ) ) {
     2538    if ( empty( $active_id ) || ! bbp_is_reply( $active_id ) ) {
    25392539        $active_id = $topic_id;
    25402540    }
     
    25762576
    25772577    // Update only if published
    2578     if ( !empty( $new_time ) ) {
     2578    if ( ! empty( $new_time ) ) {
    25792579        update_post_meta( $topic_id, '_bbp_last_active_time', $new_time );
    25802580    }
     
    26172617
    26182618    // Adjust last_id's based on last_reply post_type
    2619     if ( empty( $reply_id ) || !bbp_is_reply( $reply_id ) ) {
     2619    if ( empty( $reply_id ) || ! bbp_is_reply( $reply_id ) ) {
    26202620        $reply_id = 0;
    26212621    }
     
    29332933    ) );
    29342934
    2935     if ( !empty( $replies->posts ) ) {
     2935    if ( ! empty( $replies->posts ) ) {
    29362936
    29372937        // Prevent debug notices
     
    29762976
    29772977    // Topic has tags
    2978     if ( !empty( $terms ) ) {
     2978    if ( ! empty( $terms ) ) {
    29792979
    29802980        // Loop through and collect term names
     
    29842984
    29852985        // Topic terms have slugs
    2986         if ( !empty( $term_names ) ) {
     2986        if ( ! empty( $term_names ) ) {
    29872987
    29882988            // Add the original post status as post meta for future restoration
     
    30703070
    30713071    // There are replies to untrash
    3072     if ( !empty( $pre_spammed_replies ) ) {
     3072    if ( ! empty( $pre_spammed_replies ) ) {
    30733073
    30743074        // Maybe reverse the trashed replies array
     
    31053105
    31063106    // Delete pre-spam topic tag meta
    3107     if ( !empty( $terms ) ) {
     3107    if ( ! empty( $terms ) ) {
    31083108        delete_post_meta( $topic_id, '_bbp_spam_topic_tags' );
    31093109    }
     
    31493149    do_action( 'bbp_stick_topic', $topic_id, $super );
    31503150
    3151     if ( !is_array( $stickies ) ) {
     3151    if ( ! is_array( $stickies ) ) {
    31523152        $stickies   = array( $topic_id );
    31533153    } else {
     
    31673167    // Reset keys
    31683168    $stickies = array_values( $stickies );
    3169     $success  = !empty( $super ) ? update_option( '_bbp_super_sticky_topics', $stickies ) : update_post_meta( $forum_id, '_bbp_sticky_topics', $stickies );
     3169    $success  = ! empty( $super ) ? update_option( '_bbp_super_sticky_topics', $stickies ) : update_post_meta( $forum_id, '_bbp_sticky_topics', $stickies );
    31703170
    31713171    do_action( 'bbp_stuck_topic', $topic_id, $super, $success );
     
    32033203    if ( empty( $stickies ) ) {
    32043204        $success = true;
    3205     } elseif ( !in_array( $topic_id, $stickies ) ) {
     3205    } elseif ( ! in_array( $topic_id, $stickies ) ) {
    32063206        $success = true;
    32073207    } elseif ( false === $offset ) {
     
    32103210        array_splice( $stickies, $offset, 1 );
    32113211        if ( empty( $stickies ) ) {
    3212             $success = !empty( $super ) ? delete_option( '_bbp_super_sticky_topics'            ) : delete_post_meta( $forum_id, '_bbp_sticky_topics'            );
     3212            $success = ! empty( $super ) ? delete_option( '_bbp_super_sticky_topics'            ) : delete_post_meta( $forum_id, '_bbp_sticky_topics'            );
    32133213        } else {
    3214             $success = !empty( $super ) ? update_option( '_bbp_super_sticky_topics', $stickies ) : update_post_meta( $forum_id, '_bbp_sticky_topics', $stickies );
     3214            $success = ! empty( $super ) ? update_option( '_bbp_super_sticky_topics', $stickies ) : update_post_meta( $forum_id, '_bbp_sticky_topics', $stickies );
    32153215        }
    32163216    }
     
    33383338    ) );
    33393339
    3340     if ( !empty( $replies->posts ) ) {
     3340    if ( ! empty( $replies->posts ) ) {
    33413341
    33423342        // Prevent debug notices
     
    33973397
    33983398    // There are replies to untrash
    3399     if ( !empty( $pre_trashed_replies ) ) {
     3399    if ( ! empty( $pre_trashed_replies ) ) {
    34003400
    34013401        // Maybe reverse the trashed replies array
     
    35353535        $terms[] = $term->name;
    35363536    }
    3537     $terms = !empty( $terms ) ? implode( $sep, $terms ) : '';
     3537    $terms = ! empty( $terms ) ? implode( $sep, $terms ) : '';
    35383538
    35393539    return apply_filters( 'bbp_get_topic_tags', $terms, $topic_id );
     
    35903590
    35913591    // User cannot access this forum
    3592     if ( bbp_is_single_forum() && !bbp_user_can_view_forum( array( 'forum_id' => bbp_get_forum_id() ) ) ) {
     3592    if ( bbp_is_single_forum() && ! bbp_user_can_view_forum( array( 'forum_id' => bbp_get_forum_id() ) ) ) {
    35933593        return;
    35943594    }
     
    36813681
    36823682    // User cannot edit topic, so redirect back to topic
    3683     if ( !current_user_can( 'edit_topic', bbp_get_topic_id() ) ) {
     3683    if ( ! current_user_can( 'edit_topic', bbp_get_topic_id() ) ) {
    36843684        wp_safe_redirect( bbp_get_topic_permalink() );
    36853685        exit();
     
    37063706
    37073707    // Bail if current user cannot edit topic tags
    3708     if ( !current_user_can( 'edit_topic_tags', bbp_get_topic_tag_id() ) ) {
     3708    if ( ! current_user_can( 'edit_topic_tags', bbp_get_topic_tag_id() ) ) {
    37093709        wp_safe_redirect( bbp_get_topic_tag_link() );
    37103710        exit();
Note: See TracChangeset for help on using the changeset viewer.