@maxoud, you’re definitely right.
A better hack would be to hook wp_loaded action
I made a quite satisfying attempt
add_action( 'wp_loaded', 'wp_loaded2',1 );
function wp_loaded2(){
global $pagenow;
if ( is_admin() && ! is_user_logged_in() && ! defined( 'DOING_AJAX' ) && $pagenow !== 'admin-post.php' ) {
global $wp_query;
$wp_query->set_404();
status_header( 404 );
get_template_part( 404 );
exit();
}
}
Hi, I made an hack to the plugin on my local site in order to display 404 page when wp-admin is requested.
I replaced the line
wp_die( __( 'This has been disabled', 'wps-hide-login' ), 403 );
in wp_loaded() function with
global $wp_query;
$wp_query->set_404();
status_header( 404 );
get_template_part( 404 );
exit();
I’m not a wordpress expert but it seems to work