Skip to:
Content

BuddyPress.org

Changeset 12544


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

Blogs: fix PHP code standards & typos in inline comments

Props passoniate

Fixes #8222

Location:
trunk/src/bp-blogs
Files:
3 edited

Legend:

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

    r12393 r12544  
    288288    $blog_url = false;
    289289
    290     // Try to get the blog url from the activity object
     290    // Try to get the blog url from the activity object.
    291291    if ( isset( $activity->blog_url ) ) {
    292292        $blog_url = $activity->blog_url;
     
    297297    $blog_name = false;
    298298
    299     // Try to get the blog name from the activity object
     299    // Try to get the blog name from the activity object.
    300300    if ( isset( $activity->blog_name ) ) {
    301301        $blog_name = $activity->blog_name;
     
    314314    $post_url = false;
    315315
    316     // Try to get the post url from the activity object
     316    // Try to get the post url from the activity object.
    317317    if ( isset( $activity->post_url ) ) {
    318318        $post_url = $activity->post_url;
     
    329329    $post_title = false;
    330330
    331     // Should be the case when the comment has just been published
     331    // Should be the case when the comment has just been published.
    332332    if ( isset( $activity->post_title ) ) {
    333333        $post_title = $activity->post_title;
    334334
    335     // If activity already exists try to get the post title from activity meta
     335    // If activity already exists try to get the post title from activity meta.
    336336    } elseif ( ! empty( $activity->id ) ) {
    337337        $post_title = bp_activity_get_meta( $activity->id, 'post_title' );
     
    790790    }
    791791
    792     // Get associated post type and set default comment parent
     792    // Get associated post type and set default comment parent.
    793793    $post_type      = bp_activity_post_type_get_tracking_arg( $parent_activity->type, 'post_type' );
    794794    $comment_parent = 0;
     
    806806        'comment_author_url'   => bp_core_get_user_domain( $params['user_id'], $user->user_nicename, $user->user_login ),
    807807        'comment_content'      => $params['content'],
    808         'comment_type'         => '', // Could be interesting to add 'buddypress' here...
     808        'comment_type'         => '', // Could be interesting to add 'BuddyPress' here...
    809809        'comment_parent'       => (int) $comment_parent,
    810810        'user_id'              => $params['user_id'],
     
    910910    $activity_ids[] = $activity_id;
    911911
    912     // Handle multisite
     912    // Handle multisite.
    913913    // switch to the blog where the comment was made.
    914914    switch_to_blog( $parent_activity->item_id );
     
    924924    BP_Activity_Activity::rebuild_activity_comment_tree( $parent_activity_id );
    925925
    926     // Avoid the error message although the comments were successfully deleted
     926    // Avoid the error message although the comments were successfully deleted.
    927927    $deleted = true;
    928928
     
    947947    }
    948948
    949     // fetch parent activity item
     949    // Fetch parent activity item.
    950950    $parent_activity = new BP_Activity_Activity( $activity->item_id );
    951951
    952     // if parent activity isn't a post type having the buddypress-activity support for comments, stop now!
     952    // If parent activity isn't a post type having the buddypress-activity support for comments, stop now!
    953953    if ( ! bp_activity_type_supports( $parent_activity->type, 'post-type-comment-tracking' ) ) {
    954954        return;
     
    972972    switch_to_blog( $parent_activity->item_id );
    973973
    974     // Get the comment status
     974    // Get the comment status.
    975975    $post_comment_status = wp_get_comment_status( $post_comment_id );
    976976    $old_comment_status  = $post_comment_status;
    977977
    978     // No need to edit the activity, as it's the activity who's updating the comment
     978    // No need to edit the activity, as it's the activity who's updating the comment.
    979979    remove_action( 'transition_comment_status', 'bp_activity_transition_post_type_comment_status', 10 );
    980980    remove_action( 'bp_activity_post_type_comment', 'bp_blogs_comment_sync_activity_comment', 10 );
     
    996996    }
    997997
    998     // Restore actions
     998    // Restore actions.
    999999    add_action( 'transition_comment_status',     'bp_activity_transition_post_type_comment_status', 10, 3 );
    10001000    add_action( 'bp_activity_post_type_comment', 'bp_blogs_comment_sync_activity_comment',          10, 4 );
     
    10551055    }
    10561056
    1057     // Get the associated post type
     1057    // Get the associated post type.
    10581058    $post_type = bp_activity_post_type_get_tracking_arg( $args['action'], 'post_type' );
    10591059
    1060     // Bail if this is not an activity associated with a post type
     1060    // Bail if this is not an activity associated with a post type.
    10611061    if ( empty( $post_type ) ) {
    10621062        return $args;
    10631063    }
    10641064
    1065     // Bail if this is an activity about posts and not comments
     1065    // Bail if this is an activity about posts and not comments.
    10661066    if ( bp_activity_post_type_get_tracking_arg( $args['action'], 'comment_action_id' ) ) {
    10671067        return $args;
     
    12361236    // It's a post type supporting comment tracking.
    12371237    if ( bp_activity_type_supports( $type, 'post-type-comment-tracking' ) ) {
    1238         // The activity type is supporting comments or replies
     1238        // The activity type is supporting comments or replies.
    12391239        if ( bp_activity_type_supports( $type, 'post-type-comment-reply' ) ) {
    12401240            // Setup some globals we'll need to reference later.
     
    12511251                $retval = false;
    12521252            }
    1253         // The activity type does not support comments or replies
     1253        // The activity type does not support comments or replies.
    12541254        } else {
    12551255            $retval = false;
     
    12861286    }
    12871287
    1288     // Check the parent activity
     1288    // Check the parent activity.
    12891289    $parent_activity = new BP_Activity_Activity( bp_get_activity_item_id() );
    12901290
     
    14391439        $bp = buddypress();
    14401440
    1441         // Check if a comment action id is set for the parent activity
     1441        // Check if a comment action id is set for the parent activity.
    14421442        $comment_action_id = bp_activity_post_type_get_tracking_arg( $parent_activity->type, 'comment_action_id' );
    14431443
    1444         // Use the action string callback for the activity type
     1444        // Use the action string callback for the activity type.
    14451445        if ( ! empty( $comment_action_id ) ) {
    14461446            // Fake a 'new_{post_type}_comment' by cloning the activity object.
    14471447            $object = clone $activity;
    14481448
    1449             // Set the type of the activity to be a comment about a post type
     1449            // Set the type of the activity to be a comment about a post type.
    14501450            $object->type = $comment_action_id;
    14511451
     
    14561456            $object->secondary_item_id = $blog_comment_id;
    14571457
    1458             // Get the format callback for this activity comment
     1458            // Get the format callback for this activity comment.
    14591459            $format_callback = bp_activity_post_type_get_tracking_arg( $comment_action_id, 'format_callback' );
    14601460
    1461             // now format the activity action using the 'new_{post_type}_comment' action callback
     1461            // Now format the activity action using the 'new_{post_type}_comment' action callback.
    14621462            if ( is_callable( $format_callback ) ) {
    14631463                $retval = call_user_func_array( $format_callback, array( '', $object ) );
  • 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            }
  • trunk/src/bp-blogs/classes/class-bp-blogs-blog.php

    r11237 r12544  
    8787
    8888        /**
    89          * Filters the blog blog ID before save.
     89         * Filters the blog ID before save.
    9090         *
    9191         * @since 1.0.0
Note: See TracChangeset for help on using the changeset viewer.