Skip to:
Content

BuddyPress.org


Ignore:
Timestamp:
03/09/2014 07:29:51 PM (11 years ago)
Author:
boonebgorges
Message:

When deleting activity items, delete corresponding notifications

See #5289

Props imath

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/bp-activity/bp-activity-notifications.php

    r7831 r8095  
    377377add_action( 'bp_activity_screen_single_activity_permalink', 'bp_activity_remove_screen_notifications_single_activity_permalink' );
    378378
     379/**
     380 * Delete at-mention notifications when the corresponding activity item is deleted.
     381 *
     382 * @since BuddyPress (2.0.0)
     383 *
     384 * @param array $activity_ids_deleted IDs of deleted activity items.
     385 */
     386function bp_activity_at_mention_delete_notification( $activity_ids_deleted = array() ) {
     387    // Let's delete all without checking if content contains any mentions
     388    // to avoid a query to get the activity
     389    if ( bp_is_active( 'notifications' ) && ! empty( $activity_ids_deleted ) ) {
     390        foreach ( $activity_ids_deleted as $activity_id ) {
     391            bp_notifications_delete_all_notifications_by_type( $activity_id, buddypress()->activity->id );
     392        }
     393    }
     394}
     395add_action( 'bp_activity_deleted_activities', 'bp_activity_at_mention_delete_notification', 10 );
Note: See TracChangeset for help on using the changeset viewer.