Custom post type: Disable single page, but keep archive

I’ve ‘fixed’ my problem with the code below. This is a function that checks the post-type settings. If query_var has been set to false, the view button is removed from the post-type archive in the back-end.

For my use-case, this solves the problem. There are no links to the posts anymore.

The reason why both post_row_actions and page_row_actions is being used, is because post-types with hierarchical set to false are running through the first one, otherwise trough the second one.

function modify_list_row_actions( $actions, $post ) {
    // Retrieve the post-type object
    $post_type_object = get_post_type_object(get_post_type($post));

    // check if query_var has been set to 'false'
    if ($post_type_object->query_var == false) {
        // if so, removing the 'view' link
        unset($actions['view']);
    }

    return $actions;
}
add_filter( 'post_row_actions', 'modify_list_row_actions', 10, 2);
add_filter( 'page_row_actions', 'modify_list_row_actions', 10, 2);