Skip to content

Instantly share code, notes, and snippets.

@heldervilela
Created April 30, 2018 09:08
Show Gist options
  • Save heldervilela/475ae85e973cd3d8ea692596914b8fcb to your computer and use it in GitHub Desktop.
Save heldervilela/475ae85e973cd3d8ea692596914b8fcb to your computer and use it in GitHub Desktop.
Disables WordPress Rest API for external requests
/**
* Disables WordPress Rest API for external requests
*
* @since 1.0.0
* @access public
*
* @return void
*/
add_action( 'rest_api_init', function() {
$whitelist = array('127.0.0.1', "::1");
if(!in_array($_SERVER['REMOTE_ADDR'], $whitelist)){
die('REST API is disabled.');
}
}, 1 );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment