diff --git src/bp-activity/classes/class-bp-activity-activity.php src/bp-activity/classes/class-bp-activity-activity.php
index e6040fb..50247f1 100644
|
|
class BP_Activity_Activity { |
586 | 586 | bp_activity_update_meta_cache( $activity_ids ); |
587 | 587 | } |
588 | 588 | |
589 | | if ( $activities && $r['display_comments'] ) { |
| 589 | if ( $activities && $r['display_comments'] && 'no_replies' !== $r['display_comments'] ) { |
590 | 590 | $activities = BP_Activity_Activity::append_comments( $activities, $r['spam'] ); |
591 | 591 | } |
592 | 592 | |
diff --git src/bp-blogs/bp-blogs-activity.php src/bp-blogs/bp-blogs-activity.php
index c29e56b..e17356c 100644
|
|
add_action( 'trashed_post_comments', 'bp_blogs_remove_activity_meta_for_trashed_ |
766 | 766 | * @return array $args |
767 | 767 | */ |
768 | 768 | function bp_blogs_new_blog_comment_query_backpat( $args ) { |
| 769 | global $wpdb; |
| 770 | $bp = buddypress(); |
| 771 | |
769 | 772 | // Bail if this is not a 'new_blog_comment' query |
770 | 773 | if ( 'new_blog_comment' !== $args['action'] ) { |
771 | 774 | return $args; |
772 | 775 | } |
773 | 776 | |
774 | | // display_comments=stream is required to show new-style |
775 | | // 'activity_comment' items inline |
776 | | $args['display_comments'] = 'stream'; |
| 777 | // if activity comments are disabled for blog posts, stop now! |
| 778 | if ( bp_disable_blogforum_comments() ) { |
| 779 | return $args; |
| 780 | } |
777 | 781 | |
778 | | // For the remaining clauses, we filter the SQL query directly |
779 | | add_filter( 'bp_activity_paged_activities_sql', '_bp_blogs_new_blog_comment_query_backpat_filter' ); |
780 | | add_filter( 'bp_activity_total_activities_sql', '_bp_blogs_new_blog_comment_query_backpat_filter' ); |
| 782 | // Comment synced ? |
| 783 | $activity_ids = $wpdb->get_col( $wpdb->prepare( "SELECT activity_id FROM {$bp->activity->table_name_meta} WHERE meta_key = %s", 'bp_blogs_post_comment_id' ) ); |
781 | 784 | |
782 | | // Return the original arguments |
783 | | return $args; |
784 | | } |
785 | | add_filter( 'bp_after_has_activities_parse_args', 'bp_blogs_new_blog_comment_query_backpat' ); |
| 785 | if ( empty( $activity_ids ) ) { |
| 786 | return $args; |
| 787 | } |
786 | 788 | |
787 | | /** |
788 | | * Filter activity SQL to include new- and old-style 'new_blog_comment' activity items. |
789 | | * |
790 | | * @since BuddyPress (2.1.0) |
791 | | * |
792 | | * @access private |
793 | | * @see bp_blogs_new_blog_comment_query_backpat() |
794 | | * |
795 | | * @param string $query SQL query as assembled in BP_Activity_Activity::get(). |
796 | | * @return string $query Modified SQL query. |
797 | | */ |
798 | | function _bp_blogs_new_blog_comment_query_backpat_filter( $query ) { |
799 | | $bp = buddypress(); |
| 789 | // Init the filter query |
| 790 | $filter_query = array(); |
| 791 | |
| 792 | if ( 'null' === $args['scope'] ) { |
| 793 | $args['scope'] = ''; |
| 794 | } elseif ( 'just-me' === $args['scope'] ) { |
| 795 | $filter_query = array( |
| 796 | 'relation' => 'AND', |
| 797 | array( |
| 798 | 'column' => 'user_id', |
| 799 | 'value' => bp_displayed_user_id(), |
| 800 | ), |
| 801 | ); |
| 802 | $args['scope'] = ''; |
| 803 | } |
| 804 | |
| 805 | $filter_query[] = array( |
| 806 | 'relation' => 'OR', |
| 807 | array( |
| 808 | 'column' => 'type', |
| 809 | 'value' => $args['action'], |
| 810 | ), |
| 811 | array( |
| 812 | 'relation' => 'AND', |
| 813 | array( |
| 814 | 'column' => 'type', |
| 815 | 'value' => 'activity_comment', |
| 816 | ), |
| 817 | array( |
| 818 | 'column' => 'id', |
| 819 | 'value' => $activity_ids, |
| 820 | 'compare' => 'IN' |
| 821 | ), |
| 822 | ), |
| 823 | ); |
800 | 824 | |
801 | | // The query passed to the filter is for old-style 'new_blog_comment' |
802 | | // items. We include new-style 'activity_comment' items by running a |
803 | | // subquery inside of a large OR clause. |
804 | | $activity_comment_subquery = "SELECT a.id FROM {$bp->activity->table_name} a INNER JOIN {$bp->activity->table_name_meta} am ON (a.id = am.activity_id) WHERE am.meta_key = 'bp_blogs_post_comment_id' AND a.type = 'activity_comment'"; |
| 825 | $args['filter_query'] = $filter_query; |
805 | 826 | |
806 | | // WHERE ( [original WHERE clauses] OR a.id IN (activity_comment subquery) ) |
807 | | $query = preg_replace( '|WHERE (.*?) ORDER|', 'WHERE ( ( $1 ) OR ( a.id IN ( ' . $activity_comment_subquery . ' ) ) ) ORDER', $query ); |
| 827 | // Make sure to have comment in stream mode && avoid duplicate content |
| 828 | $args['display_comments'] = 'no_replies'; |
808 | 829 | |
809 | | // Don't run this on future queries |
810 | | remove_filter( current_filter(), '_bp_blogs_new_blog_comment_query_backpat_filter' ); |
| 830 | // Finally reset the action |
| 831 | $args['action'] = ''; |
811 | 832 | |
812 | | return $query; |
| 833 | // Return the original arguments |
| 834 | return $args; |
813 | 835 | } |
| 836 | add_filter( 'bp_after_has_activities_parse_args', 'bp_blogs_new_blog_comment_query_backpat' ); |
814 | 837 | |
815 | 838 | /** |
816 | 839 | * Utility function to set up some variables for use in the activity loop. |