Last active
September 26, 2024 17:02
-
-
Save JoelLisenby/85bb9dd5ad8572374c364fbceb164863 to your computer and use it in GitHub Desktop.
WordPress vs WPengine Proxy Function for Plugin Updates
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 to functions.php or your own plugin | |
add_filter('http_request_args', 'apply_proxy_for_updates', 10, 2); | |
function apply_proxy_for_updates($http_args, $url) { | |
// Check if the URL is for an update check or download | |
if (strpos($url, 'wordpress.org') !== false) { | |
$http_args['proxy'] = array( | |
'host' => 'your.proxy.server', | |
'port' => 'proxy_port_number', | |
// Add username and password if your proxy requires authentication | |
'username' => 'your_username', | |
'password' => 'your_password', | |
); | |
} | |
return $http_args; | |
} | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment