function wporg_frontend_delete_link() {
$url = add_query_arg(
array(
'action'=>'wporg_frontend_delete',
'post'=>get_the_ID();
),
home_url(),
);
echo "<a href="{$url}">Delete</a>";
}
if ( isset($_REQUEST['action']) && $_REQUEST['action']=='wporg_frontend_delete' ) {
add_action('init','wporg_frontend_delete_post');
}
function wporg_frontend_delete_post() {
// Get the ID of the post.
$post_id = ( isset( $_REQUEST['post'] ) ? get_post( (int) $_REQUEST['post'] ) : false;
// No post? Oh well..
if ( empty($post_id) )
return;
// Delete post
wp_trash_post( $post_id );
// Redirect to admin page
$redirect = admin_url('edit.php');
wp_safe_redirect( $redirect );
exit;
}