Skip to:
Content

bbPress.org


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

Breathing room for ! usages in Topics component.

File:
1 edited

Legend:

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

    r5434 r5443  
    145145
    146146    // Other defaults
    147     $default_topic_search  = !empty( $_REQUEST['ts'] ) ? $_REQUEST['ts'] : false;
     147    $default_topic_search  = ! empty( $_REQUEST['ts'] ) ? $_REQUEST['ts'] : false;
    148148    $default_show_stickies = (bool) ( bbp_is_single_forum() || bbp_is_topic_archive() ) && ( false === $default_topic_search );
    149149    $default_post_parent   = bbp_is_single_forum() ? bbp_get_forum_id() : 'any';
     
    211211
    212212    // Limited the number of pages shown
    213     if ( !empty( $r['max_num_pages'] ) ) {
     213    if ( ! empty( $r['max_num_pages'] ) ) {
    214214        $bbp->topic_query->max_num_pages = $r['max_num_pages'];
    215215    }
     
    218218
    219219    // Put sticky posts at the top of the posts array
    220     if ( !empty( $r['show_stickies'] ) && $r['paged'] <= 1 ) {
     220    if ( ! empty( $r['show_stickies'] ) && $r['paged'] <= 1 ) {
    221221
    222222        // Get super stickies and stickies in this forum
     
    224224
    225225        // Get stickies for current forum
    226         if ( !empty( $r['post_parent'] ) ) {
     226        if ( ! empty( $r['post_parent'] ) ) {
    227227            $stickies = array_merge( $stickies, bbp_get_stickies( $r['post_parent'] ) );
    228228        }
     
    232232
    233233        // We have stickies
    234         if ( is_array( $stickies ) && !empty( $stickies ) ) {
     234        if ( is_array( $stickies ) && ! empty( $stickies ) ) {
    235235
    236236            // Start the offset at -1 so first sticky is at correct 0 offset
     
    273273
    274274            // If any posts have been excluded specifically, Ignore those that are sticky.
    275             if ( !empty( $stickies ) && !empty( $r['post__not_in'] ) ) {
     275            if ( ! empty( $stickies ) && ! empty( $r['post__not_in'] ) ) {
    276276                $stickies = array_diff( $stickies, $r['post__not_in'] );
    277277            }
    278278
    279279            // Fetch sticky posts that weren't in the query results
    280             if ( !empty( $stickies ) ) {
     280            if ( ! empty( $stickies ) ) {
    281281
    282282                // Query to use in get_posts to get sticky posts
     
    311311                // Get all stickies
    312312                $sticky_posts = get_posts( $sticky_query );
    313                 if ( !empty( $sticky_posts ) ) {
     313                if ( ! empty( $sticky_posts ) ) {
    314314
    315315                    // Get a count of the visible stickies
     
    343343
    344344        // Limit the number of topics shown based on maximum allowed pages
    345         if ( ( !empty( $r['max_num_pages'] ) ) && $bbp->topic_query->found_posts > $bbp->topic_query->max_num_pages * $bbp->topic_query->post_count ) {
     345        if ( ( ! empty( $r['max_num_pages'] ) ) && $bbp->topic_query->found_posts > $bbp->topic_query->max_num_pages * $bbp->topic_query->post_count ) {
    346346            $bbp->topic_query->found_posts = $bbp->topic_query->max_num_pages * $bbp->topic_query->post_count;
    347347        }
     
    490490
    491491        // Easy empty checking
    492         if ( !empty( $topic_id ) && is_numeric( $topic_id ) ) {
     492        if ( ! empty( $topic_id ) && is_numeric( $topic_id ) ) {
    493493            $bbp_topic_id = $topic_id;
    494494
    495495        // Currently inside a topic loop
    496         } elseif ( !empty( $bbp->topic_query->in_the_loop ) && isset( $bbp->topic_query->post->ID ) ) {
     496        } elseif ( ! empty( $bbp->topic_query->in_the_loop ) && isset( $bbp->topic_query->post->ID ) ) {
    497497            $bbp_topic_id = $bbp->topic_query->post->ID;
    498498
    499499        // Currently inside a search loop
    500         } elseif ( !empty( $bbp->search_query->in_the_loop ) && isset( $bbp->search_query->post->ID ) && bbp_is_topic( $bbp->search_query->post->ID ) ) {
     500        } elseif ( ! empty( $bbp->search_query->in_the_loop ) && isset( $bbp->search_query->post->ID ) && bbp_is_topic( $bbp->search_query->post->ID ) ) {
    501501            $bbp_topic_id = $bbp->search_query->post->ID;
    502502
    503503        // Currently viewing/editing a topic, likely alone
    504         } elseif ( ( bbp_is_single_topic() || bbp_is_topic_edit() ) && !empty( $bbp->current_topic_id ) ) {
     504        } elseif ( ( bbp_is_single_topic() || bbp_is_topic_edit() ) && ! empty( $bbp->current_topic_id ) ) {
    505505            $bbp_topic_id = $bbp->current_topic_id;
    506506
     
    600600
    601601        // Use the redirect address
    602         if ( !empty( $redirect_to ) ) {
     602        if ( ! empty( $redirect_to ) ) {
    603603            $topic_permalink = esc_url_raw( $redirect_to );
    604604
     
    674674            // Set root text to page title
    675675            $page = bbp_get_page_by_path( bbp_get_topic_archive_slug() );
    676             if ( !empty( $page ) ) {
     676            if ( ! empty( $page ) ) {
    677677                $title = get_the_title( $page->ID );
    678678
     
    770770        }
    771771
    772         if ( !empty( $length ) && ( $excerpt_length > $length ) ) {
     772        if ( ! empty( $length ) && ( $excerpt_length > $length ) ) {
    773773            $excerpt  = substr( $excerpt, 0, $length - 1 );
    774774            $excerpt .= '&hellip;';
     
    808808
    809809        // 4 days, 4 hours ago
    810         if ( !empty( $humanize ) ) {
    811             $gmt_s  = !empty( $gmt ) ? 'U' : 'G';
     810        if ( ! empty( $humanize ) ) {
     811            $gmt_s  = ! empty( $gmt ) ? 'U' : 'G';
    812812            $date   = get_post_time( $gmt_s, $gmt, $topic_id );
    813813            $time   = false; // For filter below
     
    885885
    886886        // Bump if topic is in loop
    887         if ( !bbp_show_lead_topic() ) {
     887        if ( ! bbp_show_lead_topic() ) {
    888888            $total++;
    889889        }
     
    903903        // Add pagination to query object
    904904        $pagination_links = paginate_links( $pagination );
    905         if ( !empty( $pagination_links ) ) {
     905        if ( ! empty( $pagination_links ) ) {
    906906
    907907            // Remove first page from pagination
     
    977977        $revision_log = bbp_get_topic_raw_revision_log( $topic_id );
    978978
    979         if ( empty( $topic_id ) || empty( $revision_log ) || !is_array( $revision_log ) ) {
     979        if ( empty( $topic_id ) || empty( $revision_log ) || ! is_array( $revision_log ) ) {
    980980            return false;
    981981        }
     
    10031003
    10041004            $r .= "\t" . '<li id="bbp-topic-revision-log-' . esc_attr( $topic_id ) . '-item-' . esc_attr( $revision->ID ) . '" class="bbp-topic-revision-log-item">' . "\n";
    1005             if ( !empty( $reason ) ) {
     1005            if ( ! empty( $reason ) ) {
    10061006                $r .= "\t\t" . sprintf( __( 'This topic was modified %1$s by %2$s. Reason: %3$s', 'bbpress' ), esc_html( $since ), $author, esc_html( $reason ) ) . "\n";
    10071007            } else {
     
    11151115 */
    11161116function bbp_is_topic_open( $topic_id = 0 ) {
    1117     return !bbp_is_topic_closed( $topic_id );
     1117    return ! bbp_is_topic_closed( $topic_id );
    11181118}
    11191119
     
    11541154    $stickies = bbp_get_stickies( $forum_id );
    11551155
    1156     if ( in_array( $topic_id, $stickies ) || ( !empty( $check_super ) && bbp_is_topic_super_sticky( $topic_id ) ) ) {
     1156    if ( in_array( $topic_id, $stickies ) || ( ! empty( $check_super ) && bbp_is_topic_super_sticky( $topic_id ) ) ) {
    11571157        return true;
    11581158    }
     
    12421242    $retval   = false;
    12431243
    1244     if ( !bbp_get_topic_author_id( $topic_id ) ) {
     1244    if ( ! bbp_get_topic_author_id( $topic_id ) ) {
    12451245        $retval = true;
    12461246
     
    12921292        $topic_id = bbp_get_topic_id( $topic_id );
    12931293
    1294         if ( !bbp_is_topic_anonymous( $topic_id ) ) {
     1294        if ( ! bbp_is_topic_anonymous( $topic_id ) ) {
    12951295            $author = get_the_author_meta( 'display_name', bbp_get_topic_author_id( $topic_id ) );
    12961296        } else {
     
    13631363
    13641364        // Check for anonymous user
    1365         if ( !bbp_is_topic_anonymous( $topic_id ) ) {
     1365        if ( ! bbp_is_topic_anonymous( $topic_id ) ) {
    13661366
    13671367            // Get the author ID
     
    14271427
    14281428        $topic_id = bbp_get_topic_id( $topic_id );
    1429         if ( !empty( $topic_id ) ) {
    1430             if ( !bbp_is_topic_anonymous( $topic_id ) ) {
     1429        if ( ! empty( $topic_id ) ) {
     1430            if ( ! bbp_is_topic_anonymous( $topic_id ) ) {
    14311431                $author_avatar = get_avatar( bbp_get_topic_author_id( $topic_id ), $size );
    14321432            } else {
     
    14901490
    14911491        // Topic ID is good
    1492         if ( !empty( $topic_id ) ) {
     1492        if ( ! empty( $topic_id ) ) {
    14931493
    14941494            // Get some useful topic information
     
    15061506
    15071507            // Setup title and author_links array
    1508             $link_title   = !empty( $link_title ) ? ' title="' . esc_attr( $link_title ) . '"' : '';
     1508            $link_title   = ! empty( $link_title ) ? ' title="' . esc_attr( $link_title ) . '"' : '';
    15091509            $author_links = array();
    15101510
     
    15821582
    15831583        // Check for anonymous user or non-existant user
    1584         if ( !bbp_is_topic_anonymous( $topic_id ) && bbp_user_has_profile( bbp_get_topic_author_id( $topic_id ) ) ) {
     1584        if ( ! bbp_is_topic_anonymous( $topic_id ) && bbp_user_has_profile( bbp_get_topic_author_id( $topic_id ) ) ) {
    15851585            $author_url = bbp_get_user_profile_url( bbp_get_topic_author_id( $topic_id ) );
    15861586        } else {
     
    16271627
    16281628        // Not anonymous user
    1629         if ( !bbp_is_topic_anonymous( $topic_id ) ) {
     1629        if ( ! bbp_is_topic_anonymous( $topic_id ) ) {
    16301630
    16311631            // Use topic author email address
    16321632            $user_id      = bbp_get_topic_author_id( $topic_id );
    16331633            $user         = get_userdata( $user_id );
    1634             $author_email = !empty( $user->user_email ) ? $user->user_email : '';
     1634            $author_email = ! empty( $user->user_email ) ? $user->user_email : '';
    16351635
    16361636        // Anonymous
     
    18151815        if ( empty( $last_active ) ) {
    18161816            $reply_id = bbp_get_topic_last_reply_id( $topic_id );
    1817             if ( !empty( $reply_id ) ) {
     1817            if ( ! empty( $reply_id ) ) {
    18181818                $last_active = get_post_field( 'post_date', $reply_id );
    18191819            } else {
     
    18221822        }
    18231823
    1824         $last_active = !empty( $last_active ) ? bbp_get_time_since( bbp_convert_date( $last_active ) ) : '';
     1824        $last_active = ! empty( $last_active ) ? bbp_get_time_since( bbp_convert_date( $last_active ) ) : '';
    18251825
    18261826        // Return the time since
     
    20372037        $reply_id = bbp_get_topic_last_reply_id( $topic_id );
    20382038
    2039         if ( !empty( $reply_id ) && ( $reply_id !== $topic_id ) ) {
     2039        if ( ! empty( $reply_id ) && ( $reply_id !== $topic_id ) ) {
    20402040            $reply_url = bbp_get_reply_url( $reply_id );
    20412041        } else {
     
    20792079        $time_since = bbp_get_topic_last_active_time( $topic_id );
    20802080
    2081         if ( !empty( $time_since ) ) {
     2081        if ( ! empty( $time_since ) ) {
    20822082            $anchor = '<a href="' . esc_url( $link_url ) . '" title="' . esc_attr( $title ) . '">' . esc_html( $time_since ) . '</a>';
    20832083        } else {
     
    21372137
    21382138        // This forum has hidden topics
    2139         if ( !empty( $deleted ) && current_user_can( 'edit_others_replies' ) ) {
     2139        if ( ! empty( $deleted ) && current_user_can( 'edit_others_replies' ) ) {
    21402140
    21412141            // Extra text
     
    23322332
    23332333            // If terms exist, explode them and compile the return value
    2334             if ( !empty( $terms ) ) {
     2334            if ( ! empty( $terms ) ) {
    23352335                $terms  = implode( $r['sep'], $terms );
    23362336                $retval = $r['before'] . $terms . $r['after'];
     
    25202520
    25212521        // Bypass check if user has caps
    2522         if ( !current_user_can( 'edit_others_topics' ) ) {
     2522        if ( ! current_user_can( 'edit_others_topics' ) ) {
    25232523
    25242524            // User cannot edit or it is past the lock time
    2525             if ( empty( $topic ) || !current_user_can( 'edit_topic', $topic->ID ) || bbp_past_edit_lock( $topic->post_date_gmt ) ) {
     2525            if ( empty( $topic ) || ! current_user_can( 'edit_topic', $topic->ID ) || bbp_past_edit_lock( $topic->post_date_gmt ) ) {
    25262526                return;
    25272527            }
     
    26482648        $topic   = bbp_get_topic( bbp_get_topic_id( (int) $r['id'] ) );
    26492649
    2650         if ( empty( $topic ) || !current_user_can( 'delete_topic', $topic->ID ) ) {
     2650        if ( empty( $topic ) || ! current_user_can( 'delete_topic', $topic->ID ) ) {
    26512651            return;
    26522652        }
     
    26582658        }
    26592659
    2660         if ( bbp_is_topic_trash( $topic->ID ) || !EMPTY_TRASH_DAYS ) {
     2660        if ( bbp_is_topic_trash( $topic->ID ) || ! empty_TRASH_DAYS ) {
    26612661            $actions['delete']  = '<a title="' . esc_attr__( 'Delete this item permanently',     'bbpress' ) . '" href="' . esc_url( wp_nonce_url( add_query_arg( array( 'action' => 'bbp_toggle_topic_trash', 'sub_action' => 'delete',  'topic_id' => $topic->ID ) ), 'delete-'  . $topic->post_type . '_' . $topic->ID ) ) . '" onclick="return confirm(\'' . esc_js( __( 'Are you sure you want to delete that permanently?', 'bbpress' ) ) . '\' );" class="bbp-topic-delete-link">' . $r['delete_text'] . '</a>';
    26622662        }
     
    27162716        $topic = bbp_get_topic( bbp_get_topic_id( (int) $r['id'] ) );
    27172717
    2718         if ( empty( $topic ) || !current_user_can( 'moderate', $topic->ID ) ) {
     2718        if ( empty( $topic ) || ! current_user_can( 'moderate', $topic->ID ) ) {
    27192719            return;
    27202720        }
     
    27782778        $topic = bbp_get_topic( bbp_get_topic_id( (int) $r['id'] ) );
    27792779
    2780         if ( empty( $topic ) || !current_user_can( 'moderate', $topic->ID ) ) {
     2780        if ( empty( $topic ) || ! current_user_can( 'moderate', $topic->ID ) ) {
    27812781            return;
    27822782        }
     
    28482848        $topic = bbp_get_topic( bbp_get_topic_id( (int) $r['id'] ) );
    28492849
    2850         if ( empty( $topic ) || !current_user_can( 'moderate', $topic->ID ) ) {
     2850        if ( empty( $topic ) || ! current_user_can( 'moderate', $topic->ID ) ) {
    28512851            return;
    28522852        }
     
    29062906        $topic = bbp_get_topic( bbp_get_topic_id( (int) $r['id'] ) );
    29072907
    2908         if ( empty( $topic ) || !current_user_can( 'moderate', $topic->ID ) ) {
     2908        if ( empty( $topic ) || ! current_user_can( 'moderate', $topic->ID ) ) {
    29092909            return;
    29102910        }
     
    30033003        $from_num  = bbp_number_format( $start_num );
    30043004        $to_num    = bbp_number_format( ( $start_num + ( $bbp->topic_query->posts_per_page - 1 ) > $bbp->topic_query->found_posts ) ? $bbp->topic_query->found_posts : $start_num + ( $bbp->topic_query->posts_per_page - 1 ) );
    3005         $total_int = (int) !empty( $bbp->topic_query->found_posts ) ? $bbp->topic_query->found_posts : $bbp->topic_query->post_count;
     3005        $total_int = (int) ! empty( $bbp->topic_query->found_posts ) ? $bbp->topic_query->found_posts : $bbp->topic_query->post_count;
    30063006        $total     = bbp_number_format( $total_int );
    30073007
     
    30623062
    30633063    // Bail if not viewing a topic
    3064     if ( !bbp_is_single_topic() ) {
     3064    if ( ! bbp_is_single_topic() ) {
    30653065        return;
    30663066    }
     
    31823182
    31833183        // Used variables
    3184         $tab = !empty( $r['tab'] ) ? ' tabindex="' . (int) $r['tab'] . '"' : '';
     3184        $tab = ! empty( $r['tab'] ) ? ' tabindex="' . (int) $r['tab'] . '"' : '';
    31853185
    31863186        // Start an output buffer, we'll finish it after the select loop
     
    33483348        // Topic has replies
    33493349        $last_reply = bbp_get_topic_last_reply_id( $topic_id );
    3350         if ( !empty( $last_reply ) ) {
     3350        if ( ! empty( $last_reply ) ) {
    33513351            $last_updated_by = bbp_get_author_link( array( 'post_id' => $last_reply, 'size' => $r['size'] ) );
    33523352            $retstr          = sprintf( esc_html__( 'This topic contains %1$s, has %2$s, and was last updated by %3$s %4$s.', 'bbpress' ), $reply_count, $voice_count, $last_updated_by, $time_since );
     
    34653465
    34663466        // Add before and after if description exists
    3467         if ( !empty( $term->term_id ) ) {
     3467        if ( ! empty( $term->term_id ) ) {
    34683468            $retval = $term->term_id;
    34693469
     
    35093509
    35103510        // Add before and after if description exists
    3511         if ( !empty( $term->name ) ) {
     3511        if ( ! empty( $term->name ) ) {
    35123512            $retval = $term->name;
    35133513
     
    35533553
    35543554        // Add before and after if description exists
    3555         if ( !empty( $term->slug ) ) {
     3555        if ( ! empty( $term->slug ) ) {
    35563556            $retval = $term->slug;
    35573557
     
    35973597
    35983598        // Add before and after if description exists
    3599         if ( !empty( $term->term_id ) ) {
     3599        if ( ! empty( $term->term_id ) ) {
    36003600            $retval = get_term_link( $term, bbp_get_topic_tag_tax_id() );
    36013601
     
    36423642
    36433643        // Add before and after if description exists
    3644         if ( !empty( $term->term_id ) ) {
     3644        if ( ! empty( $term->term_id ) ) {
    36453645
    36463646            $bbp = bbpress();
     
    37053705
    37063706        // Add before and after if description exists
    3707         if ( !empty( $term->description ) ) {
     3707        if ( ! empty( $term->description ) ) {
    37083708            $retval = $r['before'] . $term->description . $r['after'];
    37093709
     
    38453845
    38463846            // Topic exists
    3847             if ( !empty( $topic_id ) ) {
     3847            if ( ! empty( $topic_id ) ) {
    38483848
    38493849                // Topic is spammed so display pre-spam terms
     
    38743874
    38753875            // Set the return value
    3876             $topic_tags = ( !empty( $new_terms ) ) ? implode( ', ', $new_terms ) : '';
     3876            $topic_tags = ( ! empty( $new_terms ) ) ? implode( ', ', $new_terms ) : '';
    38773877
    38783878        // No data
Note: See TracChangeset for help on using the changeset viewer.