delete_metadata_by_mid

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

WordPress Version: 6.1

/**
 * Deletes metadata by meta ID.
 *
 * @since 3.3.0
 *
 * @global wpdb $wpdb WordPress database abstraction object.
 *
 * @param string $meta_type Type of object metadata is for. Accepts 'post', 'comment', 'term', 'user',
 *                          or any other object type with an associated meta table.
 * @param int    $meta_id   ID for a specific meta row.
 * @return bool True on successful delete, false on failure.
 */
function delete_metadata_by_mid($meta_type, $meta_id)
{
    global $wpdb;
    // Make sure everything is valid.
    if (!$meta_type || !is_numeric($meta_id) || floor($meta_id) != $meta_id) {
        return false;
    }
    $meta_id = (int) $meta_id;
    if ($meta_id <= 0) {
        return false;
    }
    $table = _get_meta_table($meta_type);
    if (!$table) {
        return false;
    }
    // Object and ID columns.
    $column = sanitize_key($meta_type . '_id');
    $id_column = ('user' === $meta_type) ? 'umeta_id' : 'meta_id';
    /**
     * Short-circuits deleting metadata of a specific type by meta ID.
     *
     * The dynamic portion of the hook name, `$meta_type`, refers to the meta object type
     * (post, comment, term, user, or any other type with an associated meta table).
     * Returning a non-null value will effectively short-circuit the function.
     *
     * Possible hook names include:
     *
     *  - `delete_post_metadata_by_mid`
     *  - `delete_comment_metadata_by_mid`
     *  - `delete_term_metadata_by_mid`
     *  - `delete_user_metadata_by_mid`
     *
     * @since 5.0.0
     *
     * @param null|bool $delete  Whether to allow metadata deletion of the given type.
     * @param int       $meta_id Meta ID.
     */
    $check = apply_filters("delete_{$meta_type}_metadata_by_mid", null, $meta_id);
    if (null !== $check) {
        return (bool) $check;
    }
    // Fetch the meta and go on if it's found.
    $meta = get_metadata_by_mid($meta_type, $meta_id);
    if ($meta) {
        $object_id = (int) $meta->{$column};
        /** This action is documented in wp-includes/meta.php */
        do_action("delete_{$meta_type}_meta", (array) $meta_id, $object_id, $meta->meta_key, $meta->meta_value);
        // Old-style action.
        if ('post' === $meta_type || 'comment' === $meta_type) {
            /**
             * Fires immediately before deleting post or comment metadata of a specific type.
             *
             * The dynamic portion of the hook name, `$meta_type`, refers to the meta
             * object type (post or comment).
             *
             * Possible hook names include:
             *
             *  - `delete_postmeta`
             *  - `delete_commentmeta`
             *  - `delete_termmeta`
             *  - `delete_usermeta`
             *
             * @since 3.4.0
             *
             * @param int $meta_id ID of the metadata entry to delete.
             */
            do_action("delete_{$meta_type}meta", $meta_id);
        }
        // Run the query, will return true if deleted, false otherwise.
        $result = (bool) $wpdb->delete($table, array($id_column => $meta_id));
        // Clear the caches.
        wp_cache_delete($object_id, $meta_type . '_meta');
        /** This action is documented in wp-includes/meta.php */
        do_action("deleted_{$meta_type}_meta", (array) $meta_id, $object_id, $meta->meta_key, $meta->meta_value);
        // Old-style action.
        if ('post' === $meta_type || 'comment' === $meta_type) {
            /**
             * Fires immediately after deleting post or comment metadata of a specific type.
             *
             * The dynamic portion of the hook name, `$meta_type`, refers to the meta
             * object type (post or comment).
             *
             * Possible hook names include:
             *
             *  - `deleted_postmeta`
             *  - `deleted_commentmeta`
             *  - `deleted_termmeta`
             *  - `deleted_usermeta`
             *
             * @since 3.4.0
             *
             * @param int $meta_id Deleted metadata entry ID.
             */
            do_action("deleted_{$meta_type}meta", $meta_id);
        }
        return $result;
    }
    // Meta ID was not found.
    return false;
}

WordPress Version: 5.9

/**
 * Deletes metadata by meta ID.
 *
 * @since 3.3.0
 *
 * @global wpdb $wpdb WordPress database abstraction object.
 *
 * @param string $meta_type Type of object metadata is for. Accepts 'post', 'comment', 'term', 'user',
 *                          or any other object type with an associated meta table.
 * @param int    $meta_id   ID for a specific meta row.
 * @return bool True on successful delete, false on failure.
 */
function delete_metadata_by_mid($meta_type, $meta_id)
{
    global $wpdb;
    // Make sure everything is valid.
    if (!$meta_type || !is_numeric($meta_id) || floor($meta_id) != $meta_id) {
        return false;
    }
    $meta_id = (int) $meta_id;
    if ($meta_id <= 0) {
        return false;
    }
    $table = _get_meta_table($meta_type);
    if (!$table) {
        return false;
    }
    // Object and ID columns.
    $column = sanitize_key($meta_type . '_id');
    $id_column = ('user' === $meta_type) ? 'umeta_id' : 'meta_id';
    /**
     * Short-circuits deleting metadata of a specific type by meta ID.
     *
     * The dynamic portion of the hook name, `$meta_type`, refers to the meta object type
     * (post, comment, term, user, or any other type with an associated meta table).
     * Returning a non-null value will effectively short-circuit the function.
     *
     * Possible hook names include:
     *
     *  - `delete_post_metadata_by_mid`
     *  - `delete_comment_metadata_by_mid`
     *  - `delete_term_metadata_by_mid`
     *  - `delete_user_metadata_by_mid`
     *
     * @since 5.0.0
     *
     * @param null|bool $delete  Whether to allow metadata deletion of the given type.
     * @param int       $meta_id Meta ID.
     */
    $check = apply_filters("delete_{$meta_type}_metadata_by_mid", null, $meta_id);
    if (null !== $check) {
        return (bool) $check;
    }
    // Fetch the meta and go on if it's found.
    $meta = get_metadata_by_mid($meta_type, $meta_id);
    if ($meta) {
        $object_id = (int) $meta->{$column};
        /** This action is documented in wp-includes/meta.php */
        do_action("delete_{$meta_type}_meta", (array) $meta_id, $object_id, $meta->meta_key, $meta->meta_value);
        // Old-style action.
        if ('post' === $meta_type || 'comment' === $meta_type) {
            /**
             * Fires immediately before deleting post or comment metadata of a specific type.
             *
             * The dynamic portion of the hook name, `$meta_type`, refers to the meta
             * object type (post or comment).
             *
             * Possible hook names include:
             *
             *  - `delete_postmeta`
             *  - `delete_commentmeta`
             *  - `delete_termmeta`
             *  - `delete_usermeta`
             *
             * @since 3.4.0
             *
             * @param int $meta_id ID of the metadata entry to delete.
             */
            do_action("delete_{$meta_type}meta", $meta_id);
        }
        // Run the query, will return true if deleted, false otherwise.
        $result = (bool) $wpdb->delete($table, array($id_column => $meta_id));
        // Clear the caches.
        wp_cache_delete($object_id, $meta_type . '_meta');
        /** This action is documented in wp-includes/meta.php */
        do_action("deleted_{$meta_type}_meta", (array) $meta_id, $object_id, $meta->meta_key, $meta->meta_value);
        // Old-style action.
        if ('post' === $meta_type || 'comment' === $meta_type) {
            /**
             * Fires immediately after deleting post or comment metadata of a specific type.
             *
             * The dynamic portion of the hook name, `$meta_type`, refers to the meta
             * object type (post or comment).
             *
             * Possible hook names include:
             *
             *  - `deleted_postmeta`
             *  - `deleted_commentmeta`
             *  - `deleted_termmeta`
             *  - `deleted_usermeta`
             *
             * @since 3.4.0
             *
             * @param int $meta_ids Deleted metadata entry ID.
             */
            do_action("deleted_{$meta_type}meta", $meta_id);
        }
        return $result;
    }
    // Meta ID was not found.
    return false;
}

WordPress Version: 5.6

/**
 * Deletes metadata by meta ID.
 *
 * @since 3.3.0
 *
 * @global wpdb $wpdb WordPress database abstraction object.
 *
 * @param string $meta_type Type of object metadata is for. Accepts 'post', 'comment', 'term', 'user',
 *                          or any other object type with an associated meta table.
 * @param int    $meta_id   ID for a specific meta row.
 * @return bool True on successful delete, false on failure.
 */
function delete_metadata_by_mid($meta_type, $meta_id)
{
    global $wpdb;
    // Make sure everything is valid.
    if (!$meta_type || !is_numeric($meta_id) || floor($meta_id) != $meta_id) {
        return false;
    }
    $meta_id = (int) $meta_id;
    if ($meta_id <= 0) {
        return false;
    }
    $table = _get_meta_table($meta_type);
    if (!$table) {
        return false;
    }
    // Object and ID columns.
    $column = sanitize_key($meta_type . '_id');
    $id_column = ('user' === $meta_type) ? 'umeta_id' : 'meta_id';
    /**
     * Short-circuits deleting metadata of a specific type by meta ID.
     *
     * The dynamic portion of the hook, `$meta_type`, refers to the meta object type
     * (post, comment, term, user, or any other type with an associated meta table).
     * Returning a non-null value will effectively short-circuit the function.
     *
     * @since 5.0.0
     *
     * @param null|bool $delete  Whether to allow metadata deletion of the given type.
     * @param int       $meta_id Meta ID.
     */
    $check = apply_filters("delete_{$meta_type}_metadata_by_mid", null, $meta_id);
    if (null !== $check) {
        return (bool) $check;
    }
    // Fetch the meta and go on if it's found.
    $meta = get_metadata_by_mid($meta_type, $meta_id);
    if ($meta) {
        $object_id = (int) $meta->{$column};
        /** This action is documented in wp-includes/meta.php */
        do_action("delete_{$meta_type}_meta", (array) $meta_id, $object_id, $meta->meta_key, $meta->meta_value);
        // Old-style action.
        if ('post' === $meta_type || 'comment' === $meta_type) {
            /**
             * Fires immediately before deleting post or comment metadata of a specific type.
             *
             * The dynamic portion of the hook, `$meta_type`, refers to the meta
             * object type (post or comment).
             *
             * @since 3.4.0
             *
             * @param int $meta_id ID of the metadata entry to delete.
             */
            do_action("delete_{$meta_type}meta", $meta_id);
        }
        // Run the query, will return true if deleted, false otherwise.
        $result = (bool) $wpdb->delete($table, array($id_column => $meta_id));
        // Clear the caches.
        wp_cache_delete($object_id, $meta_type . '_meta');
        /** This action is documented in wp-includes/meta.php */
        do_action("deleted_{$meta_type}_meta", (array) $meta_id, $object_id, $meta->meta_key, $meta->meta_value);
        // Old-style action.
        if ('post' === $meta_type || 'comment' === $meta_type) {
            /**
             * Fires immediately after deleting post or comment metadata of a specific type.
             *
             * The dynamic portion of the hook, `$meta_type`, refers to the meta
             * object type (post or comment).
             *
             * @since 3.4.0
             *
             * @param int $meta_ids Deleted metadata entry ID.
             */
            do_action("deleted_{$meta_type}meta", $meta_id);
        }
        return $result;
    }
    // Meta ID was not found.
    return false;
}

WordPress Version: 5.5

/**
 * Deletes metadata by meta ID.
 *
 * @since 3.3.0
 *
 * @global wpdb $wpdb WordPress database abstraction object.
 *
 * @param string $meta_type Type of object metadata is for. Accepts 'post', 'comment', 'term', 'user',
 *                          or any other object type with an associated meta table.
 * @param int    $meta_id   ID for a specific meta row.
 * @return bool True on successful delete, false on failure.
 */
function delete_metadata_by_mid($meta_type, $meta_id)
{
    global $wpdb;
    // Make sure everything is valid.
    if (!$meta_type || !is_numeric($meta_id) || floor($meta_id) != $meta_id) {
        return false;
    }
    $meta_id = intval($meta_id);
    if ($meta_id <= 0) {
        return false;
    }
    $table = _get_meta_table($meta_type);
    if (!$table) {
        return false;
    }
    // Object and ID columns.
    $column = sanitize_key($meta_type . '_id');
    $id_column = ('user' === $meta_type) ? 'umeta_id' : 'meta_id';
    /**
     * Short-circuits deleting metadata of a specific type by meta ID.
     *
     * The dynamic portion of the hook, `$meta_type`, refers to the meta object type
     * (post, comment, term, user, or any other type with an associated meta table).
     * Returning a non-null value will effectively short-circuit the function.
     *
     * @since 5.0.0
     *
     * @param null|bool $delete  Whether to allow metadata deletion of the given type.
     * @param int       $meta_id Meta ID.
     */
    $check = apply_filters("delete_{$meta_type}_metadata_by_mid", null, $meta_id);
    if (null !== $check) {
        return (bool) $check;
    }
    // Fetch the meta and go on if it's found.
    $meta = get_metadata_by_mid($meta_type, $meta_id);
    if ($meta) {
        $object_id = (int) $meta->{$column};
        /** This action is documented in wp-includes/meta.php */
        do_action("delete_{$meta_type}_meta", (array) $meta_id, $object_id, $meta->meta_key, $meta->meta_value);
        // Old-style action.
        if ('post' === $meta_type || 'comment' === $meta_type) {
            /**
             * Fires immediately before deleting post or comment metadata of a specific type.
             *
             * The dynamic portion of the hook, `$meta_type`, refers to the meta
             * object type (post or comment).
             *
             * @since 3.4.0
             *
             * @param int $meta_id ID of the metadata entry to delete.
             */
            do_action("delete_{$meta_type}meta", $meta_id);
        }
        // Run the query, will return true if deleted, false otherwise.
        $result = (bool) $wpdb->delete($table, array($id_column => $meta_id));
        // Clear the caches.
        wp_cache_delete($object_id, $meta_type . '_meta');
        /** This action is documented in wp-includes/meta.php */
        do_action("deleted_{$meta_type}_meta", (array) $meta_id, $object_id, $meta->meta_key, $meta->meta_value);
        // Old-style action.
        if ('post' === $meta_type || 'comment' === $meta_type) {
            /**
             * Fires immediately after deleting post or comment metadata of a specific type.
             *
             * The dynamic portion of the hook, `$meta_type`, refers to the meta
             * object type (post or comment).
             *
             * @since 3.4.0
             *
             * @param int $meta_ids Deleted metadata entry ID.
             */
            do_action("deleted_{$meta_type}meta", $meta_id);
        }
        return $result;
    }
    // Meta ID was not found.
    return false;
}

WordPress Version: 5.4

/**
 * Deletes metadata by meta ID.
 *
 * @since 3.3.0
 *
 * @global wpdb $wpdb WordPress database abstraction object.
 *
 * @param string $meta_type Type of object metadata is for. Accepts 'post', 'comment', 'term', 'user',
 *                          or any other object type with an associated meta table.
 * @param int    $meta_id   ID for a specific meta row.
 * @return bool True on successful delete, false on failure.
 */
function delete_metadata_by_mid($meta_type, $meta_id)
{
    global $wpdb;
    // Make sure everything is valid.
    if (!$meta_type || !is_numeric($meta_id) || floor($meta_id) != $meta_id) {
        return false;
    }
    $meta_id = intval($meta_id);
    if ($meta_id <= 0) {
        return false;
    }
    $table = _get_meta_table($meta_type);
    if (!$table) {
        return false;
    }
    // Object and ID columns.
    $column = sanitize_key($meta_type . '_id');
    $id_column = ('user' == $meta_type) ? 'umeta_id' : 'meta_id';
    /**
     * Filters whether to delete metadata of a specific type by meta ID.
     *
     * The dynamic portion of the hook, `$meta_type`, refers to the meta
     * object type (comment, post, term, or user). Returning a non-null value
     * will effectively short-circuit the function.
     *
     * @since 5.0.0
     *
     * @param null|bool $delete  Whether to allow metadata deletion of the given type.
     * @param int       $meta_id Meta ID.
     */
    $check = apply_filters("delete_{$meta_type}_metadata_by_mid", null, $meta_id);
    if (null !== $check) {
        return (bool) $check;
    }
    // Fetch the meta and go on if it's found.
    $meta = get_metadata_by_mid($meta_type, $meta_id);
    if ($meta) {
        $object_id = (int) $meta->{$column};
        /** This action is documented in wp-includes/meta.php */
        do_action("delete_{$meta_type}_meta", (array) $meta_id, $object_id, $meta->meta_key, $meta->meta_value);
        // Old-style action.
        if ('post' == $meta_type || 'comment' == $meta_type) {
            /**
             * Fires immediately before deleting post or comment metadata of a specific type.
             *
             * The dynamic portion of the hook, `$meta_type`, refers to the meta
             * object type (post or comment).
             *
             * @since 3.4.0
             *
             * @param int $meta_id ID of the metadata entry to delete.
             */
            do_action("delete_{$meta_type}meta", $meta_id);
        }
        // Run the query, will return true if deleted, false otherwise.
        $result = (bool) $wpdb->delete($table, array($id_column => $meta_id));
        // Clear the caches.
        wp_cache_delete($object_id, $meta_type . '_meta');
        /** This action is documented in wp-includes/meta.php */
        do_action("deleted_{$meta_type}_meta", (array) $meta_id, $object_id, $meta->meta_key, $meta->meta_value);
        // Old-style action.
        if ('post' == $meta_type || 'comment' == $meta_type) {
            /**
             * Fires immediately after deleting post or comment metadata of a specific type.
             *
             * The dynamic portion of the hook, `$meta_type`, refers to the meta
             * object type (post or comment).
             *
             * @since 3.4.0
             *
             * @param int $meta_ids Deleted metadata entry ID.
             */
            do_action("deleted_{$meta_type}meta", $meta_id);
        }
        return $result;
    }
    // Meta ID was not found.
    return false;
}

WordPress Version: 5.3

/**
 * Delete meta data by meta ID
 *
 * @since 3.3.0
 *
 * @global wpdb $wpdb WordPress database abstraction object.
 *
 * @param string $meta_type Type of object metadata is for (e.g., comment, post, term, or user).
 * @param int    $meta_id   ID for a specific meta row
 * @return bool True on successful delete, false on failure.
 */
function delete_metadata_by_mid($meta_type, $meta_id)
{
    global $wpdb;
    // Make sure everything is valid.
    if (!$meta_type || !is_numeric($meta_id) || floor($meta_id) != $meta_id) {
        return false;
    }
    $meta_id = intval($meta_id);
    if ($meta_id <= 0) {
        return false;
    }
    $table = _get_meta_table($meta_type);
    if (!$table) {
        return false;
    }
    // object and id columns
    $column = sanitize_key($meta_type . '_id');
    $id_column = ('user' == $meta_type) ? 'umeta_id' : 'meta_id';
    /**
     * Filters whether to delete metadata of a specific type by meta ID.
     *
     * The dynamic portion of the hook, `$meta_type`, refers to the meta
     * object type (comment, post, term, or user). Returning a non-null value
     * will effectively short-circuit the function.
     *
     * @since 5.0.0
     *
     * @param null|bool $delete  Whether to allow metadata deletion of the given type.
     * @param int       $meta_id Meta ID.
     */
    $check = apply_filters("delete_{$meta_type}_metadata_by_mid", null, $meta_id);
    if (null !== $check) {
        return (bool) $check;
    }
    // Fetch the meta and go on if it's found.
    $meta = get_metadata_by_mid($meta_type, $meta_id);
    if ($meta) {
        $object_id = (int) $meta->{$column};
        /** This action is documented in wp-includes/meta.php */
        do_action("delete_{$meta_type}_meta", (array) $meta_id, $object_id, $meta->meta_key, $meta->meta_value);
        // Old-style action.
        if ('post' == $meta_type || 'comment' == $meta_type) {
            /**
             * Fires immediately before deleting post or comment metadata of a specific type.
             *
             * The dynamic portion of the hook, `$meta_type`, refers to the meta
             * object type (post or comment).
             *
             * @since 3.4.0
             *
             * @param int $meta_id ID of the metadata entry to delete.
             */
            do_action("delete_{$meta_type}meta", $meta_id);
        }
        // Run the query, will return true if deleted, false otherwise
        $result = (bool) $wpdb->delete($table, array($id_column => $meta_id));
        // Clear the caches.
        wp_cache_delete($object_id, $meta_type . '_meta');
        /** This action is documented in wp-includes/meta.php */
        do_action("deleted_{$meta_type}_meta", (array) $meta_id, $object_id, $meta->meta_key, $meta->meta_value);
        // Old-style action.
        if ('post' == $meta_type || 'comment' == $meta_type) {
            /**
             * Fires immediately after deleting post or comment metadata of a specific type.
             *
             * The dynamic portion of the hook, `$meta_type`, refers to the meta
             * object type (post or comment).
             *
             * @since 3.4.0
             *
             * @param int $meta_ids Deleted metadata entry ID.
             */
            do_action("deleted_{$meta_type}meta", $meta_id);
        }
        return $result;
    }
    // Meta id was not found.
    return false;
}

WordPress Version: 5.2

/**
 * Delete meta data by meta ID
 *
 * @since 3.3.0
 *
 * @global wpdb $wpdb WordPress database abstraction object.
 *
 * @param string $meta_type Type of object metadata is for (e.g., comment, post, term, or user).
 * @param int    $meta_id   ID for a specific meta row
 * @return bool True on successful delete, false on failure.
 */
function delete_metadata_by_mid($meta_type, $meta_id)
{
    global $wpdb;
    // Make sure everything is valid.
    if (!$meta_type || !is_numeric($meta_id) || floor($meta_id) != $meta_id) {
        return false;
    }
    $meta_id = intval($meta_id);
    if ($meta_id <= 0) {
        return false;
    }
    $table = _get_meta_table($meta_type);
    if (!$table) {
        return false;
    }
    // object and id columns
    $column = sanitize_key($meta_type . '_id');
    $id_column = ('user' == $meta_type) ? 'umeta_id' : 'meta_id';
    /**
     * Filters whether to delete metadata of a specific type by meta ID.
     *
     * The dynamic portion of the hook, `$meta_type`, refers to the meta
     * object type (comment, post, term, or user). Returning a non-null value
     * will effectively short-circuit the function.
     *
     * @since 5.0.0
     *
     * @param null|bool $delete  Whether to allow metadata deletion of the given type.
     * @param int       $meta_id Meta ID.
     */
    $check = apply_filters("delete_{$meta_type}_metadata_by_mid", null, $meta_id);
    if (null !== $check) {
        return (bool) $check;
    }
    // Fetch the meta and go on if it's found.
    if ($meta = get_metadata_by_mid($meta_type, $meta_id)) {
        $object_id = (int) $meta->{$column};
        /** This action is documented in wp-includes/meta.php */
        do_action("delete_{$meta_type}_meta", (array) $meta_id, $object_id, $meta->meta_key, $meta->meta_value);
        // Old-style action.
        if ('post' == $meta_type || 'comment' == $meta_type) {
            /**
             * Fires immediately before deleting post or comment metadata of a specific type.
             *
             * The dynamic portion of the hook, `$meta_type`, refers to the meta
             * object type (post or comment).
             *
             * @since 3.4.0
             *
             * @param int $meta_id ID of the metadata entry to delete.
             */
            do_action("delete_{$meta_type}meta", $meta_id);
        }
        // Run the query, will return true if deleted, false otherwise
        $result = (bool) $wpdb->delete($table, array($id_column => $meta_id));
        // Clear the caches.
        wp_cache_delete($object_id, $meta_type . '_meta');
        /** This action is documented in wp-includes/meta.php */
        do_action("deleted_{$meta_type}_meta", (array) $meta_id, $object_id, $meta->meta_key, $meta->meta_value);
        // Old-style action.
        if ('post' == $meta_type || 'comment' == $meta_type) {
            /**
             * Fires immediately after deleting post or comment metadata of a specific type.
             *
             * The dynamic portion of the hook, `$meta_type`, refers to the meta
             * object type (post or comment).
             *
             * @since 3.4.0
             *
             * @param int $meta_ids Deleted metadata entry ID.
             */
            do_action("deleted_{$meta_type}meta", $meta_id);
        }
        return $result;
    }
    // Meta id was not found.
    return false;
}

WordPress Version: 5.0

/**
 * Delete meta data by meta ID
 *
 * @since 3.3.0
 *
 * @global wpdb $wpdb WordPress database abstraction object.
 *
 * @param string $meta_type Type of object metadata is for (e.g., comment, post, term, or user).
 * @param int    $meta_id   ID for a specific meta row
 * @return bool True on successful delete, false on failure.
 */
function delete_metadata_by_mid($meta_type, $meta_id)
{
    global $wpdb;
    // Make sure everything is valid.
    if (!$meta_type || !is_numeric($meta_id) || floor($meta_id) != $meta_id) {
        return false;
    }
    $meta_id = intval($meta_id);
    if ($meta_id <= 0) {
        return false;
    }
    $table = _get_meta_table($meta_type);
    if (!$table) {
        return false;
    }
    // object and id columns
    $column = sanitize_key($meta_type . '_id');
    $id_column = ('user' == $meta_type) ? 'umeta_id' : 'meta_id';
    /**
     * Filters whether to delete metadata of a specific type by meta ID.
     *
     * The dynamic portion of the hook, `$meta_type`, refers to the meta
     * object type (comment, post, term, or user). Returning a non-null value
     * will effectively short-circuit the function.
     *
     * @since 5.0.0
     *
     * @param null|bool $delete  Whether to allow metadata deletion of the given type.
     * @param int       $meta_id Meta ID.
     */
    $check = apply_filters("delete_{$meta_type}_metadata_by_mid", null, $meta_id);
    if (null !== $check) {
        return (bool) $check;
    }
    // Fetch the meta and go on if it's found.
    if ($meta = get_metadata_by_mid($meta_type, $meta_id)) {
        $object_id = $meta->{$column};
        /** This action is documented in wp-includes/meta.php */
        do_action("delete_{$meta_type}_meta", (array) $meta_id, $object_id, $meta->meta_key, $meta->meta_value);
        // Old-style action.
        if ('post' == $meta_type || 'comment' == $meta_type) {
            /**
             * Fires immediately before deleting post or comment metadata of a specific type.
             *
             * The dynamic portion of the hook, `$meta_type`, refers to the meta
             * object type (post or comment).
             *
             * @since 3.4.0
             *
             * @param int $meta_id ID of the metadata entry to delete.
             */
            do_action("delete_{$meta_type}meta", $meta_id);
        }
        // Run the query, will return true if deleted, false otherwise
        $result = (bool) $wpdb->delete($table, array($id_column => $meta_id));
        // Clear the caches.
        wp_cache_delete($object_id, $meta_type . '_meta');
        /** This action is documented in wp-includes/meta.php */
        do_action("deleted_{$meta_type}_meta", (array) $meta_id, $object_id, $meta->meta_key, $meta->meta_value);
        // Old-style action.
        if ('post' == $meta_type || 'comment' == $meta_type) {
            /**
             * Fires immediately after deleting post or comment metadata of a specific type.
             *
             * The dynamic portion of the hook, `$meta_type`, refers to the meta
             * object type (post or comment).
             *
             * @since 3.4.0
             *
             * @param int $meta_ids Deleted metadata entry ID.
             */
            do_action("deleted_{$meta_type}meta", $meta_id);
        }
        return $result;
    }
    // Meta id was not found.
    return false;
}

WordPress Version: 4.7

/**
 * Delete meta data by meta ID
 *
 * @since 3.3.0
 *
 * @global wpdb $wpdb WordPress database abstraction object.
 *
 * @param string $meta_type Type of object metadata is for (e.g., comment, post, term, or user).
 * @param int    $meta_id   ID for a specific meta row
 * @return bool True on successful delete, false on failure.
 */
function delete_metadata_by_mid($meta_type, $meta_id)
{
    global $wpdb;
    // Make sure everything is valid.
    if (!$meta_type || !is_numeric($meta_id) || floor($meta_id) != $meta_id) {
        return false;
    }
    $meta_id = intval($meta_id);
    if ($meta_id <= 0) {
        return false;
    }
    $table = _get_meta_table($meta_type);
    if (!$table) {
        return false;
    }
    // object and id columns
    $column = sanitize_key($meta_type . '_id');
    $id_column = ('user' == $meta_type) ? 'umeta_id' : 'meta_id';
    // Fetch the meta and go on if it's found.
    if ($meta = get_metadata_by_mid($meta_type, $meta_id)) {
        $object_id = $meta->{$column};
        /** This action is documented in wp-includes/meta.php */
        do_action("delete_{$meta_type}_meta", (array) $meta_id, $object_id, $meta->meta_key, $meta->meta_value);
        // Old-style action.
        if ('post' == $meta_type || 'comment' == $meta_type) {
            /**
             * Fires immediately before deleting post or comment metadata of a specific type.
             *
             * The dynamic portion of the hook, `$meta_type`, refers to the meta
             * object type (post or comment).
             *
             * @since 3.4.0
             *
             * @param int $meta_id ID of the metadata entry to delete.
             */
            do_action("delete_{$meta_type}meta", $meta_id);
        }
        // Run the query, will return true if deleted, false otherwise
        $result = (bool) $wpdb->delete($table, array($id_column => $meta_id));
        // Clear the caches.
        wp_cache_delete($object_id, $meta_type . '_meta');
        /** This action is documented in wp-includes/meta.php */
        do_action("deleted_{$meta_type}_meta", (array) $meta_id, $object_id, $meta->meta_key, $meta->meta_value);
        // Old-style action.
        if ('post' == $meta_type || 'comment' == $meta_type) {
            /**
             * Fires immediately after deleting post or comment metadata of a specific type.
             *
             * The dynamic portion of the hook, `$meta_type`, refers to the meta
             * object type (post or comment).
             *
             * @since 3.4.0
             *
             * @param int $meta_ids Deleted metadata entry ID.
             */
            do_action("deleted_{$meta_type}meta", $meta_id);
        }
        return $result;
    }
    // Meta id was not found.
    return false;
}

WordPress Version: 4.4

/**
 * Delete meta data by meta ID
 *
 * @since 3.3.0
 *
 * @global wpdb $wpdb WordPress database abstraction object.
 *
 * @param string $meta_type Type of object metadata is for (e.g., comment, post, term, or user).
 * @param int    $meta_id   ID for a specific meta row
 * @return bool True on successful delete, false on failure.
 */
function delete_metadata_by_mid($meta_type, $meta_id)
{
    global $wpdb;
    // Make sure everything is valid.
    if (!$meta_type || !is_numeric($meta_id)) {
        return false;
    }
    $meta_id = absint($meta_id);
    if (!$meta_id) {
        return false;
    }
    $table = _get_meta_table($meta_type);
    if (!$table) {
        return false;
    }
    // object and id columns
    $column = sanitize_key($meta_type . '_id');
    $id_column = ('user' == $meta_type) ? 'umeta_id' : 'meta_id';
    // Fetch the meta and go on if it's found.
    if ($meta = get_metadata_by_mid($meta_type, $meta_id)) {
        $object_id = $meta->{$column};
        /** This action is documented in wp-includes/meta.php */
        do_action("delete_{$meta_type}_meta", (array) $meta_id, $object_id, $meta->meta_key, $meta->meta_value);
        // Old-style action.
        if ('post' == $meta_type || 'comment' == $meta_type) {
            /**
             * Fires immediately before deleting post or comment metadata of a specific type.
             *
             * The dynamic portion of the hook, `$meta_type`, refers to the meta
             * object type (post or comment).
             *
             * @since 3.4.0
             *
             * @param int $meta_id ID of the metadata entry to delete.
             */
            do_action("delete_{$meta_type}meta", $meta_id);
        }
        // Run the query, will return true if deleted, false otherwise
        $result = (bool) $wpdb->delete($table, array($id_column => $meta_id));
        // Clear the caches.
        wp_cache_delete($object_id, $meta_type . '_meta');
        /** This action is documented in wp-includes/meta.php */
        do_action("deleted_{$meta_type}_meta", (array) $meta_id, $object_id, $meta->meta_key, $meta->meta_value);
        // Old-style action.
        if ('post' == $meta_type || 'comment' == $meta_type) {
            /**
             * Fires immediately after deleting post or comment metadata of a specific type.
             *
             * The dynamic portion of the hook, `$meta_type`, refers to the meta
             * object type (post or comment).
             *
             * @since 3.4.0
             *
             * @param int $meta_ids Deleted metadata entry ID.
             */
            do_action("deleted_{$meta_type}meta", $meta_id);
        }
        return $result;
    }
    // Meta id was not found.
    return false;
}

WordPress Version: 4.3

/**
 * Delete meta data by meta ID
 *
 * @since 3.3.0
 *
 * @global wpdb $wpdb
 *
 * @param string $meta_type Type of object metadata is for (e.g., comment, post, or user)
 * @param int    $meta_id   ID for a specific meta row
 * @return bool True on successful delete, false on failure.
 */
function delete_metadata_by_mid($meta_type, $meta_id)
{
    global $wpdb;
    // Make sure everything is valid.
    if (!$meta_type || !is_numeric($meta_id)) {
        return false;
    }
    $meta_id = absint($meta_id);
    if (!$meta_id) {
        return false;
    }
    $table = _get_meta_table($meta_type);
    if (!$table) {
        return false;
    }
    // object and id columns
    $column = sanitize_key($meta_type . '_id');
    $id_column = ('user' == $meta_type) ? 'umeta_id' : 'meta_id';
    // Fetch the meta and go on if it's found.
    if ($meta = get_metadata_by_mid($meta_type, $meta_id)) {
        $object_id = $meta->{$column};
        /** This action is documented in wp-includes/meta.php */
        do_action("delete_{$meta_type}_meta", (array) $meta_id, $object_id, $meta->meta_key, $meta->meta_value);
        // Old-style action.
        if ('post' == $meta_type || 'comment' == $meta_type) {
            /**
             * Fires immediately before deleting post or comment metadata of a specific type.
             *
             * The dynamic portion of the hook, `$meta_type`, refers to the meta
             * object type (post or comment).
             *
             * @since 3.4.0
             *
             * @param int $meta_id ID of the metadata entry to delete.
             */
            do_action("delete_{$meta_type}meta", $meta_id);
        }
        // Run the query, will return true if deleted, false otherwise
        $result = (bool) $wpdb->delete($table, array($id_column => $meta_id));
        // Clear the caches.
        wp_cache_delete($object_id, $meta_type . '_meta');
        /** This action is documented in wp-includes/meta.php */
        do_action("deleted_{$meta_type}_meta", (array) $meta_id, $object_id, $meta->meta_key, $meta->meta_value);
        // Old-style action.
        if ('post' == $meta_type || 'comment' == $meta_type) {
            /**
             * Fires immediately after deleting post or comment metadata of a specific type.
             *
             * The dynamic portion of the hook, `$meta_type`, refers to the meta
             * object type (post or comment).
             *
             * @since 3.4.0
             *
             * @param int $meta_ids Deleted metadata entry ID.
             */
            do_action("deleted_{$meta_type}meta", $meta_id);
        }
        return $result;
    }
    // Meta id was not found.
    return false;
}

WordPress Version: 4.1

/**
 * Delete meta data by meta ID
 *
 * @since 3.3.0
 *
 * @param string $meta_type Type of object metadata is for (e.g., comment, post, or user)
 * @param int $meta_id ID for a specific meta row
 * @return bool True on successful delete, false on failure.
 */
function delete_metadata_by_mid($meta_type, $meta_id)
{
    global $wpdb;
    // Make sure everything is valid.
    if (!$meta_type || !is_numeric($meta_id)) {
        return false;
    }
    $meta_id = absint($meta_id);
    if (!$meta_id) {
        return false;
    }
    $table = _get_meta_table($meta_type);
    if (!$table) {
        return false;
    }
    // object and id columns
    $column = sanitize_key($meta_type . '_id');
    $id_column = ('user' == $meta_type) ? 'umeta_id' : 'meta_id';
    // Fetch the meta and go on if it's found.
    if ($meta = get_metadata_by_mid($meta_type, $meta_id)) {
        $object_id = $meta->{$column};
        /** This action is documented in wp-includes/meta.php */
        do_action("delete_{$meta_type}_meta", (array) $meta_id, $object_id, $meta->meta_key, $meta->meta_value);
        // Old-style action.
        if ('post' == $meta_type || 'comment' == $meta_type) {
            /**
             * Fires immediately before deleting post or comment metadata of a specific type.
             *
             * The dynamic portion of the hook, `$meta_type`, refers to the meta
             * object type (post or comment).
             *
             * @since 3.4.0
             *
             * @param int $meta_id ID of the metadata entry to delete.
             */
            do_action("delete_{$meta_type}meta", $meta_id);
        }
        // Run the query, will return true if deleted, false otherwise
        $result = (bool) $wpdb->delete($table, array($id_column => $meta_id));
        // Clear the caches.
        wp_cache_delete($object_id, $meta_type . '_meta');
        /** This action is documented in wp-includes/meta.php */
        do_action("deleted_{$meta_type}_meta", (array) $meta_id, $object_id, $meta->meta_key, $meta->meta_value);
        // Old-style action.
        if ('post' == $meta_type || 'comment' == $meta_type) {
            /**
             * Fires immediately after deleting post or comment metadata of a specific type.
             *
             * The dynamic portion of the hook, `$meta_type`, refers to the meta
             * object type (post or comment).
             *
             * @since 3.4.0
             *
             * @param int $meta_ids Deleted metadata entry ID.
             */
            do_action("deleted_{$meta_type}meta", $meta_id);
        }
        return $result;
    }
    // Meta id was not found.
    return false;
}

WordPress Version: 4.0

/**
 * Delete meta data by meta ID
 *
 * @since 3.3.0
 *
 * @uses get_metadata_by_mid() Calls get_metadata_by_mid() to fetch the meta key, value
 *		and object_id of the given meta_id.
 *
 * @param string $meta_type Type of object metadata is for (e.g., comment, post, or user)
 * @param int $meta_id ID for a specific meta row
 * @return bool True on successful delete, false on failure.
 */
function delete_metadata_by_mid($meta_type, $meta_id)
{
    global $wpdb;
    // Make sure everything is valid.
    if (!$meta_type || !is_numeric($meta_id)) {
        return false;
    }
    $meta_id = absint($meta_id);
    if (!$meta_id) {
        return false;
    }
    $table = _get_meta_table($meta_type);
    if (!$table) {
        return false;
    }
    // object and id columns
    $column = sanitize_key($meta_type . '_id');
    $id_column = ('user' == $meta_type) ? 'umeta_id' : 'meta_id';
    // Fetch the meta and go on if it's found.
    if ($meta = get_metadata_by_mid($meta_type, $meta_id)) {
        $object_id = $meta->{$column};
        /** This action is documented in wp-includes/meta.php */
        do_action("delete_{$meta_type}_meta", (array) $meta_id, $object_id, $meta->meta_key, $meta->meta_value);
        // Old-style action.
        if ('post' == $meta_type || 'comment' == $meta_type) {
            /**
             * Fires immediately before deleting post or comment metadata of a specific type.
             *
             * The dynamic portion of the hook, $meta_type, refers to the meta
             * object type (post or comment).
             *
             * @since 3.4.0
             *
             * @param int $meta_id ID of the metadata entry to delete.
             */
            do_action("delete_{$meta_type}meta", $meta_id);
        }
        // Run the query, will return true if deleted, false otherwise
        $result = (bool) $wpdb->delete($table, array($id_column => $meta_id));
        // Clear the caches.
        wp_cache_delete($object_id, $meta_type . '_meta');
        /** This action is documented in wp-includes/meta.php */
        do_action("deleted_{$meta_type}_meta", (array) $meta_id, $object_id, $meta->meta_key, $meta->meta_value);
        // Old-style action.
        if ('post' == $meta_type || 'comment' == $meta_type) {
            /**
             * Fires immediately after deleting post or comment metadata of a specific type.
             *
             * The dynamic portion of the hook, $meta_type, refers to the meta
             * object type (post or comment).
             *
             * @since 3.4.0
             *
             * @param int $meta_ids Deleted metadata entry ID.
             */
            do_action("deleted_{$meta_type}meta", $meta_id);
        }
        return $result;
    }
    // Meta id was not found.
    return false;
}

WordPress Version: 3.9

/**
 * Delete meta data by meta ID
 *
 * @since 3.3.0
 *
 * @uses get_metadata_by_mid() Calls get_metadata_by_mid() to fetch the meta key, value
 *		and object_id of the given meta_id.
 *
 * @param string $meta_type Type of object metadata is for (e.g., comment, post, or user)
 * @param int $meta_id ID for a specific meta row
 * @return bool True on successful delete, false on failure.
 */
function delete_metadata_by_mid($meta_type, $meta_id)
{
    global $wpdb;
    // Make sure everything is valid.
    if (!$meta_type) {
        return false;
    }
    if (!$meta_id = absint($meta_id)) {
        return false;
    }
    if (!$table = _get_meta_table($meta_type)) {
        return false;
    }
    // object and id columns
    $column = sanitize_key($meta_type . '_id');
    $id_column = ('user' == $meta_type) ? 'umeta_id' : 'meta_id';
    // Fetch the meta and go on if it's found.
    if ($meta = get_metadata_by_mid($meta_type, $meta_id)) {
        $object_id = $meta->{$column};
        /** This action is documented in wp-includes/meta.php */
        do_action("delete_{$meta_type}_meta", (array) $meta_id, $object_id, $meta->meta_key, $meta->meta_value);
        // Old-style action.
        if ('post' == $meta_type || 'comment' == $meta_type) {
            /**
             * Fires immediately before deleting post or comment metadata of a specific type.
             *
             * The dynamic portion of the hook, $meta_type, refers to the meta
             * object type (post or comment).
             *
             * @since 3.4.0
             *
             * @param int $meta_id ID of the metadata entry to delete.
             */
            do_action("delete_{$meta_type}meta", $meta_id);
        }
        // Run the query, will return true if deleted, false otherwise
        $result = (bool) $wpdb->delete($table, array($id_column => $meta_id));
        // Clear the caches.
        wp_cache_delete($object_id, $meta_type . '_meta');
        /** This action is documented in wp-includes/meta.php */
        do_action("deleted_{$meta_type}_meta", (array) $meta_id, $object_id, $meta->meta_key, $meta->meta_value);
        // Old-style action.
        if ('post' == $meta_type || 'comment' == $meta_type) {
            /**
             * Fires immediately after deleting post or comment metadata of a specific type.
             *
             * The dynamic portion of the hook, $meta_type, refers to the meta
             * object type (post or comment).
             *
             * @since 3.4.0
             *
             * @param int $meta_ids Deleted metadata entry ID.
             */
            do_action("deleted_{$meta_type}meta", $meta_id);
        }
        return $result;
    }
    // Meta id was not found.
    return false;
}

WordPress Version: 3.7

/**
 * Delete meta data by meta ID
 *
 * @since 3.3.0
 *
 * @uses get_metadata_by_mid() Calls get_metadata_by_mid() to fetch the meta key, value
 *		and object_id of the given meta_id.
 *
 * @param string $meta_type Type of object metadata is for (e.g., comment, post, or user)
 * @param int $meta_id ID for a specific meta row
 * @return bool True on successful delete, false on failure.
 */
function delete_metadata_by_mid($meta_type, $meta_id)
{
    global $wpdb;
    // Make sure everything is valid.
    if (!$meta_type) {
        return false;
    }
    if (!$meta_id = absint($meta_id)) {
        return false;
    }
    if (!$table = _get_meta_table($meta_type)) {
        return false;
    }
    // object and id columns
    $column = sanitize_key($meta_type . '_id');
    $id_column = ('user' == $meta_type) ? 'umeta_id' : 'meta_id';
    // Fetch the meta and go on if it's found.
    if ($meta = get_metadata_by_mid($meta_type, $meta_id)) {
        $object_id = $meta->{$column};
        do_action("delete_{$meta_type}_meta", (array) $meta_id, $object_id, $meta->meta_key, $meta->meta_value);
        // Old-style action.
        if ('post' == $meta_type || 'comment' == $meta_type) {
            do_action("delete_{$meta_type}meta", $meta_id);
        }
        // Run the query, will return true if deleted, false otherwise
        $result = (bool) $wpdb->delete($table, array($id_column => $meta_id));
        // Clear the caches.
        wp_cache_delete($object_id, $meta_type . '_meta');
        do_action("deleted_{$meta_type}_meta", (array) $meta_id, $object_id, $meta->meta_key, $meta->meta_value);
        // Old-style action.
        if ('post' == $meta_type || 'comment' == $meta_type) {
            do_action("deleted_{$meta_type}meta", $meta_id);
        }
        return $result;
    }
    // Meta id was not found.
    return false;
}