The get_delete_post_link WordPress PHP filter allows you to modify the delete link for a specific post.
Usage
add_filter('get_delete_post_link', 'your_custom_function', 10, 3);
function your_custom_function($link, $post_id, $force_delete) {
    // your custom code here
    return $link;
}
Parameters
- $link(string) – The delete link.
- $post_id(int) – Post ID.
- $force_delete(bool) – Whether to bypass the Trash and force deletion. Default false.
More information
See WordPress Developer Resources: get_delete_post_link
Examples
Change the delete link to a custom URL
Modify the delete link to use a custom URL.
add_filter('get_delete_post_link', 'change_delete_post_link', 10, 3);
function change_delete_post_link($link, $post_id, $force_delete) {
    return "https://example.com/delete-post/{$post_id}";
}
Add a confirmation message to the delete link
Add a JavaScript confirmation message when clicking the delete link.
add_filter('get_delete_post_link', 'add_confirm_message', 10, 3);
function add_confirm_message($link, $post_id, $force_delete) {
    return $link . "\" onclick=\"return confirm('Are you sure you want to delete this post?');";
}
Force delete for specific post types
Force delete for posts with a specific custom post type.
add_filter('get_delete_post_link', 'force_delete_custom_post_type', 10, 3);
function force_delete_custom_post_type($link, $post_id, $force_delete) {
    $post_type = get_post_type($post_id);
    if ('custom_post_type' === $post_type) {
        $force_delete = true;
    }
    return $link;
}
Change the delete link for posts with a specific tag
Modify the delete link for posts with a specific tag.
add_filter('get_delete_post_link', 'change_delete_link_for_tagged_posts', 10, 3);
function change_delete_link_for_tagged_posts($link, $post_id, $force_delete) {
    if (has_tag('special-tag', $post_id)) {
        return "https://example.com/special-delete/{$post_id}";
    }
    return $link;
}
Disable delete link for specific user roles
Disable the delete link for posts created by authors with a specific user role.
add_filter('get_delete_post_link', 'disable_delete_link_for_user_role', 10, 3);
function disable_delete_link_for_user_role($link, $post_id, $force_delete) {
    $post_author = get_post_field('post_author', $post_id);
    $user = get_user_by('id', $post_author);
    if (in_array('specific_role', $user->roles)) {
        return '';
    }
    return $link;
}