add_action( 'init', function() {
$ip = ( ! empty( $_SERVER['HTTP_CLIENT_IP'] ) ) ? $_SERVER['HTTP_CLIENT_IP'] : $_SERVER['REMOTE_ADDR'];
if ( '111.111.111.111' != $ip ) {
die();
}
});
Restrict all site access to a specific IP address
This post brought to you by RocketGeek, ButlerBlog, and the following: