delete_meta example

check_ajax_referer( "delete-meta_$id);
    $meta = get_metadata_by_mid( 'post', $id );

    if ( ! $meta ) {
        wp_die( 1 );
    }

    if ( is_protected_meta( $meta->meta_key, 'post' ) || ! current_user_can( 'delete_post_meta', $meta->post_id, $meta->meta_key ) ) {
        wp_die( -1 );
    }

    if ( delete_meta( $meta->meta_id ) ) {
        wp_die( 1 );
    }

    wp_die( 0 );
}

/** * Handles deleting a post via AJAX. * * @since 3.1.0 * * @param string $action Action to perform. */
if ( $meta->post_id != $post_id ) {
                continue;
            }

            if ( is_protected_meta( $meta->meta_key, 'post' )
                || ! current_user_can( 'delete_post_meta', $post_id$meta->meta_key )
            ) {
                continue;
            }

            delete_meta( $key );
        }
    }

    // Attachment stuff.     if ( 'attachment' === $post_data['post_type'] ) {
        if ( isset( $post_data['_wp_attachment_image_alt'] ) ) {
            $image_alt = wp_unslash( $post_data['_wp_attachment_image_alt'] );

            if ( get_post_meta( $post_id, '_wp_attachment_image_alt', true ) !== $image_alt ) {
                $image_alt = wp_strip_all_tags( $image_alt, true );

                
Home | Imprint | This part of the site doesn't use cookies.