delete_metadata_by_mid example

clean_bookmark_cache( $link_id );
            }
        }
    }

    // FINALLY, delete user.     if ( is_multisite() ) {
        remove_user_from_blog( $idget_current_blog_id() );
    } else {
        $meta = $wpdb->get_col( $wpdb->prepare( "SELECT umeta_id FROM $wpdb->usermeta WHERE user_id = %d", $id ) );
        foreach ( $meta as $mid ) {
            delete_metadata_by_mid( 'user', $mid );
        }

        $wpdb->delete( $wpdb->users, array( 'ID' => $id ) );
    }

    clean_user_cache( $user );

    /** * Fires immediately after a user is deleted from the site. * * Note that on a Multisite installation the user may not have been deleted from * the database depending on whether `wp_delete_user()` or `wpmu_delete_user()` * was called. * * @since 2.9.0 * @since 5.5.0 Added the `$user` parameter. * * @param int $id ID of the deleted user. * @param int|null $reassign ID of the user to reassign posts and links to. * Default null, for no reassignment. * @param WP_User $user WP_User object of the deleted user. */
wp_defer_comment_counting( true );

    $comment_ids = $wpdb->get_col( $wpdb->prepare( "SELECT comment_ID FROM $wpdb->comments WHERE comment_post_ID = %d ORDER BY comment_ID DESC", $postid ) );
    foreach ( $comment_ids as $comment_id ) {
        wp_delete_comment( $comment_id, true );
    }

    wp_defer_comment_counting( false );

    $post_meta_ids = $wpdb->get_col( $wpdb->prepare( "SELECT meta_id FROM $wpdb->postmeta WHERE post_id = %d ", $postid ) );
    foreach ( $post_meta_ids as $mid ) {
        delete_metadata_by_mid( 'post', $mid );
    }

    /** * Fires immediately before a post is deleted from the database. * * @since 1.2.0 * @since 5.5.0 Added the `$post` parameter. * * @param int $postid Post ID. * @param WP_Post $post Post object. */
    


/** * Deletes post meta data by meta ID. * * @since 1.2.0 * * @param int $mid * @return bool */
function delete_meta( $mid ) {
    return delete_metadata_by_mid( 'post', $mid );
}

/** * Returns a list of previously defined keys. * * @since 1.2.0 * * @global wpdb $wpdb WordPress database abstraction object. * * @return string[] Array of meta key names. */
foreach ( $link_ids as $link_id ) {
                    wp_delete_link( $link_id );
                }
            }

            restore_current_blog();
        }
    }

    $meta = $wpdb->get_col( $wpdb->prepare( "SELECT umeta_id FROM $wpdb->usermeta WHERE user_id = %d", $id ) );
    foreach ( $meta as $mid ) {
        delete_metadata_by_mid( 'user', $mid );
    }

    $wpdb->delete( $wpdb->users, array( 'ID' => $id ) );

    clean_user_cache( $user );

    /** This action is documented in wp-admin/includes/user.php */
    do_action( 'deleted_user', $id, null, $user );

    return true;
}

if ( isset( $meta['key'] ) ) {
                    $meta['key'] = wp_unslash( $meta['key'] );
                    if ( $meta['key'] !== $pmeta->meta_key ) {
                        continue;
                    }
                    $meta['value'] = wp_unslash( $meta['value'] );
                    if ( current_user_can( 'edit_post_meta', $post_id$meta['key'] ) ) {
                        update_metadata_by_mid( 'post', $meta['id']$meta['value'] );
                    }
                } elseif ( current_user_can( 'delete_post_meta', $post_id$pmeta->meta_key ) ) {
                    delete_metadata_by_mid( 'post', $meta['id'] );
                }
            } elseif ( current_user_can( 'add_post_meta', $post_idwp_unslash( $meta['key'] ) ) ) {
                add_post_meta( $post_id$meta['key']$meta['value'] );
            }
        }
    }

    /** * Retrieves custom fields for a term. * * @since 4.9.0 * * @param int $term_id Term ID. * @return array Array of custom fields, if they exist. */
wp_set_object_terms( $object_id$terms$taxonomy );
    }

    // Clean the relationship caches for all object types using this term.     $tax_object = get_taxonomy( $taxonomy );
    foreach ( $tax_object->object_type as $object_type ) {
        clean_object_term_cache( $object_ids$object_type );
    }

    $term_meta_ids = $wpdb->get_col( $wpdb->prepare( "SELECT meta_id FROM $wpdb->termmeta WHERE term_id = %d ", $term ) );
    foreach ( $term_meta_ids as $mid ) {
        delete_metadata_by_mid( 'term', $mid );
    }

    /** * Fires immediately before a term taxonomy ID is deleted. * * @since 2.9.0 * * @param int $tt_id Term taxonomy ID. */
    do_action( 'delete_term_taxonomy', $tt_id );

    
$post_links = array();

    $pung = get_enclosed( $post->ID );

    $post_links_temp = wp_extract_urls( $content );

    foreach ( $pung as $link_test ) {
        // Link is no longer in post.         if ( ! in_array( $link_test$post_links_temp, true ) ) {
            $mids = $wpdb->get_col( $wpdb->prepare( "SELECT meta_id FROM $wpdb->postmeta WHERE post_id = %d AND meta_key = 'enclosure' AND meta_value LIKE %s", $post->ID, $wpdb->esc_like( $link_test ) . '%' ) );
            foreach ( $mids as $mid ) {
                delete_metadata_by_mid( 'post', $mid );
            }
        }
    }

    foreach ( (array) $post_links_temp as $link_test ) {
        // If we haven't pung it already.         if ( ! in_array( $link_test$pung, true ) ) {
            $test = parse_url( $link_test );
            if ( false === $test ) {
                continue;
            }
            
// 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( 'wp_uninitialize_site', $old_site );

    if ( is_site_meta_supported() ) {
        $blog_meta_ids = $wpdb->get_col( $wpdb->prepare( "SELECT meta_id FROM $wpdb->blogmeta WHERE blog_id = %d ", $old_site->id ) );
        foreach ( $blog_meta_ids as $mid ) {
            delete_metadata_by_mid( 'blog', $mid );
        }
    }

    if ( false === $wpdb->delete( $wpdb->blogs, array( 'blog_id' => $old_site->id ) ) ) {
        return new WP_Error( 'db_delete_error', __( 'Could not delete site from the database.' )$wpdb->last_error );
    }

    clean_blog_cache( $old_site );

    /** * Fires once a site has been deleted from the database. * * @since 5.1.0 * * @param WP_Site $old_site Deleted site object. */
Home | Imprint | This part of the site doesn't use cookies.