WordPress restriction to the whole website

This can be done as concisely as follows (in your theme functions.php or a plugin):

function wpse_231970_lockdown() {
    if ( ! is_user_logged_in() ) {
        global $wp;

        /**
         * Redirect to login page with redirect back to current request.
         */
        wp_redirect( wp_login_url( $wp->request ) );
        exit;
    }
}

add_action( 'template_redirect', 'wpse_231970_lockdown' );