Changeset 8944 for trunk/src/bp-blogs/bp-blogs-functions.php
- Timestamp:
- 08/18/2014 04:51:11 PM (11 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/bp-blogs/bp-blogs-functions.php
r8942 r8944 524 524 $activity_content = $post->post_content; 525 525 526 bp_blogs_record_activity( array(526 $activity_id = bp_blogs_record_activity( array( 527 527 'user_id' => (int) $post->post_author, 528 528 'content' => apply_filters( 'bp_blogs_activity_new_post_content', $activity_content, $post, $post_permalink ), … … 532 532 'secondary_item_id' => $post_id, 533 533 'recorded_time' => $post->post_date_gmt, 534 )); 534 ) ); 535 536 // save post title in activity meta 537 bp_activity_update_meta( $activity_id, 'post_title', $post->post_title ); 538 bp_activity_update_meta( $activity_id, 'post_url', $post_permalink ); 535 539 } 536 540 … … 584 588 $activity->save(); 585 589 590 // update post title in activity meta 591 $existing_title = bp_activity_get_meta( $activity_id, 'post_title' ); 592 if ( $post->post_title !== $existing_title ) { 593 bp_activity_update_meta( $activity_id, 'post_title', $post->post_title ); 594 595 // now update activity meta for post comments... sigh 596 $comment_ids = get_comments( array( 'post_id' => $post->ID, 'fields' => 'ids' ) ); 597 598 if ( ! empty( $comment_ids ) ) { 599 $activity_ids = array(); 600 601 // setup activity args 602 $args = array( 603 'update_meta_cache' => false, 604 'show_hidden' => true, 605 'per_page' => 99999, 606 ); 607 608 // query for old-style "new_blog_comment" activity items 609 $args['filter'] = array( 610 'object' => buddypress()->blogs->id, 611 'action' => 'new_blog_comment', 612 'secondary_id' => implode( ',', $comment_ids ), 613 ); 614 615 $activities = bp_activity_get( $args ); 616 if ( ! empty( $activities['activities'] ) ) { 617 $activity_ids = (array) wp_list_pluck( $activities['activities'], 'id' ); 618 } 619 620 // query for activity comments connected to a blog post 621 unset( $args['filter'] ); 622 $args['meta_query'] = array( array( 623 'key' => 'bp_blogs_post_comment_id', 624 'value' => $comment_ids, 625 'compare' => 'IN', 626 ) ); 627 $args['type'] = 'activity_comment'; 628 $args['display_comments'] = 'stream'; 629 630 $activities = bp_activity_get( $args ); 631 if ( ! empty( $activities['activities'] ) ) { 632 $activity_ids = array_merge( $activity_ids, (array) wp_list_pluck( $activities['activities'], 'id' ) ); 633 } 634 635 // update activity meta for all found activity items 636 if ( ! empty( $activity_ids ) ) { 637 foreach ( $activity_ids as $aid ) { 638 bp_activity_update_meta( $aid, 'post_title', $post->post_title ); 639 } 640 } 641 642 unset( $activities, $activity_ids, $comment_ids ); 643 } 644 } 645 586 646 // add post comment status to activity meta if closed 587 647 if( 'closed' == $post->comment_status ) { … … 681 741 682 742 // record the activity entry 683 bp_blogs_record_activity( $args ); 743 $activity_id = bp_blogs_record_activity( $args ); 744 745 // add some post info in activity meta 746 bp_activity_update_meta( $activity_id, 'post_title', $recorded_comment->post->post_title ); 747 bp_activity_update_meta( $activity_id, 'post_url', add_query_arg( 'p', $recorded_comment->post->ID, home_url( '/' ) ) ); 684 748 685 749 // record comment as BP activity comment under the parent 'new_blog_post' … … 745 809 // add meta to activity comment 746 810 bp_activity_update_meta( $comment_activity_id, 'bp_blogs_post_comment_id', $comment_id ); 811 bp_activity_update_meta( $comment_activity_id, 'post_title', $recorded_comment->post->post_title ); 812 bp_activity_update_meta( $comment_activity_id, 'post_url', add_query_arg( 'p', $recorded_comment->post->ID, home_url( '/' ) ) ); 747 813 748 814 // add meta to comment
Note: See TracChangeset
for help on using the changeset viewer.