blogs} WHERE site_id = '{$wpdb->siteid}' "; $blog_list = $wpdb->get_results( $query, ARRAY_A ); foreach( $blog_list as $blog ) { /*if ( $blog['blog_id'] < 12 ) continue; if ( $blog['blog_id'] > 30 ) die();*/ switch_to_blog( $blog['blog_id'] ); print "
";


				query_posts('order=ASC');

				echo "Blog name: " . get_bloginfo('name') . "";
				echo "
"; if ( have_posts() ) { while ( have_posts() ) { the_post(); //echo "The post is: "; the_title(); echo "
"; $filter = array( 'object' => 'blogs', 'primary_id' => $blog['blog_id'], 'secondary_id' => get_the_ID(), 'action' => 'new_blog_post' ); $activities = bp_activity_get( array( 'filter' => $filter ) ); if ( empty($activities->activities) ) { global $post; if ( (int)get_blog_option( $blog['blog_id'], 'blog_public' ) ) { $post_permalink = get_permalink(); $activity_action = sprintf( __( '%s wrote a new blog post: %s', 'buddypress' ), bp_core_get_userlink( (int)$post->post_author ), '' . $post->post_title . '' ); $activity_content = $post->post_content; $post_id = get_the_ID(); bp_blogs_record_activity( array( 'user_id' => (int)$post->post_author, 'action' => apply_filters( 'bp_blogs_activity_new_post_action', $activity_action, $post, $post_permalink ), 'content' => apply_filters( 'bp_blogs_activity_new_post_content', $activity_content, $post, $post_permalink ), 'primary_link' => apply_filters( 'bp_blogs_activity_new_post_primary_link', $post_permalink, $post_id ), 'type' => 'new_blog_post', 'item_id' => $blog['blog_id'], 'secondary_item_id' => $post_id, 'recorded_time' => $post->post_date_gmt )); } echo "Importing: \"" . $activity_action . "\"
"; } $comments = get_comments("post_id=" . $post_id ); foreach( $comments as $recorded_comment ) { $user = get_user_by( 'email', $recorded_comment->comment_author_email ); if ( is_wp_error( $user ) || ! is_a( 'WP_User', $user ) ) { continue; } $user_id = $user->ID; $filter = array( 'object' => 'blogs', 'primary_id' => $blog['blog_id'], 'secondary_id' => $recorded_comment->comment_ID, 'action' => 'new_blog_comment' ); $activities = bp_activity_get( array( 'filter' => $filter ) ); if ( empty($activities->activities) ) { if ( (int)get_blog_option( $recorded_comment->blog_id, 'blog_public' )) { global $post; $comment_link = $post_permalink . '#comment-' . $recorded_comment->comment_ID; $activity_action = sprintf( __( '%s commented on the blog post %s', 'buddypress' ), bp_core_get_userlink( $user_id ), '' . $post->post_title . '' ); $activity_content = $recorded_comment->comment_content; /* Record this in activity streams */ bp_blogs_record_activity( array( 'user_id' => $user_id, 'action' => apply_filters( 'bp_blogs_activity_new_comment_action', $activity_action, $comment, $recorded_comment, $comment_link ), 'content' => apply_filters( 'bp_blogs_activity_new_comment_content', $activity_content, $comment, $recorded_comment, $comment_link ), 'primary_link' => apply_filters( 'bp_blogs_activity_new_comment_primary_link', $comment_link, $comment, $recorded_comment ), 'type' => 'new_blog_comment', 'item_id' => $blog['blog_id'], 'secondary_item_id' => $recorded_comment->comment_ID, 'recorded_time' => $recorded_comment->comment_date_gmt ) ); echo "Importing: \"" . $activity_action . ": " . $activity_content . "\"
"; } } } } // end while have_posts } // end if have_posts wp_reset_query(); echo "

"; restore_current_blog(); } } } ?>