Changeset 8095
- Timestamp:
- 03/09/2014 07:29:51 PM (11 years ago)
- Location:
- trunk
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/bp-activity/bp-activity-notifications.php
r7831 r8095 377 377 add_action( 'bp_activity_screen_single_activity_permalink', 'bp_activity_remove_screen_notifications_single_activity_permalink' ); 378 378 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 */ 386 function 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 } 395 add_action( 'bp_activity_deleted_activities', 'bp_activity_at_mention_delete_notification', 10 ); -
trunk/tests/testcases/activity/notifications.php
r7831 r8095 207 207 208 208 /** 209 * @group bp_notifications_delete_all_notifications_by_type 210 * @group bp_activity_at_mention_delete_notification 211 */ 212 public function test_bp_activity_at_mention_delete_notification() { 213 $this->create_notifications(); 214 215 $notifications = BP_Notifications_Notification::get( array( 216 'item_id' => $this->a1, 217 ) ); 218 219 // Double check it's there 220 $this->assertEquals( array( $this->a1 ), wp_list_pluck( $notifications, 'item_id' ) ); 221 222 bp_activity_delete( array( 223 'id' => $this->a1, 224 ) ); 225 226 $notifications = BP_Notifications_Notification::get( array( 227 'item_id' => $this->a1, 228 ) ); 229 230 $this->assertEmpty( $notifications ); 231 } 232 233 /** 209 234 * Creates two notifications for $u1, one of which is for mentions 210 235 */
Note: See TracChangeset
for help on using the changeset viewer.