Adds Proxy support to the WordPress HTTP API.

There are caveats to proxy support. It requires that defines be made in the wp-config.php file to enable proxy support. There are also a few filters that plugins can hook into for some of the constants.

The constants are as follows:

  1. WP_PROXY_HOST - Enable proxy support and host for connecting.
  2. WP_PROXY_PORT - Proxy port for connection. No default, must be defined.
  3. WP_PROXY_USERNAME - Proxy username, if it requires authentication.
  4. WP_PROXY_PASSWORD - Proxy password, if it requires authentication.
  5. WP_PROXY_BYPASS_HOSTS - Will prevent the hosts in this list from going through the proxy. You do not need to have localhost and the blog host in this list, because they will not be passed through the proxy. The list should be presented in a comma separated list

An example can be as seen below. define('WP_PROXY_HOST', '192.168.84.101'); define('WP_PROXY_PORT', '8080'); define('WP_PROXY_BYPASS_HOSTS', 'localhost, www.example.com');

link Proxy support ticket in WordPress.
since 2.8
package WordPress

 Methods

Retrieve authentication string for proxy authentication.

authentication() : string
since 2.8

Returns

string

Retrieve header string for proxy authentication.

authentication_header() : string
since 2.8

Returns

string

Retrieve the host for the proxy server.

host() : string
since 2.8

Returns

string

Whether proxy connection should be used.

is_enabled() : boolean
since 2.8
use WP_PROXY_HOST
use WP_PROXY_PORT

Returns

boolean

Retrieve the password for proxy authentication.

password() : string
since 2.8

Returns

string

Retrieve the port for the proxy server.

port() : string
since 2.8

Returns

string

Whether URL should be sent through the proxy server.

send_through_proxy(string $uri) : boolean

We want to keep localhost and the blog URL from being sent through the proxy server, because some proxies can not handle this. We also have the constant available for defining other hosts that won't be sent through the proxy.

uses
since unknown

Parameters

$uri

string

URI to check.

Returns

booleanTrue, to send through the proxy and false if, the proxy should not be used.

Whether authentication should be used.

use_authentication() : boolean
since 2.8
use WP_PROXY_USERNAME
use WP_PROXY_PASSWORD

Returns

boolean

Retrieve the username for proxy authentication.

username() : string
since 2.8

Returns

string