wp_delete_comment

The timeline below displays how wordpress function wp_delete_comment has changed across different WordPress versions. If a version is not listed, refer to the next available version below.

WordPress Version: 5.9

/**
 * Trashes or deletes a comment.
 *
 * The comment is moved to Trash instead of permanently deleted unless Trash is
 * disabled, item is already in the Trash, or $force_delete is true.
 *
 * The post comment count will be updated if the comment was approved and has a
 * post ID available.
 *
 * @since 2.0.0
 *
 * @global wpdb $wpdb WordPress database abstraction object.
 *
 * @param int|WP_Comment $comment_id   Comment ID or WP_Comment object.
 * @param bool           $force_delete Whether to bypass Trash and force deletion. Default false.
 * @return bool True on success, false on failure.
 */
function wp_delete_comment($comment_id, $force_delete = false)
{
    global $wpdb;
    $comment = get_comment($comment_id);
    if (!$comment) {
        return false;
    }
    if (!$force_delete && EMPTY_TRASH_DAYS && !in_array(wp_get_comment_status($comment), array('trash', 'spam'), true)) {
        return wp_trash_comment($comment_id);
    }
    /**
     * Fires immediately before a comment is deleted from the database.
     *
     * @since 1.2.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 comment to be deleted.
     */
    do_action('delete_comment', $comment->comment_ID, $comment);
    // 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.
     */
    do_action('deleted_comment', $comment->comment_ID, $comment);
    $post_id = $comment->comment_post_ID;
    if ($post_id && 1 == $comment->comment_approved) {
        wp_update_comment_count($post_id);
    }
    clean_comment_cache($comment->comment_ID);
    /** This action is documented in wp-includes/comment.php */
    do_action('wp_set_comment_status', $comment->comment_ID, 'delete');
    wp_transition_comment_status('delete', $comment->comment_approved, $comment);
    return true;
}

WordPress Version: 5.5

/**
 * Trashes or deletes a comment.
 *
 * The comment is moved to Trash instead of permanently deleted unless Trash is
 * disabled, item is already in the Trash, or $force_delete is true.
 *
 * The post comment count will be updated if the comment was approved and has a
 * post ID available.
 *
 * @since 2.0.0
 *
 * @global wpdb $wpdb WordPress database abstraction object.
 *
 * @param int|WP_Comment $comment_id   Comment ID or WP_Comment object.
 * @param bool           $force_delete Whether to bypass Trash and force deletion. Default false.
 * @return bool True on success, false on failure.
 */
function wp_delete_comment($comment_id, $force_delete = false)
{
    global $wpdb;
    $comment = get_comment($comment_id);
    if (!$comment) {
        return false;
    }
    if (!$force_delete && EMPTY_TRASH_DAYS && !in_array(wp_get_comment_status($comment), array('trash', 'spam'), true)) {
        return wp_trash_comment($comment_id);
    }
    /**
     * Fires immediately before a comment is deleted from the database.
     *
     * @since 1.2.0
     * @since 4.9.0 Added the `$comment` parameter.
     *
     * @param int        $comment_id The comment ID.
     * @param WP_Comment $comment    The comment to be deleted.
     */
    do_action('delete_comment', $comment->comment_ID, $comment);
    // 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 int        $comment_id The comment ID.
     * @param WP_Comment $comment    The deleted comment.
     */
    do_action('deleted_comment', $comment->comment_ID, $comment);
    $post_id = $comment->comment_post_ID;
    if ($post_id && 1 == $comment->comment_approved) {
        wp_update_comment_count($post_id);
    }
    clean_comment_cache($comment->comment_ID);
    /** This action is documented in wp-includes/comment.php */
    do_action('wp_set_comment_status', $comment->comment_ID, 'delete');
    wp_transition_comment_status('delete', $comment->comment_approved, $comment);
    return true;
}

WordPress Version: 5.4

/**
 * Trashes or deletes a comment.
 *
 * The comment is moved to Trash instead of permanently deleted unless Trash is
 * disabled, item is already in the Trash, or $force_delete is true.
 *
 * The post comment count will be updated if the comment was approved and has a
 * post ID available.
 *
 * @since 2.0.0
 *
 * @global wpdb $wpdb WordPress database abstraction object.
 *
 * @param int|WP_Comment $comment_id   Comment ID or WP_Comment object.
 * @param bool           $force_delete Whether to bypass Trash and force deletion. Default is false.
 * @return bool True on success, false on failure.
 */
function wp_delete_comment($comment_id, $force_delete = false)
{
    global $wpdb;
    $comment = get_comment($comment_id);
    if (!$comment) {
        return false;
    }
    if (!$force_delete && EMPTY_TRASH_DAYS && !in_array(wp_get_comment_status($comment), array('trash', 'spam'))) {
        return wp_trash_comment($comment_id);
    }
    /**
     * Fires immediately before a comment is deleted from the database.
     *
     * @since 1.2.0
     * @since 4.9.0 Added the `$comment` parameter.
     *
     * @param int        $comment_id The comment ID.
     * @param WP_Comment $comment    The comment to be deleted.
     */
    do_action('delete_comment', $comment->comment_ID, $comment);
    // 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 int        $comment_id The comment ID.
     * @param WP_Comment $comment    The deleted comment.
     */
    do_action('deleted_comment', $comment->comment_ID, $comment);
    $post_id = $comment->comment_post_ID;
    if ($post_id && 1 == $comment->comment_approved) {
        wp_update_comment_count($post_id);
    }
    clean_comment_cache($comment->comment_ID);
    /** This action is documented in wp-includes/comment.php */
    do_action('wp_set_comment_status', $comment->comment_ID, 'delete');
    wp_transition_comment_status('delete', $comment->comment_approved, $comment);
    return true;
}

WordPress Version: 5.3

/**
 * Trashes or deletes a comment.
 *
 * The comment is moved to trash instead of permanently deleted unless trash is
 * disabled, item is already in the trash, or $force_delete is true.
 *
 * The post comment count will be updated if the comment was approved and has a
 * post ID available.
 *
 * @since 2.0.0
 *
 * @global wpdb $wpdb WordPress database abstraction object.
 *
 * @param int|WP_Comment $comment_id   Comment ID or WP_Comment object.
 * @param bool           $force_delete Whether to bypass trash and force deletion. Default is false.
 * @return bool True on success, false on failure.
 */
function wp_delete_comment($comment_id, $force_delete = false)
{
    global $wpdb;
    $comment = get_comment($comment_id);
    if (!$comment) {
        return false;
    }
    if (!$force_delete && EMPTY_TRASH_DAYS && !in_array(wp_get_comment_status($comment), array('trash', 'spam'))) {
        return wp_trash_comment($comment_id);
    }
    /**
     * Fires immediately before a comment is deleted from the database.
     *
     * @since 1.2.0
     * @since 4.9.0 Added the `$comment` parameter.
     *
     * @param int        $comment_id The comment ID.
     * @param WP_Comment $comment    The comment to be deleted.
     */
    do_action('delete_comment', $comment->comment_ID, $comment);
    // 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 int        $comment_id The comment ID.
     * @param WP_Comment $comment    The deleted comment.
     */
    do_action('deleted_comment', $comment->comment_ID, $comment);
    $post_id = $comment->comment_post_ID;
    if ($post_id && $comment->comment_approved == 1) {
        wp_update_comment_count($post_id);
    }
    clean_comment_cache($comment->comment_ID);
    /** This action is documented in wp-includes/comment.php */
    do_action('wp_set_comment_status', $comment->comment_ID, 'delete');
    wp_transition_comment_status('delete', $comment->comment_approved, $comment);
    return true;
}

WordPress Version: 4.9

/**
 * Trashes or deletes a comment.
 *
 * The comment is moved to trash instead of permanently deleted unless trash is
 * disabled, item is already in the trash, or $force_delete is true.
 *
 * The post comment count will be updated if the comment was approved and has a
 * post ID available.
 *
 * @since 2.0.0
 *
 * @global wpdb $wpdb WordPress database abstraction object.
 *
 * @param int|WP_Comment $comment_id   Comment ID or WP_Comment object.
 * @param bool           $force_delete Whether to bypass trash and force deletion. Default is false.
 * @return bool True on success, false on failure.
 */
function wp_delete_comment($comment_id, $force_delete = false)
{
    global $wpdb;
    if (!$comment = get_comment($comment_id)) {
        return false;
    }
    if (!$force_delete && EMPTY_TRASH_DAYS && !in_array(wp_get_comment_status($comment), array('trash', 'spam'))) {
        return wp_trash_comment($comment_id);
    }
    /**
     * Fires immediately before a comment is deleted from the database.
     *
     * @since 1.2.0
     * @since 4.9.0 Added the `$comment` parameter.
     *
     * @param int        $comment_id The comment ID.
     * @param WP_Comment $comment    The comment to be deleted.
     */
    do_action('delete_comment', $comment->comment_ID, $comment);
    // 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 int        $comment_id The comment ID.
     * @param WP_Comment $comment    The deleted comment.
     */
    do_action('deleted_comment', $comment->comment_ID, $comment);
    $post_id = $comment->comment_post_ID;
    if ($post_id && $comment->comment_approved == 1) {
        wp_update_comment_count($post_id);
    }
    clean_comment_cache($comment->comment_ID);
    /** This action is documented in wp-includes/comment.php */
    do_action('wp_set_comment_status', $comment->comment_ID, 'delete');
    wp_transition_comment_status('delete', $comment->comment_approved, $comment);
    return true;
}

WordPress Version: 4.4

/**
 * Trashes or deletes a comment.
 *
 * The comment is moved to trash instead of permanently deleted unless trash is
 * disabled, item is already in the trash, or $force_delete is true.
 *
 * The post comment count will be updated if the comment was approved and has a
 * post ID available.
 *
 * @since 2.0.0
 *
 * @global wpdb $wpdb WordPress database abstraction object.
 *
 * @param int|WP_Comment $comment_id   Comment ID or WP_Comment object.
 * @param bool           $force_delete Whether to bypass trash and force deletion. Default is false.
 * @return bool True on success, false on failure.
 */
function wp_delete_comment($comment_id, $force_delete = false)
{
    global $wpdb;
    if (!$comment = get_comment($comment_id)) {
        return false;
    }
    if (!$force_delete && EMPTY_TRASH_DAYS && !in_array(wp_get_comment_status($comment), array('trash', 'spam'))) {
        return wp_trash_comment($comment_id);
    }
    /**
     * Fires immediately before a comment is deleted from the database.
     *
     * @since 1.2.0
     *
     * @param int $comment_id The comment ID.
     */
    do_action('delete_comment', $comment->comment_ID);
    // 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
     *
     * @param int $comment_id The comment ID.
     */
    do_action('deleted_comment', $comment->comment_ID);
    $post_id = $comment->comment_post_ID;
    if ($post_id && $comment->comment_approved == 1) {
        wp_update_comment_count($post_id);
    }
    clean_comment_cache($comment->comment_ID);
    /** This action is documented in wp-includes/comment.php */
    do_action('wp_set_comment_status', $comment->comment_ID, 'delete');
    wp_transition_comment_status('delete', $comment->comment_approved, $comment);
    return true;
}

WordPress Version: 4.1

/**
 * Trashes or deletes a comment.
 *
 * The comment is moved to trash instead of permanently deleted unless trash is
 * disabled, item is already in the trash, or $force_delete is true.
 *
 * The post comment count will be updated if the comment was approved and has a
 * post ID available.
 *
 * @since 2.0.0
 *
 * @global wpdb $wpdb WordPress database abstraction object.
 *
 * @param int $comment_id Comment ID
 * @param bool $force_delete Whether to bypass trash and force deletion. Default is false.
 * @return bool True on success, false on failure.
 */
function wp_delete_comment($comment_id, $force_delete = false)
{
    global $wpdb;
    if (!$comment = get_comment($comment_id)) {
        return false;
    }
    if (!$force_delete && EMPTY_TRASH_DAYS && !in_array(wp_get_comment_status($comment_id), array('trash', 'spam'))) {
        return wp_trash_comment($comment_id);
    }
    /**
     * Fires immediately before a comment is deleted from the database.
     *
     * @since 1.2.0
     *
     * @param int $comment_id The comment ID.
     */
    do_action('delete_comment', $comment_id);
    // Move children up a level.
    $children = $wpdb->get_col($wpdb->prepare("SELECT comment_ID FROM {$wpdb->comments} WHERE comment_parent = %d", $comment_id));
    if (!empty($children)) {
        $wpdb->update($wpdb->comments, array('comment_parent' => $comment->comment_parent), array('comment_parent' => $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_id));
    foreach ($meta_ids as $mid) {
        delete_metadata_by_mid('comment', $mid);
    }
    if (!$wpdb->delete($wpdb->comments, array('comment_ID' => $comment_id))) {
        return false;
    }
    /**
     * Fires immediately after a comment is deleted from the database.
     *
     * @since 2.9.0
     *
     * @param int $comment_id The comment ID.
     */
    do_action('deleted_comment', $comment_id);
    $post_id = $comment->comment_post_ID;
    if ($post_id && $comment->comment_approved == 1) {
        wp_update_comment_count($post_id);
    }
    clean_comment_cache($comment_id);
    /** This action is documented in wp-includes/comment.php */
    do_action('wp_set_comment_status', $comment_id, 'delete');
    wp_transition_comment_status('delete', $comment->comment_approved, $comment);
    return true;
}

WordPress Version: 4.0

/**
 * Trashes or deletes a comment.
 *
 * The comment is moved to trash instead of permanently deleted unless trash is
 * disabled, item is already in the trash, or $force_delete is true.
 *
 * The post comment count will be updated if the comment was approved and has a
 * post ID available.
 *
 * @since 2.0.0
 * @uses $wpdb
 * @uses wp_transition_comment_status() Passes new and old comment status along with $comment object
 *
 * @param int $comment_id Comment ID
 * @param bool $force_delete Whether to bypass trash and force deletion. Default is false.
 * @return bool True on success, false on failure.
 */
function wp_delete_comment($comment_id, $force_delete = false)
{
    global $wpdb;
    if (!$comment = get_comment($comment_id)) {
        return false;
    }
    if (!$force_delete && EMPTY_TRASH_DAYS && !in_array(wp_get_comment_status($comment_id), array('trash', 'spam'))) {
        return wp_trash_comment($comment_id);
    }
    /**
     * Fires immediately before a comment is deleted from the database.
     *
     * @since 1.2.0
     *
     * @param int $comment_id The comment ID.
     */
    do_action('delete_comment', $comment_id);
    // Move children up a level.
    $children = $wpdb->get_col($wpdb->prepare("SELECT comment_ID FROM {$wpdb->comments} WHERE comment_parent = %d", $comment_id));
    if (!empty($children)) {
        $wpdb->update($wpdb->comments, array('comment_parent' => $comment->comment_parent), array('comment_parent' => $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_id));
    foreach ($meta_ids as $mid) {
        delete_metadata_by_mid('comment', $mid);
    }
    if (!$wpdb->delete($wpdb->comments, array('comment_ID' => $comment_id))) {
        return false;
    }
    /**
     * Fires immediately after a comment is deleted from the database.
     *
     * @since 2.9.0
     *
     * @param int $comment_id The comment ID.
     */
    do_action('deleted_comment', $comment_id);
    $post_id = $comment->comment_post_ID;
    if ($post_id && $comment->comment_approved == 1) {
        wp_update_comment_count($post_id);
    }
    clean_comment_cache($comment_id);
    /** This action is documented in wp-includes/comment.php */
    do_action('wp_set_comment_status', $comment_id, 'delete');
    wp_transition_comment_status('delete', $comment->comment_approved, $comment);
    return true;
}

WordPress Version: 3.9

/**
 * Trashes or deletes a comment.
 *
 * The comment is moved to trash instead of permanently deleted unless trash is
 * disabled, item is already in the trash, or $force_delete is true.
 *
 * The post comment count will be updated if the comment was approved and has a
 * post ID available.
 *
 * @since 2.0.0
 * @uses $wpdb
 * @uses wp_transition_comment_status() Passes new and old comment status along with $comment object
 *
 * @param int $comment_id Comment ID
 * @param bool $force_delete Whether to bypass trash and force deletion. Default is false.
 * @return bool True on success, false on failure.
 */
function wp_delete_comment($comment_id, $force_delete = false)
{
    global $wpdb;
    if (!$comment = get_comment($comment_id)) {
        return false;
    }
    if (!$force_delete && EMPTY_TRASH_DAYS && !in_array(wp_get_comment_status($comment_id), array('trash', 'spam'))) {
        return wp_trash_comment($comment_id);
    }
    /**
     * Fires immediately before a comment is deleted from the database.
     *
     * @since 1.2.0
     *
     * @param int $comment_id The comment ID.
     */
    do_action('delete_comment', $comment_id);
    // Move children up a level.
    $children = $wpdb->get_col($wpdb->prepare("SELECT comment_ID FROM {$wpdb->comments} WHERE comment_parent = %d", $comment_id));
    if (!empty($children)) {
        $wpdb->update($wpdb->comments, array('comment_parent' => $comment->comment_parent), array('comment_parent' => $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_id));
    foreach ($meta_ids as $mid) {
        delete_metadata_by_mid('comment', $mid);
    }
    if (!$wpdb->delete($wpdb->comments, array('comment_ID' => $comment_id))) {
        return false;
    }
    /**
     * Fires immediately after a comment is deleted from the database.
     *
     * @since 2.9.0
     *
     * @param int $comment_id The comment ID.
     */
    do_action('deleted_comment', $comment_id);
    $post_id = $comment->comment_post_ID;
    if ($post_id && $comment->comment_approved == 1) {
        wp_update_comment_count($post_id);
    }
    clean_comment_cache($comment_id);
    /**
     * Fires immediately before changing the comment's status to 'delete'.
     *
     * @since 1.5.0
     *
     * @param int    $comment_id The comment ID.
     * @param string $status     The new 'delete' comment status.
     */
    do_action('wp_set_comment_status', $comment_id, 'delete');
    wp_transition_comment_status('delete', $comment->comment_approved, $comment);
    return true;
}

WordPress Version: 3.8

/**
 * Trashes or deletes a comment.
 *
 * The comment is moved to trash instead of permanently deleted unless trash is
 * disabled, item is already in the trash, or $force_delete is true.
 *
 * The post comment count will be updated if the comment was approved and has a
 * post ID available.
 *
 * @since 2.0.0
 * @uses $wpdb
 * @uses do_action() Calls 'delete_comment' hook on comment ID
 * @uses do_action() Calls 'deleted_comment' hook on comment ID after deletion, on success
 * @uses do_action() Calls 'wp_set_comment_status' hook on comment ID with 'delete' set for the second parameter
 * @uses wp_transition_comment_status() Passes new and old comment status along with $comment object
 *
 * @param int $comment_id Comment ID
 * @param bool $force_delete Whether to bypass trash and force deletion. Default is false.
 * @return bool True on success, false on failure.
 */
function wp_delete_comment($comment_id, $force_delete = false)
{
    global $wpdb;
    if (!$comment = get_comment($comment_id)) {
        return false;
    }
    if (!$force_delete && EMPTY_TRASH_DAYS && !in_array(wp_get_comment_status($comment_id), array('trash', 'spam'))) {
        return wp_trash_comment($comment_id);
    }
    /**
     * Fires immediately before a comment is deleted from the database.
     *
     * @since 1.2.0
     *
     * @param int $comment_id The comment ID.
     */
    do_action('delete_comment', $comment_id);
    // Move children up a level.
    $children = $wpdb->get_col($wpdb->prepare("SELECT comment_ID FROM {$wpdb->comments} WHERE comment_parent = %d", $comment_id));
    if (!empty($children)) {
        $wpdb->update($wpdb->comments, array('comment_parent' => $comment->comment_parent), array('comment_parent' => $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_id));
    foreach ($meta_ids as $mid) {
        delete_metadata_by_mid('comment', $mid);
    }
    if (!$wpdb->delete($wpdb->comments, array('comment_ID' => $comment_id))) {
        return false;
    }
    /**
     * Fires immediately after a comment is deleted from the database.
     *
     * @since 2.9.0
     *
     * @param int $comment_id The comment ID.
     */
    do_action('deleted_comment', $comment_id);
    $post_id = $comment->comment_post_ID;
    if ($post_id && $comment->comment_approved == 1) {
        wp_update_comment_count($post_id);
    }
    clean_comment_cache($comment_id);
    /**
     * Fires immediately before changing the comment's status to 'delete'.
     *
     * @since 1.5.0
     *
     * @param int    $comment_id The comment ID.
     * @param string $status     The new 'delete' comment status.
     */
    do_action('wp_set_comment_status', $comment_id, 'delete');
    wp_transition_comment_status('delete', $comment->comment_approved, $comment);
    return true;
}

WordPress Version: 3.7

/**
 * Trashes or deletes a comment.
 *
 * The comment is moved to trash instead of permanently deleted unless trash is
 * disabled, item is already in the trash, or $force_delete is true.
 *
 * The post comment count will be updated if the comment was approved and has a
 * post ID available.
 *
 * @since 2.0.0
 * @uses $wpdb
 * @uses do_action() Calls 'delete_comment' hook on comment ID
 * @uses do_action() Calls 'deleted_comment' hook on comment ID after deletion, on success
 * @uses do_action() Calls 'wp_set_comment_status' hook on comment ID with 'delete' set for the second parameter
 * @uses wp_transition_comment_status() Passes new and old comment status along with $comment object
 *
 * @param int $comment_id Comment ID
 * @param bool $force_delete Whether to bypass trash and force deletion. Default is false.
 * @return bool True on success, false on failure.
 */
function wp_delete_comment($comment_id, $force_delete = false)
{
    global $wpdb;
    if (!$comment = get_comment($comment_id)) {
        return false;
    }
    if (!$force_delete && EMPTY_TRASH_DAYS && !in_array(wp_get_comment_status($comment_id), array('trash', 'spam'))) {
        return wp_trash_comment($comment_id);
    }
    do_action('delete_comment', $comment_id);
    // Move children up a level.
    $children = $wpdb->get_col($wpdb->prepare("SELECT comment_ID FROM {$wpdb->comments} WHERE comment_parent = %d", $comment_id));
    if (!empty($children)) {
        $wpdb->update($wpdb->comments, array('comment_parent' => $comment->comment_parent), array('comment_parent' => $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_id));
    foreach ($meta_ids as $mid) {
        delete_metadata_by_mid('comment', $mid);
    }
    if (!$wpdb->delete($wpdb->comments, array('comment_ID' => $comment_id))) {
        return false;
    }
    do_action('deleted_comment', $comment_id);
    $post_id = $comment->comment_post_ID;
    if ($post_id && $comment->comment_approved == 1) {
        wp_update_comment_count($post_id);
    }
    clean_comment_cache($comment_id);
    do_action('wp_set_comment_status', $comment_id, 'delete');
    wp_transition_comment_status('delete', $comment->comment_approved, $comment);
    return true;
}