// Move children up a level.
$children =
$wpdb->
get_col( $wpdb->
prepare( "SELECT comment_ID FROM
$wpdb->comments WHERE comment_parent = %d",
$comment->comment_ID
) );
if ( !
empty( $children ) ) { $wpdb->
update( $wpdb->comments, array
( 'comment_parent' =>
$comment->comment_parent
), array
( 'comment_parent' =>
$comment->comment_ID
) );
clean_comment_cache( $children );
} // Delete metadata.
$meta_ids =
$wpdb->
get_col( $wpdb->
prepare( "SELECT meta_id FROM
$wpdb->commentmeta WHERE comment_id = %d",
$comment->comment_ID
) );
foreach ( $meta_ids as $mid ) { delete_metadata_by_mid( 'comment',
$mid );
} if ( !
$wpdb->
delete( $wpdb->comments, array
( 'comment_ID' =>
$comment->comment_ID
) ) ) { return false;
} /**
* Fires immediately after a comment is deleted from the database.
*
* @since 2.9.0
* @since 4.9.0 Added the `$comment` parameter.
*
* @param string $comment_id The comment ID as a numeric string.
* @param WP_Comment $comment The deleted comment.
*/