Website Settings

Dondere modus
Hoog contrast
Font grootte
Lees pagina-inhoud
Afdrukken
  • Het is 13-09-2026 en week 37 in de Herfst .

Account Settings

Winkelwagen

De winkelwagen is nog leeg

Disable rest api function

Snippet

Omschrijving

/**
* Disables WordPress Rest API for external requests
* Change whitelist plugins when plugins need to use the REST API
*/
function restrict_rest_api_to_localhost() {
$whitelist = array(‘127.0.0.1’, “::1”);

$whitelistplugins = array(‘contact-form-7’, ‘redirection’);

$request = $_SERVER[‘REQUEST_URI’];
$die = true;

if ($request) {
foreach ($whitelistplugins as $plugin) {
if (!empty(strpos($request, $plugin))) {
$die = false;
}
}
}

if(!in_array($_SERVER[‘REMOTE_ADDR’], $whitelist) && $die){
die(‘REST API is disabled.’);
}
}
add_action( ‘rest_api_init’, ‘restrict_rest_api_to_localhost’, 1 );

Snippet

FieldValue
Snippet Status
Snippet Description
Snippet Type Code
Snippet URL
Snippet Content
Snippet Content CSS
Snippet Content HTML
Snippet Content JS
Snippet Content PHP
Particle Snippet in Software
Particle Snippet in Boilerplate

Relations

ItemType

Pointing items

ItemTypeCategoryTags
Home