Changeset 12544 for trunk/src/bp-blogs/bp-blogs-functions.php
- Timestamp:
- 01/29/2020 08:36:15 PM (6 years ago)
- File:
-
- 1 edited
-
trunk/src/bp-blogs/bp-blogs-functions.php (modified) (16 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/bp-blogs/bp-blogs-functions.php
r12311 r12544 46 46 // Parse query arguments. 47 47 $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. 55 55 ), 'blogs_get_blogs' ); 56 56 … … 107 107 ), 'record_existing_blogs' ); 108 108 109 // Truncate all BP blogs tables if starting fresh 109 // Truncate all BP blogs tables if starting fresh. 110 110 if ( empty( $r['offset'] ) && empty( $r['blog_ids'] ) ) { 111 111 $bp = buddypress(); 112 112 113 // Truncate user blogs table 113 // Truncate user blogs table. 114 114 $truncate = $wpdb->query( "TRUNCATE {$bp->blogs->table_name}" ); 115 115 if ( is_wp_error( $truncate ) ) { … … 117 117 } 118 118 119 // Truncate user blogmeta table 119 // Truncate user blogmeta table. 120 120 $truncate = $wpdb->query( "TRUNCATE {$bp->blogs->table_name_blogmeta}" ); 121 121 if ( is_wp_error( $truncate ) ) { … … 124 124 } 125 125 126 // Multisite 126 // Multisite. 127 127 if ( is_multisite() ) { 128 128 $sql = array(); 129 129 $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'] ); 130 130 131 // Omit root blog if large network 131 // Omit root blog if large network. 132 132 if ( bp_is_large_install() ) { 133 133 $sql['omit_root_blog'] = $wpdb->prepare( "AND blog_id != %d", bp_get_root_blog_id() ); 134 134 } 135 135 136 // Filter by selected blog IDs 136 // Filter by selected blog IDs. 137 137 if ( ! empty( $r['blog_ids'] ) ) { 138 138 $in = implode( ',', wp_parse_id_list( $r['blog_ids'] ) ); … … 162 162 } 163 163 164 // Bail if there are no blogs 164 // Bail if there are no blogs. 165 165 if ( empty( $blogs ) ) { 166 // Make sure we remove our offset marker 166 // Make sure we remove our offset marker. 167 167 if ( is_multisite() ) { 168 168 bp_delete_option( '_bp_record_blogs_offset' ); … … 193 193 bp_blogs_add_user_to_blog( $user_id, false, $blog->blog_id ); 194 194 195 // Clear cache 195 // Clear cache. 196 196 bp_blogs_clear_blog_object_cache( $blog->blog_id, $user_id ); 197 197 } 198 198 199 // Update blog last activity timestamp 199 // Update blog last activity timestamp. 200 200 if ( ! empty( $blog->last_updated ) && false !== strtotime( $blog->last_updated ) ) { 201 201 bp_blogs_update_blogmeta( $blog->blog_id, 'last_activity', $blog->last_updated ); … … 203 203 } 204 204 205 // See if we need to do this again 205 // See if we need to do this again. 206 206 if ( is_multisite() && empty( $r['blog_ids'] ) ) { 207 207 $sql['offset'] = $wpdb->prepare( " OFFSET %d", $r['limit'] + $r['offset'] ); 208 208 209 // Check if there are more blogs to record 209 // Check if there are more blogs to record. 210 210 $blog_ids = $wpdb->get_results( implode( ' ', $sql ) ); 211 211 212 // We have more blogs; record offset and re-run function 212 // We have more blogs; record offset and re-run function. 213 213 if ( ! empty( $blog_ids ) ) { 214 214 bp_update_option( '_bp_record_blogs_offset', $r['limit'] + $r['offset'] ); … … 223 223 return; 224 224 225 // No more blogs; delete offset marker 225 // No more blogs; delete offset marker. 226 226 } else { 227 227 bp_delete_option( '_bp_record_blogs_offset' ); … … 727 727 $blog_id = get_current_blog_id(); 728 728 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. 730 730 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 meta731 // Add some post info in activity meta. 732 732 bp_activity_update_meta( $activity_id, 'post_title', $comment->post->post_title ); 733 733 bp_activity_update_meta( $activity_id, 'post_url', esc_url_raw( add_query_arg( 'p', $comment->post->ID, home_url( '/' ) ) ) ); 734 734 } 735 735 736 // Sync comment - activity comment 736 // Sync comment - activity comment. 737 737 if ( ! bp_disable_blogforum_comments() ) { 738 738 … … 750 750 751 751 if ( isset( $activity_post_object->action_id ) && isset( $activity_post_object->component_id ) ) { 752 // find the parent 'new_post_type' activity entry752 // Find the parent 'new_post_type' activity entry. 753 753 $parent_activity_id = bp_activity_get_activity_id( array( 754 754 'component' => $activity_post_object->component_id, … … 764 764 } 765 765 766 // we found the parent activity entry767 // 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. 768 768 if ( ! empty( $parent_activity_id ) ) { 769 // set the parent activity entry ID769 // Set the parent activity entry ID. 770 770 $activity_args['activity_id'] = $parent_activity_id; 771 771 772 // now see if the WP parent comment has a BP activity ID772 // Now see if the WP parent comment has a BP activity ID. 773 773 $comment_parent = 0; 774 774 if ( ! empty( $comment->comment_parent ) ) { … … 777 777 778 778 // 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. 780 780 if ( empty( $comment_parent ) ) { 781 781 $comment_parent = $parent_activity_id; … … 785 785 $activity_args['skip_notification'] = true; 786 786 787 // could not find corresponding parent activity entry788 // so wipe out $args array 787 // Could not find corresponding parent activity entry 788 // so wipe out $args array. 789 789 } else { 790 790 $activity_args = array(); 791 791 } 792 792 793 // Record in activity streams 793 // Record in activity streams. 794 794 if ( ! empty( $activity_args ) ) { 795 795 $activity_id = bp_activity_new_comment( $activity_args ); 796 796 797 797 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. 799 799 bp_activity_update_meta( $activity_id, "bp_blogs_{$comment->post->post_type}_comment_id", $comment->comment_ID ); 800 800 801 // The comment metadata to inform about the corresponding activity ID 801 // The comment metadata to inform about the corresponding activity ID. 802 802 add_comment_meta( $comment->comment_ID, 'bp_activity_comment_id', $activity_id ); 803 803 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. 805 805 if ( 'new_blog_comment' === $activity_post_object->comment_action_id ) { 806 806 bp_activity_update_meta( $activity_id, 'post_title', $comment->post->post_title ); … … 1055 1055 */ 1056 1056 if ( ! empty( $activity_id ) ) { 1057 // fetch the activity comments for the activity item1057 // Fetch the activity comments for the activity item. 1058 1058 $activity = bp_activity_get( array( 1059 1059 'in' => $activity_id, … … 1062 1062 ) ); 1063 1063 1064 // get all activity comment IDs for the pending deleted item1064 // Get all activity comment IDs for the pending deleted item. 1065 1065 if ( ! empty( $activity['activities'] ) ) { 1066 1066 $activity_ids = bp_activity_recurse_comments_activity_ids( $activity ); 1067 1067 $activity_ids[] = $activity_id; 1068 1068 1069 // delete activity items1069 // Delete activity items. 1070 1070 foreach ( $activity_ids as $activity_id ) { 1071 1071 bp_activity_delete( array( … … 1074 1074 } 1075 1075 1076 // remove associated blog comments1076 // Remove associated blog comments. 1077 1077 bp_blogs_remove_associated_blog_comments( $activity_ids ); 1078 1078 1079 // rebuild activity comment tree1079 // Rebuild activity comment tree. 1080 1080 BP_Activity_Activity::rebuild_activity_comment_tree( $activity['activities'][0]->item_id ); 1081 1081 1082 // Set the result 1082 // Set the result. 1083 1083 $deleted = true; 1084 1084 }
Note: See TracChangeset
for help on using the changeset viewer.