The following code will return “ugly” page like this:
|
//case where someone attempting to reach wp-admin if (is_admin() && !is_user_logged_in() && !defined('DOING_AJAX') && basename( $_SERVER["SCRIPT_FILENAME"] ) !== 'admin-post.php'){ //Fix to prevent fatal error caused by some themes and Yoast SEO do_action('aiowps_before_wp_die_renamed_login'); wp_die( __( 'Not available.', 'all-in-one-wp-security-and-firewall' ), 403 ); } |
Since we have our own 404 page, why not we use it? Add the following code to redirect it to our theme 404 page.
|
//case where someone attempting to reach wp-admin if (is_admin() && !is_user_logged_in() && !defined('DOING_AJAX') && base name( $_SERVER["SCRIPT_FILENAME"] ) !== 'admin-post.php'){ //Fix to prevent fatal error caused by some themes and Yoast SEO do_action('aiowps_before_wp_die_renamed_login'); //wp_die( __( 'Not Available.', 'all-in-one-wp-security-and-firewall ' ), 404 ); global $wp_query; $wp_query->set_404(); status_header( 404 ); get_template_part( 404 ); exit(); } |
and now for security reason, whoever request to the restricted page will get our beautiful 404 page.