So the problem is with nonce..WP is checking for the nonce with param name = _wpnonce and pre-hash value to be in this format (without brackets of course ) [ ‘trash-‘ . $post->post_type . ‘_’ . $post->ID ]
change this line of code in function provided above by adanaahmad
$delLink = wp_nonce_url( get_bloginfo('wpurl') . "/wp-admin/post.php?action=delete&post=" . $post->ID, 'delete-post_' . $post->ID);
to {Changed nonce and action=trash}
$delLink = wp_nonce_url( get_bloginfo('wpurl') . "/wp-admin/post.php?action=trash&post=" . $post->ID, 'trash-' . $post->post_type . '_' . $post->ID);
So your function becomes ..
function wp_delete_post_link($link = 'Delete This', $before = '', $after = '') {
global $post;
if ( $post->post_type == 'page' ) {
if ( !current_user_can( 'edit_page', $post->ID ) )
return;
} else {
if ( !current_user_can( 'edit_post', $post->ID ) )
return;
}
$message = "Are your sure you want to delete ".get_the_title($post->ID)." ?";
$delLink = wp_nonce_url( get_bloginfo('wpurl') . "/wp-admin/post.php?action=trash&post=" . $post->ID, 'trash-' . $post->post_type . '_' . $post->ID);
$link = "<a href='" . $delLink . "' title="Delete" />".$link."";
echo $before . $link . $after;
}