@topher1kenobe might want to refactor this a bit, like:

```php
$post_type = get_post_type_object( get_post( $post_id )->post_type );
if ( ! current_user_can( $post_type->cap->edit_post, $post_id ) ) {
    return;
}
```