check_admin_referer( 'media-form'
);
$post_id = 0;
if ( isset( $_REQUEST['post_id'
] ) ) { $post_id =
absint( $_REQUEST['post_id'
] );
if ( !
get_post( $post_id ) || !
current_user_can( 'edit_post',
$post_id ) ) { $post_id = 0;
}}$id =
media_handle_upload( 'async-upload',
$post_id );
if ( is_wp_error( $id ) ) { printf( '<div class="error-div error">%s <strong>%s</strong><br />%s</div>',
sprintf( '<button type="button" class="dismiss button-link" onclick="jQuery(this).parents(\'div.media-item\').slideUp(200, function(){jQuery(this).remove();});">%s</button>',
__( 'Dismiss'
) ),
sprintf( /* translators: %s: Name of the file that failed to upload. */
__( '“%s” has failed to upload.'
),
esc_html( $_FILES['async-upload'
]['name'
] ) ),