Skip to:
Content

bbPress.org

Changeset 4896


Ignore:
Timestamp:
05/11/2013 06:10:20 AM (13 years ago)
Author:
johnjamesjacoby
Message:

Use implode() instead of join() through-out project. See #2331.

Location:
trunk/includes
Files:
10 edited

Legend:

Unmodified
Added
Removed
  • trunk/includes/admin/tools.php

    r4791 r4896  
    131131
    132132                        default:
    133                                 $message = '<ul>' . "\n\t" . '<li>' . join( '</li>' . "\n\t" . '<li>', $errors ) . '</li>' . "\n" . '</ul>';
     133                                $message = '<ul>' . "\n\t" . '<li>' . implode( '</li>' . "\n\t" . '<li>', $errors ) . '</li>' . "\n" . '</ul>';
    134134                                break;
    135135                }
     
    286286                return array( 1, sprintf( $statement, $result ) );
    287287
    288         $sql = "INSERT INTO `{$wpdb->postmeta}` (`post_id`, `meta_key`, `meta_value`) (SELECT `post_parent`, '_bbp_reply_count_hidden', COUNT(`post_status`) as `meta_value` FROM `{$wpdb->posts}` WHERE `post_type` = '" . bbp_get_reply_post_type() . "' AND `post_status` IN ( '" . join( "','", array( bbp_get_trash_status_id(), bbp_get_spam_status_id() ) ) . "') GROUP BY `post_parent`);";
     288        $sql = "INSERT INTO `{$wpdb->postmeta}` (`post_id`, `meta_key`, `meta_value`) (SELECT `post_parent`, '_bbp_reply_count_hidden', COUNT(`post_status`) as `meta_value` FROM `{$wpdb->posts}` WHERE `post_type` = '" . bbp_get_reply_post_type() . "' AND `post_status` IN ( '" . implode( "','", array( bbp_get_trash_status_id(), bbp_get_spam_status_id() ) ) . "') GROUP BY `post_parent`);";
    289289        if ( is_wp_error( $wpdb->query( $sql ) ) )
    290290                return array( 2, sprintf( $statement, $result ) );
     
    528528
    529529        foreach ( array_chunk( $insert_values, 10000 ) as $chunk ) {
    530                 $chunk = "\n" . join( ",\n", $chunk );
     530                $chunk = "\n" . implode( ",\n", $chunk );
    531531                $sql_insert = "INSERT INTO `{$wpdb->usermeta}` (`user_id`, `meta_key`, `meta_value`) VALUES $chunk;";
    532532
     
    573573
    574574        foreach ( array_chunk( $insert_values, 10000 ) as $chunk ) {
    575                 $chunk = "\n" . join( ",\n", $chunk );
     575                $chunk = "\n" . implode( ",\n", $chunk );
    576576                $sql_insert = "INSERT INTO `{$wpdb->usermeta}` (`user_id`, `meta_key`, `meta_value`) VALUES $chunk;";
    577577
     
    619619                        continue;
    620620
    621                 $favorites_joined = join( ',', $favorites );
     621                $favorites_joined = implode( ',', $favorites );
    622622                $values[]         = "('{$user->user_id}', '{$key}, '{$favorites_joined}')";
    623623
     
    636636
    637637        foreach ( array_chunk( $values, 10000 ) as $chunk ) {
    638                 $chunk = "\n" . join( ",\n", $chunk );
     638                $chunk = "\n" . implode( ",\n", $chunk );
    639639                $sql_insert = "INSERT INTO `$wpdb->usermeta` (`user_id`, `meta_key`, `meta_value`) VALUES $chunk;";
    640640                if ( is_wp_error( $wpdb->query( $sql_insert ) ) ) {
     
    680680                        continue;
    681681
    682                 $subscriptions_joined = join( ',', $subscriptions );
     682                $subscriptions_joined = implode( ',', $subscriptions );
    683683                $values[]             = "('{$user->user_id}', '{$key}', '{$subscriptions_joined}')";
    684684
     
    697697
    698698        foreach ( array_chunk( $values, 10000 ) as $chunk ) {
    699                 $chunk = "\n" . join( ",\n", $chunk );
     699                $chunk = "\n" . implode( ",\n", $chunk );
    700700                $sql_insert = "INSERT INTO `{$wpdb->usermeta}` (`user_id`, `meta_key`, `meta_value`) VALUES $chunk;";
    701701                if ( is_wp_error( $wpdb->query( $sql_insert ) ) ) {
  • trunk/includes/common/formatting.php

    r4866 r4896  
    171171
    172172        // Return the joined content array
    173         return join( '', $content );
     173        return implode( '', $content );
    174174}
    175175
  • trunk/includes/common/functions.php

    r4848 r4896  
    12531253
    12541254        // Join post statuses together
    1255         $post_status = "'" . join( "', '", $post_status ) . "'";
     1255        $post_status = "'" . implode( "', '", $post_status ) . "'";
    12561256
    12571257        // Check for cache and set if needed
     
    12961296
    12971297        // Join post statuses together
    1298         $post_status = "'" . join( "', '", $post_status ) . "'";
     1298        $post_status = "'" . implode( "', '", $post_status ) . "'";
    12991299
    13001300        // Check for cache and set if needed
     
    13391339
    13401340        // Join post statuses together
    1341         $post_status = "'" . join( "', '", $post_status ) . "'";
     1341        $post_status = "'" . implode( "', '", $post_status ) . "'";
    13421342
    13431343        // Check for cache and set if needed
     
    14001400
    14011401        // Join post statuses together
    1402         $post_status = "'" . join( "', '", $post_status ) . "'";
     1402        $post_status = "'" . implode( "', '", $post_status ) . "'";
    14031403
    14041404        // Check for cache and set if needed
  • trunk/includes/forums/functions.php

    r4876 r4896  
    13631363                // Get topics of forum
    13641364                if ( empty( $topic_count ) )
    1365                         $topic_count = $wpdb->get_var( $wpdb->prepare( "SELECT COUNT(ID) FROM {$wpdb->posts} WHERE post_parent = %d AND post_status IN ( '" . join( '\',\'', array( bbp_get_trash_status_id(), bbp_get_spam_status_id() ) ) . "') AND post_type = '%s';", $forum_id, bbp_get_topic_post_type() ) );
     1365                        $topic_count = $wpdb->get_var( $wpdb->prepare( "SELECT COUNT(ID) FROM {$wpdb->posts} WHERE post_parent = %d AND post_status IN ( '" . implode( '\',\'', array( bbp_get_trash_status_id(), bbp_get_spam_status_id() ) ) . "') AND post_type = '%s';", $forum_id, bbp_get_topic_post_type() ) );
    13661366
    13671367                // Update the count
     
    14101410        $topic_ids = bbp_forum_query_topic_ids( $forum_id );
    14111411        if ( !empty( $topic_ids ) ) {
    1412                 $reply_count = (int) $wpdb->get_var( $wpdb->prepare( "SELECT COUNT(ID) FROM {$wpdb->posts} WHERE post_parent IN ( " . join( ',', $topic_ids ) . " ) AND post_status = '%s' AND post_type = '%s';", bbp_get_public_status_id(), bbp_get_reply_post_type() ) );
     1412                $reply_count = (int) $wpdb->get_var( $wpdb->prepare( "SELECT COUNT(ID) FROM {$wpdb->posts} WHERE post_parent IN ( " . implode( ',', $topic_ids ) . " ) AND post_status = '%s' AND post_type = '%s';", bbp_get_public_status_id(), bbp_get_reply_post_type() ) );
    14131413        } else {
    14141414                $reply_count = 0;
     
    18061806
    18071807                if ( !empty( $topic_ids ) ) {
    1808                         $reply_id = (int) $wpdb->get_var( $wpdb->prepare( "SELECT ID FROM {$wpdb->posts} WHERE post_parent IN ( " . join( ',', $topic_ids ) . " ) AND post_status = '%s' AND post_type = '%s' ORDER BY ID DESC LIMIT 1;", bbp_get_public_status_id(), bbp_get_reply_post_type() ) );
     1808                        $reply_id = (int) $wpdb->get_var( $wpdb->prepare( "SELECT ID FROM {$wpdb->posts} WHERE post_parent IN ( " . implode( ',', $topic_ids ) . " ) AND post_status = '%s' AND post_type = '%s' ORDER BY ID DESC LIMIT 1;", bbp_get_public_status_id(), bbp_get_reply_post_type() ) );
    18091809                        wp_cache_set( $cache_id, $reply_id, 'bbpress_posts' ); // May be (int) 0
    18101810                } else {
     
    20222022
    20232023        // Allowed post statuses to pre-trash
    2024         $post_stati = join( ',', array(
     2024        $post_stati = implode( ',', array(
    20252025                bbp_get_public_status_id(),
    20262026                bbp_get_closed_status_id(),
  • trunk/includes/forums/template-tags.php

    r4877 r4896  
    17781778                // Filter the results
    17791779                $classes   = apply_filters( 'bbp_get_forum_class', $classes, $forum_id );
    1780                 $retval    = 'class="' . join( ' ', $classes ) . '"';
     1780                $retval    = 'class="' . implode( ' ', $classes ) . '"';
    17811781
    17821782                return $retval;
  • trunk/includes/replies/template-tags.php

    r4866 r4896  
    101101
    102102                // Join post statuses together
    103                 $default['post_status'] = join( ',', $post_statuses );
     103                $default['post_status'] = implode( ',', $post_statuses );
    104104
    105105        // Lean on the 'perm' query var value of 'readable' to provide statuses
     
    11121112                                }
    11131113
    1114                                 $author_link = join( $r['sep'], $author_link );
     1114                                $author_link = implode( $r['sep'], $author_link );
    11151115
    11161116                        // No links if anonymous
    11171117                        } else {
    1118                                 $author_link = join( $r['sep'], $author_links );
     1118                                $author_link = implode( $r['sep'], $author_links );
    11191119                        }
    11201120
     
    19721972                $classes   = get_post_class( $classes, $reply_id );
    19731973                $classes   = apply_filters( 'bbp_get_reply_class', $classes, $reply_id );
    1974                 $retval    = 'class="' . join( ' ', $classes ) . '"';
     1974                $retval    = 'class="' . implode( ' ', $classes ) . '"';
    19751975
    19761976                return $retval;
  • trunk/includes/search/template-tags.php

    r4733 r4896  
    5252
    5353        $default_post_type   = array( bbp_get_forum_post_type(), bbp_get_topic_post_type(), bbp_get_reply_post_type() );
    54         $default_post_status = join( ',', $post_statuses );
     54        $default_post_status = implode( ',', $post_statuses );
    5555
    5656        // Default query args
  • trunk/includes/topics/functions.php

    r4876 r4896  
    23412341        // Get replies of topic
    23422342        if ( empty( $reply_count ) ) {
    2343                 $reply_count = $wpdb->get_var( $wpdb->prepare( "SELECT COUNT(ID) FROM {$wpdb->posts} WHERE post_parent = %d AND post_status IN ( '" . join( '\',\'', array( bbp_get_trash_status_id(), bbp_get_spam_status_id() ) ) . "') AND post_type = '%s';", $topic_id, bbp_get_reply_post_type() ) );
     2343                $reply_count = $wpdb->get_var( $wpdb->prepare( "SELECT COUNT(ID) FROM {$wpdb->posts} WHERE post_parent = %d AND post_status IN ( '" . implode( '\',\'', array( bbp_get_trash_status_id(), bbp_get_spam_status_id() ) ) . "') AND post_type = '%s';", $topic_id, bbp_get_reply_post_type() ) );
    23442344        }
    23452345
  • trunk/includes/topics/template-tags.php

    r4866 r4896  
    123123
    124124                // Join post statuses together
    125                 $default['post_status'] = join( ',', $post_statuses );
     125                $default['post_status'] = implode( ',', $post_statuses );
    126126
    127127        // Lean on the 'perm' query var value of 'readable' to provide statuses
     
    14391439                                }
    14401440
    1441                                 $author_link = join( $r['sep'], $author_link );
     1441                                $author_link = implode( $r['sep'], $author_link );
    14421442
    14431443                        // No links if anonymous
    14441444                        } else {
    1445                                 $author_link = join( $r['sep'], $author_links );
     1445                                $author_link = implode( $r['sep'], $author_links );
    14461446                        }
    14471447
     
    21982198                $classes   = get_post_class( $classes, $topic_id );
    21992199                $classes   = apply_filters( 'bbp_get_topic_class', $classes, $topic_id );
    2200                 $retval    = 'class="' . join( ' ', $classes ) . '"';
     2200                $retval    = 'class="' . implode( ' ', $classes ) . '"';
    22012201
    22022202                return $retval;
  • trunk/includes/users/template-tags.php

    r4840 r4896  
    14401440                                        $author_link[] = sprintf( '<a href="%1$s"%2$s>%3$s</a>', $author_url, $link_title, $link_text );
    14411441                                }
    1442                                 $author_link = join( '&nbsp;', $author_link );
     1442                                $author_link = implode( '&nbsp;', $author_link );
    14431443
    14441444                        // No links if anonymous
    14451445                        } else {
    1446                                 $author_link = join( '&nbsp;', $author_links );
     1446                                $author_link = implode( '&nbsp;', $author_links );
    14471447                        }
    14481448
Note: See TracChangeset for help on using the changeset viewer.