Skip to:
Content

BuddyPress.org


Ignore:
Timestamp:
01/29/2020 08:36:15 PM (6 years ago)
Author:
imath
Message:

Blogs: fix PHP code standards & typos in inline comments

Props passoniate

Fixes #8222

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/bp-blogs/bp-blogs-functions.php

    r12311 r12544  
    4646    // Parse query arguments.
    4747    $r = bp_parse_args( $args, array(
    48         'type'              => 'active', // 'active', 'alphabetical', 'newest', or 'random'
    49         'include_blog_ids'  => false,    // Array of blog IDs to include
    50         'user_id'           => false,    // Limit to blogs this user can post to
    51         'search_terms'      => false,    // Limit to blogs matching these search terms
    52         'per_page'          => 20,       // The number of results to return per page
    53         'page'              => 1,        // The page to return if limiting per page
    54         'update_meta_cache' => true      // Whether to pre-fetch blogmeta
     48        'type'              => 'active', // 'active', 'alphabetical', 'newest', or 'random'.
     49        'include_blog_ids'  => false,    // Array of blog IDs to include.
     50        'user_id'           => false,    // Limit to blogs this user can post to.
     51        'search_terms'      => false,    // Limit to blogs matching these search terms.
     52        'per_page'          => 20,       // The number of results to return per page.
     53        'page'              => 1,        // The page to return if limiting per page.
     54        'update_meta_cache' => true      // Whether to pre-fetch blogmeta.
    5555    ), 'blogs_get_blogs' );
    5656
     
    107107    ), 'record_existing_blogs' );
    108108
    109     // Truncate all BP blogs tables if starting fresh
     109    // Truncate all BP blogs tables if starting fresh.
    110110    if ( empty( $r['offset'] ) && empty( $r['blog_ids'] ) ) {
    111111        $bp = buddypress();
    112112
    113         // Truncate user blogs table
     113        // Truncate user blogs table.
    114114        $truncate = $wpdb->query( "TRUNCATE {$bp->blogs->table_name}" );
    115115        if ( is_wp_error( $truncate ) ) {
     
    117117        }
    118118
    119         // Truncate user blogmeta table
     119        // Truncate user blogmeta table.
    120120        $truncate = $wpdb->query( "TRUNCATE {$bp->blogs->table_name_blogmeta}" );
    121121        if ( is_wp_error( $truncate ) ) {
     
    124124    }
    125125
    126     // Multisite
     126    // Multisite.
    127127    if ( is_multisite() ) {
    128128        $sql = array();
    129129        $sql['select'] = $wpdb->prepare( "SELECT blog_id, last_updated FROM {$wpdb->base_prefix}blogs WHERE mature = 0 AND spam = 0 AND deleted = 0 AND site_id = %d", $r['site_id'] );
    130130
    131         // Omit root blog if large network
     131        // Omit root blog if large network.
    132132        if ( bp_is_large_install() ) {
    133133            $sql['omit_root_blog'] = $wpdb->prepare( "AND blog_id != %d", bp_get_root_blog_id() );
    134134        }
    135135
    136         // Filter by selected blog IDs
     136        // Filter by selected blog IDs.
    137137        if ( ! empty( $r['blog_ids'] ) ) {
    138138            $in        = implode( ',', wp_parse_id_list( $r['blog_ids'] ) );
     
    162162    }
    163163
    164      // Bail if there are no blogs
     164     // Bail if there are no blogs.
    165165     if ( empty( $blogs ) ) {
    166         // Make sure we remove our offset marker
     166        // Make sure we remove our offset marker.
    167167        if ( is_multisite() ) {
    168168            bp_delete_option( '_bp_record_blogs_offset' );
     
    193193            bp_blogs_add_user_to_blog( $user_id, false, $blog->blog_id );
    194194
    195             // Clear cache
     195            // Clear cache.
    196196            bp_blogs_clear_blog_object_cache( $blog->blog_id, $user_id );
    197197        }
    198198
    199         // Update blog last activity timestamp
     199        // Update blog last activity timestamp.
    200200        if ( ! empty( $blog->last_updated ) && false !== strtotime( $blog->last_updated ) ) {
    201201            bp_blogs_update_blogmeta( $blog->blog_id, 'last_activity', $blog->last_updated );
     
    203203    }
    204204
    205     // See if we need to do this again
     205    // See if we need to do this again.
    206206    if ( is_multisite() && empty( $r['blog_ids'] ) ) {
    207207        $sql['offset'] = $wpdb->prepare( " OFFSET %d", $r['limit'] + $r['offset'] );
    208208
    209         // Check if there are more blogs to record
     209        // Check if there are more blogs to record.
    210210        $blog_ids = $wpdb->get_results( implode( ' ', $sql ) );
    211211
    212         // We have more blogs; record offset and re-run function
     212        // We have more blogs; record offset and re-run function.
    213213        if ( ! empty( $blog_ids  ) ) {
    214214            bp_update_option( '_bp_record_blogs_offset', $r['limit'] + $r['offset'] );
     
    223223            return;
    224224
    225         // No more blogs; delete offset marker
     225        // No more blogs; delete offset marker.
    226226        } else {
    227227            bp_delete_option( '_bp_record_blogs_offset' );
     
    727727    $blog_id = get_current_blog_id();
    728728
    729     // These activity metadatas are used to build the new_blog_comment action string
     729    // These activity metadatas are used to build the new_blog_comment action string.
    730730    if ( ! empty( $activity_id ) && ! empty( $activity_args['item_id'] ) && 'new_blog_comment' === $activity_post_object->comment_action_id ) {
    731         // add some post info in activity meta
     731        // Add some post info in activity meta.
    732732        bp_activity_update_meta( $activity_id, 'post_title', $comment->post->post_title );
    733733        bp_activity_update_meta( $activity_id, 'post_url',   esc_url_raw( add_query_arg( 'p', $comment->post->ID, home_url( '/' ) ) ) );
    734734    }
    735735
    736     // Sync comment - activity comment
     736    // Sync comment - activity comment.
    737737    if ( ! bp_disable_blogforum_comments() ) {
    738738
     
    750750
    751751        if ( isset( $activity_post_object->action_id ) && isset( $activity_post_object->component_id ) ) {
    752             // find the parent 'new_post_type' activity entry
     752            // Find the parent 'new_post_type' activity entry.
    753753            $parent_activity_id = bp_activity_get_activity_id( array(
    754754                'component'         => $activity_post_object->component_id,
     
    764764        }
    765765
    766         // we found the parent activity entry
    767         // so let's go ahead and reconfigure some activity args
     766        // We found the parent activity entry
     767        // so let's go ahead and reconfigure some activity args.
    768768        if ( ! empty( $parent_activity_id ) ) {
    769             // set the parent activity entry ID
     769            // Set the parent activity entry ID.
    770770            $activity_args['activity_id'] = $parent_activity_id;
    771771
    772             // now see if the WP parent comment has a BP activity ID
     772            // Now see if the WP parent comment has a BP activity ID.
    773773            $comment_parent = 0;
    774774            if ( ! empty( $comment->comment_parent ) ) {
     
    777777
    778778            // WP parent comment does not have a BP activity ID
    779             // so set to 'new_' . post_type activity ID
     779            // so set to 'new_' . post_type activity ID.
    780780            if ( empty( $comment_parent ) ) {
    781781                $comment_parent = $parent_activity_id;
     
    785785            $activity_args['skip_notification'] = true;
    786786
    787         // could not find corresponding parent activity entry
    788         // so wipe out $args array
     787        // Could not find corresponding parent activity entry
     788        // so wipe out $args array.
    789789        } else {
    790790            $activity_args = array();
    791791        }
    792792
    793         // Record in activity streams
     793        // Record in activity streams.
    794794        if ( ! empty( $activity_args ) ) {
    795795            $activity_id = bp_activity_new_comment( $activity_args );
    796796
    797797            if ( empty( $activity_args['id'] ) ) {
    798                 // The activity metadata to inform about the corresponding comment ID
     798                // The activity metadata to inform about the corresponding comment ID.
    799799                bp_activity_update_meta( $activity_id, "bp_blogs_{$comment->post->post_type}_comment_id", $comment->comment_ID );
    800800
    801                 // The comment metadata to inform about the corresponding activity ID
     801                // The comment metadata to inform about the corresponding activity ID.
    802802                add_comment_meta( $comment->comment_ID, 'bp_activity_comment_id', $activity_id );
    803803
    804                 // These activity metadatas are used to build the new_blog_comment action string
     804                // These activity metadatas are used to build the new_blog_comment action string.
    805805                if ( 'new_blog_comment' === $activity_post_object->comment_action_id ) {
    806806                    bp_activity_update_meta( $activity_id, 'post_title', $comment->post->post_title );
     
    10551055         */
    10561056        if ( ! empty( $activity_id ) ) {
    1057             // fetch the activity comments for the activity item
     1057            // Fetch the activity comments for the activity item.
    10581058            $activity = bp_activity_get( array(
    10591059                'in'               => $activity_id,
     
    10621062            ) );
    10631063
    1064             // get all activity comment IDs for the pending deleted item
     1064            // Get all activity comment IDs for the pending deleted item.
    10651065            if ( ! empty( $activity['activities'] ) ) {
    10661066                $activity_ids   = bp_activity_recurse_comments_activity_ids( $activity );
    10671067                $activity_ids[] = $activity_id;
    10681068
    1069                 // delete activity items
     1069                // Delete activity items.
    10701070                foreach ( $activity_ids as $activity_id ) {
    10711071                    bp_activity_delete( array(
     
    10741074                }
    10751075
    1076                 // remove associated blog comments
     1076                // Remove associated blog comments.
    10771077                bp_blogs_remove_associated_blog_comments( $activity_ids );
    10781078
    1079                 // rebuild activity comment tree
     1079                // Rebuild activity comment tree.
    10801080                BP_Activity_Activity::rebuild_activity_comment_tree( $activity['activities'][0]->item_id );
    10811081
    1082                 // Set the result
     1082                // Set the result.
    10831083                $deleted = true;
    10841084            }
Note: See TracChangeset for help on using the changeset viewer.