Skip to content

Instantly share code, notes, and snippets.

@alewolf
Last active September 26, 2024 10:11
Show Gist options
  • Save alewolf/c3085451de1c2b482450601e94a2bf5d to your computer and use it in GitHub Desktop.
Save alewolf/c3085451de1c2b482450601e94a2bf5d to your computer and use it in GitHub Desktop.
Block outgoing requests to api.wordpress.org
<?php
add_filter('pre_http_request', 'block_blacklisted_domains', 10, 3);
function block_blacklisted_domains($preempt, $r, $url) {
$blacklisted_domains = array(
'api.wordpress.org',
);
foreach ($blacklisted_domains as $domain) {
if (strpos($url, $domain) !== false) {
// error_log('Blocked HTTP request to: ' . $url); // Optional: log the blocked request
return true;
}
}
return $preempt;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment