/** * Delete an activity comment's children. * * @since BuddyPress (1.2.0) * * @uses BP_Activity_Activity::get_child_comments() {@link BP_Activity_Activity} * @uses bp_activity_delete_children() * @uses bp_activity_delete() * * @param int $activity_id The ID of the "root" activity, ie the * comment's oldest ancestor. * @param int $comment_id The ID of the comment to be deleted. */ function bp_activity_delete_children($activity_id, $comment_id) { // Get activity children to delete $children = BP_Activity_Activity::get_child_comments($comment_id); // Recursively delete all children of this comment. if (!empty($children)) { foreach ((array) $children as $child) { bp_activity_delete_children($activity_id, $child->id); } } // Delete the comment itself bp_activity_delete(array('secondary_item_id' => $comment_id, 'type' => 'activity_comment', 'item_id' => $activity_id)); }
function bp_activity_delete_children( $activity_id, $comment_id) { /* Recursively delete all children of this comment. */ if ( $children = BP_Activity_Activity::get_child_comments( $comment_id ) ) { foreach( (array)$children as $child ) bp_activity_delete_children( $activity_id, $child->id ); } bp_activity_delete( array( 'secondary_item_id' => $comment_id, 'type' => 'activity_comment', 'item_id' => $activity_id ) ); }