Proxy support
-
Hi
I’ve noticed that this plugin does not support HTTP proxies such as Squid.
In restricted environments with limited outgoing connectivity this is a problem because the plugin doesn’t work. Moreover if the outgoing traffic to https:/graphs.facebook.com is silently dropped by a firewall it will additionally cause a very slow site because the connections make the page hang.
Attached is a patch for version 2.4 that adds proxy support by means of picking up the settings that people have in their wp-config.php.--- custom-facebook-feed.php 2016-04-08 16:19:14.000000000 +0200 +++ custom-facebook-feed.proxy-ok.php 2016-04-08 16:19:52.000000000 +0200 @@ -1548,6 +1548,20 @@ //Use cURL if(is_callable('curl_init')){ $ch = curl_init(); + // Use global proxy settings + if (defined('WP_PROXY_HOST')) { + curl_setopt($ch, CURLOPT_PROXY, WP_PROXY_HOST); + } + if (defined('WP_PROXY_PORT')) { + curl_setopt($ch, CURLOPT_PROXYPORT, WP_PROXY_PORT); + } + if (defined('WP_PROXY_USERNAME')){ + $auth = WP_PROXY_USERNAME; + if (defined('WP_PROXY_PASSWORD')){ + $auth .= ':' . WP_PROXY_PASSWORD; + } + curl_setopt($ch, CURLOPT_PROXYUSERPWD, $auth); + } curl_setopt($ch, CURLOPT_URL, $url); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt($ch, CURLOPT_TIMEOUT, 20); @@ -1575,6 +1589,20 @@ //Auto detect if(is_callable('curl_init')){ $ch = curl_init(); + // Use global proxy settings + if (defined('WP_PROXY_HOST')) { + curl_setopt($ch, CURLOPT_PROXY, WP_PROXY_HOST); + } + if (defined('WP_PROXY_PORT')) { + curl_setopt($ch, CURLOPT_PROXYPORT, WP_PROXY_PORT); + } + if (defined('WP_PROXY_USERNAME')){ + $auth = WP_PROXY_USERNAME; + if (defined('WP_PROXY_PASSWORD')){ + $auth .= ':' . WP_PROXY_PASSWORD; + } + curl_setopt($ch, CURLOPT_PROXYUSERPWD, $auth); + } curl_setopt($ch, CURLOPT_URL, $url); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt($ch, CURLOPT_TIMEOUT, 20);
Viewing 3 replies - 1 through 3 (of 3 total)
Viewing 3 replies - 1 through 3 (of 3 total)
The topic ‘Proxy support’ is closed to new replies.