Last active
September 26, 2024 10:11
-
-
Save alewolf/c3085451de1c2b482450601e94a2bf5d to your computer and use it in GitHub Desktop.
Block outgoing requests to api.wordpress.org
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
<?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