Website Settings

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

Account Settings

Winkelwagen

De winkelwagen is nog leeg

Restrict wordpress api

Snippet

Omschrijving

// Disables WordPress Rest API for external requests
//————————————————–
function restrict_rest_api_to_localhost() {
$whitelist = array(‘127.0.0.1’, “::1”, “111.111.111.11”);

$whitelistplugins = array(‘contact-form-7’);
$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 Software1
Particle Snippet in Boilerplate1

Relations

ItemType

Pointing items

ItemTypeCategoryTags
Home