Advertisement
Guest User

Untitled

a guest
Nov 8th, 2011
81
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. function bbg_remove_doubles( $has_activities ) {
  2.     global $activities_template;
  3.  
  4.     foreach( $activities_template->activities as $activity_key => $activity ) {
  5.         //var_dump( $activity->type );
  6.         if ( 'new_blog_post' == $activity->type ) {
  7.             // Get the parent item
  8.             $parent_id = $activity->item_id;
  9.  
  10.             if ( empty( $activities_template->activity_parents[$parent_id] ) ) {
  11.                 return $has_activities;
  12.             } else {
  13.                 $parent = $activities_template->activity_parents[$parent_id];
  14.             }
  15.  
  16.             // Is the activity author the same as the parent author? If so, remove
  17.             if ( $parent->blog_id !== 1 ) {
  18.                 unset( $activities_template->activities[$activity_key] );
  19.  
  20.                 $activities_template->activity_count--;
  21.                 $activities_template->total_activity_count--;
  22.             }
  23.         }
  24.     }
  25.  
  26.     // Reset indexes
  27.     $activities_template->activities = array_values( $activities_template->activities );
  28.  
  29.     return $has_activities;
  30. }
  31. add_filter( 'bp_has_activities', 'bbg_remove_doubles' );
  32.  
  33. function bbg_dont_remove_doubles_on_ajax() {
  34.     remove_filter( 'bp_has_activities', 'bbg_remove_doubles' );
  35. }
  36. add_action( 'wp_ajax_new_blog_post', 'bbg_dont_remove_doubles', 1 );
  37.  
Advertisement
RAW Paste Data Copied
Advertisement