Skip to:
Content

bbPress.org

Changeset 5442


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

Breathing room for ! usages in Users component.

Location:
trunk/src/includes/users
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/includes/users/capabilities.php

    r5436 r5442  
    6363
    6464    // User exists
    65     if ( !empty( $user ) ) {
     65    if ( ! empty( $user ) ) {
    6666
    6767        // Get users forum role
     
    8181
    8282            // Add the new role
    83             if ( !empty( $new_role ) ) {
     83            if ( ! empty( $new_role ) ) {
    8484
    8585                // Make sure bbPress roles are added
     
    128128        // smart, but since roles aren't exactly hierarchical, and bbPress
    129129        // does not yet have a UI for multiple user roles, it's fine for now.
    130         if ( !empty( $roles ) ) {
     130        if ( ! empty( $roles ) ) {
    131131            $role = array_shift( $roles );
    132132        }
     
    161161
    162162        // Look for a non bbPress role
    163         $roles     = array_intersect(
     163        $roles = array_intersect(
    164164            array_values( $user->roles ),
    165165            array_keys( bbp_get_blog_roles() )
     
    169169        // smart, but since roles aren't exactly hierarchical, and WordPress
    170170        // does not yet have a UI for multiple user roles, it's fine for now.
    171         if ( !empty( $roles ) ) {
     171        if ( ! empty( $roles ) ) {
    172172            $role = array_shift( $roles );
    173173        }
     
    371371
    372372    // Check if spam
    373     } elseif ( !empty( $user->spam ) ) {
     373    } elseif ( ! empty( $user->spam ) ) {
    374374        $is_spammer = true;
    375375    }
     
    405405
    406406    // Use displayed user if it's not yourself
    407     if ( empty( $user_id ) && bbp_is_single_user() && !bbp_is_user_home() ) {
     407    if ( empty( $user_id ) && bbp_is_single_user() && ! bbp_is_user_home() ) {
    408408        $user_id = bbp_get_displayed_user_id();
    409409    }
     
    444444
    445445        // Loop through posts and spam them
    446         if ( !empty( $posts ) ) {
     446        if ( ! empty( $posts ) ) {
    447447            foreach ( $posts as $post_id ) {
    448448
     
    496496
    497497    // Use displayed user if it's not yourself
    498     if ( empty( $user_id ) && bbp_is_single_user() && !bbp_is_user_home() ) {
     498    if ( empty( $user_id ) && bbp_is_single_user() && ! bbp_is_user_home() ) {
    499499        $user_id = bbp_get_displayed_user_id();
    500500    }
     
    535535
    536536        // Loop through posts and spam them
    537         if ( !empty( $posts ) ) {
     537        if ( ! empty( $posts ) ) {
    538538            foreach ( $posts as $post_id ) {
    539539
     
    592592
    593593    // Check if deleted
    594     } elseif ( !empty( $user->deleted ) ) {
     594    } elseif ( ! empty( $user->deleted ) ) {
    595595        $is_deleted = true;
    596596    }
     
    663663
    664664    // Return the inverse of active
    665     return !bbp_is_user_active( $user_id );
     665    return ! bbp_is_user_active( $user_id );
    666666}
    667667
  • trunk/src/includes/users/functions.php

    r5436 r5442  
    2828
    2929    // Raw redirect_to was passed, so use it
    30     if ( !empty( $raw_url ) ) {
     30    if ( ! empty( $raw_url ) ) {
    3131        $url = $raw_url;
    3232
     
    104104        $bbp_current_poster = wp_get_current_commenter();
    105105
    106         if ( !empty( $key ) && in_array( $key, array_keys( $cookie_names ) ) ) {
     106        if ( ! empty( $key ) && in_array( $key, array_keys( $cookie_names ) ) ) {
    107107            return $bbp_current_poster[$cookie_names[$key]];
    108108        }
     
    125125 */
    126126function bbp_set_current_anonymous_user_data( $anonymous_data = array() ) {
    127     if ( empty( $anonymous_data ) || !is_array( $anonymous_data ) ) {
     127    if ( empty( $anonymous_data ) || ! is_array( $anonymous_data ) ) {
    128128        return;
    129129    }
     
    157157 */
    158158function bbp_current_author_ua() {
    159     $retval = !empty( $_SERVER['HTTP_USER_AGENT'] ) ? substr( $_SERVER['HTTP_USER_AGENT'], 0, 254 ) : '';
     159    $retval = ! empty( $_SERVER['HTTP_USER_AGENT'] ) ? substr( $_SERVER['HTTP_USER_AGENT'], 0, 254 ) : '';
    160160
    161161    return apply_filters( 'bbp_current_author_ua', $retval );
     
    213213    // If user has favorites, load them
    214214    $favorites = bbp_get_user_favorites_topic_ids( $user_id );
    215     if ( !empty( $favorites ) ) {
     215    if ( ! empty( $favorites ) ) {
    216216        $query = bbp_has_topics( array( 'post__in' => $favorites ) );
    217217    } else {
     
    271271    $favorites = bbp_get_user_favorites_topic_ids( $user_id );
    272272
    273     if ( !empty( $favorites ) ) {
     273    if ( ! empty( $favorites ) ) {
    274274
    275275        // Checking a specific topic id
    276         if ( !empty( $topic_id ) ) {
     276        if ( ! empty( $topic_id ) ) {
    277277            $topic    = bbp_get_topic( $topic_id );
    278             $topic_id = !empty( $topic ) ? $topic->ID : 0;
     278            $topic_id = ! empty( $topic ) ? $topic->ID : 0;
    279279
    280280        // Using the global topic id
     
    283283
    284284        // Use the current post id
    285         } elseif ( !bbp_get_topic_id() ) {
     285        } elseif ( ! bbp_get_topic_id() ) {
    286286            $topic_id = get_the_ID();
    287287        }
    288288
    289289        // Is topic_id in the user's favorites
    290         if ( !empty( $topic_id ) ) {
     290        if ( ! empty( $topic_id ) ) {
    291291            $retval = in_array( $topic_id, $favorites );
    292292        }
     
    319319
    320320    $favorites = bbp_get_user_favorites_topic_ids( $user_id );
    321     if ( !in_array( $topic_id, $favorites ) ) {
     321    if ( ! in_array( $topic_id, $favorites ) ) {
    322322        $favorites[] = $topic_id;
    323323        $favorites   = implode( ',', wp_parse_id_list( array_filter( $favorites ) ) );
     
    359359        $favorites = array_filter( $favorites );
    360360
    361         if ( !empty( $favorites ) ) {
     361        if ( ! empty( $favorites ) ) {
    362362            $favorites = implode( ',', wp_parse_id_list( $favorites ) );
    363363            update_user_option( $user_id, '_bbp_favorites', $favorites );
     
    392392function bbp_favorites_handler( $action = '' ) {
    393393
    394     if ( !bbp_is_favorites_active() ) {
     394    if ( ! bbp_is_favorites_active() ) {
    395395        return false;
    396396    }
     
    408408
    409409    // Bail if actions aren't meant for this function
    410     if ( !in_array( $action, $possible_actions ) ) {
     410    if ( ! in_array( $action, $possible_actions ) ) {
    411411        return;
    412412    }
     
    425425
    426426    // Check current user's ability to edit the user
    427     } elseif ( !current_user_can( 'edit_user', $user_id ) ) {
     427    } elseif ( ! current_user_can( 'edit_user', $user_id ) ) {
    428428        bbp_add_error( 'bbp_favorite_permissions', __( '<strong>ERROR</strong>: You don\'t have the permission to edit favorites of that user!', 'bbpress' ) );
    429429    }
     
    574574    // If user has subscriptions, load them
    575575    $subscriptions = bbp_get_user_subscribed_topic_ids( $user_id );
    576     if ( !empty( $subscriptions ) ) {
     576    if ( ! empty( $subscriptions ) ) {
    577577        $query = bbp_has_topics( array( 'post__in' => $subscriptions ) );
    578578    } else {
     
    605605    // If user has subscriptions, load them
    606606    $subscriptions = bbp_get_user_subscribed_forum_ids( $user_id );
    607     if ( !empty( $subscriptions ) ) {
     607    if ( ! empty( $subscriptions ) ) {
    608608        $query = bbp_has_forums( array( 'post__in' => $subscriptions ) );
    609609    } else {
     
    796796    // Validate user
    797797    $user_id = bbp_get_user_id( $user_id, true, true );
    798     if ( !empty( $user_id ) ) {
     798    if ( ! empty( $user_id ) ) {
    799799
    800800        // Get subscription ID's if none passed
     
    816816
    817817            // Use the current post id
    818             } elseif ( !bbp_get_topic_id() ) {
     818            } elseif ( ! bbp_get_topic_id() ) {
    819819                $topic_id = get_the_ID();
    820820            }
     
    900900
    901901    $subscriptions = (array) bbp_get_user_subscribed_forum_ids( $user_id );
    902     if ( !in_array( $forum_id, $subscriptions ) ) {
     902    if ( ! in_array( $forum_id, $subscriptions ) ) {
    903903        $subscriptions[] = $forum_id;
    904904        $subscriptions   = implode( ',', wp_parse_id_list( array_filter( $subscriptions ) ) );
     
    937937
    938938    $subscriptions = (array) bbp_get_user_subscribed_topic_ids( $user_id );
    939     if ( !in_array( $topic_id, $subscriptions ) ) {
     939    if ( ! in_array( $topic_id, $subscriptions ) ) {
    940940        $subscriptions[] = $topic_id;
    941941        $subscriptions   = implode( ',', wp_parse_id_list( array_filter( $subscriptions ) ) );
     
    10291029    $subscriptions = array_filter( $subscriptions );
    10301030
    1031     if ( !empty( $subscriptions ) ) {
     1031    if ( ! empty( $subscriptions ) ) {
    10321032        $subscriptions = implode( ',', wp_parse_id_list( $subscriptions ) );
    10331033        update_user_option( $user_id, '_bbp_forum_subscriptions', $subscriptions );
     
    10761076    $subscriptions = array_filter( $subscriptions );
    10771077
    1078     if ( !empty( $subscriptions ) ) {
     1078    if ( ! empty( $subscriptions ) ) {
    10791079        $subscriptions = implode( ',', wp_parse_id_list( $subscriptions ) );
    10801080        update_user_option( $user_id, '_bbp_subscriptions', $subscriptions );
     
    11461146
    11471147    // Check current user's ability to edit the user
    1148     } elseif ( !current_user_can( 'edit_user', $user_id ) ) {
     1148    } elseif ( ! current_user_can( 'edit_user', $user_id ) ) {
    11491149        bbp_add_error( 'bbp_subscription_permissions', __( '<strong>ERROR</strong>: You don\'t have the permission to edit favorites of that user!', 'bbpress' ) );
    11501150    }
     
    12191219function bbp_subscriptions_handler( $action = '' ) {
    12201220
    1221     if ( !bbp_is_subscriptions_active() ) {
     1221    if ( ! bbp_is_subscriptions_active() ) {
    12221222        return false;
    12231223    }
     
    12351235
    12361236    // Bail if actions aren't meant for this function
    1237     if ( !in_array( $action, $possible_actions ) ) {
     1237    if ( ! in_array( $action, $possible_actions ) ) {
    12381238        return;
    12391239    }
     
    12521252
    12531253    // Check current user's ability to edit the user
    1254     } elseif ( !current_user_can( 'edit_user', $user_id ) ) {
     1254    } elseif ( ! current_user_can( 'edit_user', $user_id ) ) {
    12551255        bbp_add_error( 'bbp_subscription_permissions', __( '<strong>ERROR</strong>: You don\'t have the permission to edit favorites of that user!', 'bbpress' ) );
    12561256    }
     
    13691369
    13701370    // Delete new email address from user options
    1371     } elseif ( is_multisite() && bbp_is_user_home_edit() && !empty( $_GET['dismiss'] ) && ( $user_id . '_new_email' === $_GET['dismiss'] ) ) {
     1371    } elseif ( is_multisite() && bbp_is_user_home_edit() && ! empty( $_GET['dismiss'] ) && ( $user_id . '_new_email' === $_GET['dismiss'] ) ) {
    13721372        delete_option( $user_id . '_new_email' );
    13731373        wp_safe_redirect( add_query_arg( array( 'updated' => 'true' ), bbp_get_user_profile_edit_url( $user_id ) ) );
     
    13921392
    13931393    // Prevent edit_user() from wiping out the user's Toolbar on front setting
    1394     if ( !isset( $_POST['admin_bar_front'] ) && _get_admin_bar_pref( 'front', $user_id ) ) {
     1394    if ( ! isset( $_POST['admin_bar_front'] ) && _get_admin_bar_pref( 'front', $user_id ) ) {
    13951395        $_POST['admin_bar_front'] = 1;
    13961396    }
     
    18341834
    18351835    // Bail if no username
    1836     $username = !empty( $_POST['log'] ) ? $_POST['log'] : '';
     1836    $username = ! empty( $_POST['log'] ) ? $_POST['log'] : '';
    18371837    if ( empty( $username ) ) {
    18381838        return;
  • trunk/src/includes/users/options.php

    r5309 r5442  
    116116
    117117    // Check the options global for preset value
    118     if ( isset( $user->ID ) && isset( $bbp->user_options[$user->ID] ) && !empty( $bbp->user_options[$user->ID][$option] ) ) {
     118    if ( isset( $user->ID ) && isset( $bbp->user_options[$user->ID] ) && ! empty( $bbp->user_options[$user->ID][$option] ) ) {
    119119        $value = $bbp->user_options[$user->ID][$option];
    120120    }
  • trunk/src/includes/users/template.php

    r5436 r5442  
    4242
    4343        // Easy empty checking
    44         if ( !empty( $user_id ) && is_numeric( $user_id ) ) {
     44        if ( ! empty( $user_id ) && is_numeric( $user_id ) ) {
    4545            $bbp_user_id = $user_id;
    4646
    4747        // Currently viewing or editing a user
    48         } elseif ( ( true === $displayed_user_fallback ) && !empty( $bbp->displayed_user->ID ) ) {
     48        } elseif ( ( true === $displayed_user_fallback ) && ! empty( $bbp->displayed_user->ID ) ) {
    4949            $bbp_user_id = $bbp->displayed_user->ID;
    5050
    5151        // Maybe fallback on the current_user ID
    52         } elseif ( ( true === $current_user_fallback ) && !empty( $bbp->current_user->ID ) ) {
     52        } elseif ( ( true === $current_user_fallback ) && ! empty( $bbp->current_user->ID ) ) {
    5353            $bbp_user_id = $bbp->current_user->ID;
    5454
     
    310310
    311311        // Maybe wrap the nicename
    312         $retval = !empty( $nicename ) ? ( $r['before'] . $nicename . $r['after'] ) : '';
     312        $retval = ! empty( $nicename ) ? ( $r['before'] . $nicename . $r['after'] ) : '';
    313313
    314314        // Filter and return
     
    460460            if ( empty( $user_nicename ) ) {
    461461                $user = get_userdata( $user_id );
    462                 if ( !empty( $user->user_nicename ) ) {
     462                if ( ! empty( $user->user_nicename ) ) {
    463463                    $user_nicename = $user->user_nicename;
    464464                }
     
    554554     */
    555555    function bbp_get_admin_link( $args = '' ) {
    556         if ( !current_user_can( 'moderate' ) ) {
     556        if ( ! current_user_can( 'moderate' ) ) {
    557557            return;
    558558        }
    559559
    560         if ( !empty( $args ) && is_string( $args ) && ( false === strpos( $args, '=' ) ) ) {
     560        if ( ! empty( $args ) && is_string( $args ) && ( false === strpos( $args, '=' ) ) ) {
    561561            $args = array( 'text' => $args );
    562562        }
     
    610610        // Get the author IP meta value
    611611        $author_ip = get_post_meta( $r['post_id'], '_bbp_author_ip', true );
    612         if ( !empty( $author_ip ) ) {
     612        if ( ! empty( $author_ip ) ) {
    613613            $author_ip = $r['before'] . $author_ip . $r['after'];
    614614
     
    11191119
    11201120            // Initial output is wrapped in a span, ajax output is hooked to this
    1121             if ( !empty( $wrap ) ) {
     1121            if ( ! empty( $wrap ) ) {
    11221122                $html = '<span id="subscription-toggle">' . $html . '</span>';
    11231123            }
     
    11501150
    11511151            // Initial output is wrapped in a span, ajax output is hooked to this
    1152             if ( !empty( $wrap ) ) {
     1152            if ( ! empty( $wrap ) ) {
    11531153                $html = '<span id="subscription-toggle">' . $html . '</span>';
    11541154            }
     
    12151215    $public_display['display_username'] = $bbp->displayed_user->user_login;
    12161216
    1217     if ( !empty( $bbp->displayed_user->nickname ) ) {
     1217    if ( ! empty( $bbp->displayed_user->nickname ) ) {
    12181218        $public_display['display_nickname']  = $bbp->displayed_user->nickname;
    12191219    }
    12201220
    1221     if ( !empty( $bbp->displayed_user->first_name ) ) {
     1221    if ( ! empty( $bbp->displayed_user->first_name ) ) {
    12221222        $public_display['display_firstname'] = $bbp->displayed_user->first_name;
    12231223    }
    12241224
    1225     if ( !empty( $bbp->displayed_user->last_name ) ) {
     1225    if ( ! empty( $bbp->displayed_user->last_name ) ) {
    12261226        $public_display['display_lastname']  = $bbp->displayed_user->last_name;
    12271227    }
    12281228
    1229     if ( !empty( $bbp->displayed_user->first_name ) && !empty( $bbp->displayed_user->last_name ) ) {
     1229    if ( ! empty( $bbp->displayed_user->first_name ) && ! empty( $bbp->displayed_user->last_name ) ) {
    12301230        $public_display['display_firstlast'] = $bbp->displayed_user->first_name . ' ' . $bbp->displayed_user->last_name;
    12311231        $public_display['display_lastfirst'] = $bbp->displayed_user->last_name  . ' ' . $bbp->displayed_user->first_name;
     
    12331233
    12341234    // Only add this if it isn't duplicated elsewhere
    1235     if ( !in_array( $bbp->displayed_user->display_name, $public_display ) ) {
     1235    if ( ! in_array( $bbp->displayed_user->display_name, $public_display ) ) {
    12361236        $public_display = array( 'display_displayname' => $bbp->displayed_user->display_name ) + $public_display;
    12371237    }
     
    14751475
    14761476    // loggedout was passed
    1477     if ( !empty( $_GET['loggedout'] ) && ( true === $_GET['loggedout'] ) ) {
     1477    if ( ! empty( $_GET['loggedout'] ) && ( true === $_GET['loggedout'] ) ) {
    14781478        bbp_add_error( 'loggedout', __( 'You are now logged out.', 'bbpress' ), 'message' );
    14791479
    14801480    // registration is disabled
    1481     } elseif ( !empty( $_GET['registration'] ) && ( 'disabled' === $_GET['registration'] ) ) {
     1481    } elseif ( ! empty( $_GET['registration'] ) && ( 'disabled' === $_GET['registration'] ) ) {
    14821482        bbp_add_error( 'registerdisabled', __( 'New user registration is currently not allowed.', 'bbpress' ) );
    14831483
    14841484    // Prompt user to check their email
    1485     } elseif ( !empty( $_GET['checkemail'] ) && in_array( $_GET['checkemail'], array( 'confirm', 'newpass', 'registered' ) ) ) {
     1485    } elseif ( ! empty( $_GET['checkemail'] ) && in_array( $_GET['checkemail'], array( 'confirm', 'newpass', 'registered' ) ) ) {
    14861486
    14871487        switch ( $_GET['checkemail'] ) {
     
    15221522
    15231523    // Bail if user is not logged in
    1524     if ( !is_user_logged_in() ) {
     1524    if ( ! is_user_logged_in() ) {
    15251525        return;
    15261526    }
    15271527
    15281528    // Setup the profile page to redirect to
    1529     $redirect_to = !empty( $url ) ? $url : bbp_get_user_profile_url( bbp_get_current_user_id() );
     1529    $redirect_to = ! empty( $url ) ? $url : bbp_get_user_profile_url( bbp_get_current_user_id() );
    15301530
    15311531    // Do a safe redirect and exit
     
    16711671
    16721672        // Neither a reply nor a topic, so could be a revision
    1673         if ( !empty( $r['post_id'] ) ) {
     1673        if ( ! empty( $r['post_id'] ) ) {
    16741674
    16751675            // Generate title with the display name of the author
    16761676            if ( empty( $r['link_title'] ) ) {
    1677                 $r['link_title'] = sprintf( !bbp_is_reply_anonymous( $r['post_id'] ) ? __( 'View %s\'s profile', 'bbpress' ) : __( 'Visit %s\'s website', 'bbpress' ), get_the_author_meta( 'display_name', $user_id ) );
     1677                $r['link_title'] = sprintf( ! bbp_is_reply_anonymous( $r['post_id'] ) ? __( 'View %s\'s profile', 'bbpress' ) : __( 'Visit %s\'s website', 'bbpress' ), get_the_author_meta( 'display_name', $user_id ) );
    16781678            }
    16791679
    16801680            // Assemble some link bits
    1681             $link_title = !empty( $r['link_title'] ) ? ' title="' . $r['link_title'] . '"' : '';
     1681            $link_title = ! empty( $r['link_title'] ) ? ' title="' . $r['link_title'] . '"' : '';
    16821682            $anonymous  = bbp_is_reply_anonymous( $r['post_id'] );
    16831683
     
    17501750
    17511751    // User is a keymaster
    1752     if ( !empty( $user_id ) && bbp_is_user_keymaster( $user_id ) ) {
     1752    if ( ! empty( $user_id ) && bbp_is_user_keymaster( $user_id ) ) {
    17531753        $retval = true;
    17541754
     
    17931793
    17941794    // Do not allow anonymous if not enabled
    1795     } elseif ( !is_user_logged_in() && bbp_allow_anonymous() ) {
     1795    } elseif ( ! is_user_logged_in() && bbp_allow_anonymous() ) {
    17961796        $retval = true;
    17971797
     
    18591859
    18601860    // Do not allow anonymous if not enabled
    1861     } elseif ( !is_user_logged_in() && bbp_allow_anonymous() ) {
     1861    } elseif ( ! is_user_logged_in() && bbp_allow_anonymous() ) {
    18621862        $retval = true;
    18631863
     
    18961896
    18971897    // Private forums
    1898     if ( !current_user_can( 'read_private_forums' ) ) {
     1898    if ( ! current_user_can( 'read_private_forums' ) ) {
    18991899        $private = bbp_get_private_forum_ids();
    19001900    }
    19011901
    19021902    // Hidden forums
    1903     if ( !current_user_can( 'read_hidden_forums' ) ) {
     1903    if ( ! current_user_can( 'read_hidden_forums' ) ) {
    19041904        $hidden  = bbp_get_hidden_forum_ids();
    19051905    }
     
    19091909
    19101910    // There are forums that need to be ex
    1911     if ( !empty( $forum_ids ) ) {
     1911    if ( ! empty( $forum_ids ) ) {
    19121912        $post__not_in = implode( ',', $forum_ids );
    19131913    }
Note: See TracChangeset for help on using the changeset viewer.