Created
April 30, 2018 09:08
-
-
Save heldervilela/475ae85e973cd3d8ea692596914b8fcb to your computer and use it in GitHub Desktop.
Disables WordPress Rest API for external requests
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* 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