Skip to content

Instantly share code, notes, and snippets.

@JoelLisenby
Last active September 26, 2024 17:02

Revisions

  1. JoelLisenby revised this gist Sep 26, 2024. 1 changed file with 4 additions and 12 deletions.
    16 changes: 4 additions & 12 deletions wpe_proxy.php
    Original file line number Diff line number Diff line change
    @@ -1,24 +1,16 @@
    <?php
    // Add to functions.php or your own plugin

    define('WP_PROXY_HOST', 'your.proxy.server');
    define('WP_PROXY_PORT', 'proxy_port_number');
    define('WP_PROXY_USERNAME', 'your_username');
    define('WP_PROXY_PASSWORD', 'your_password');

    // Optional, if you need to bypass proxy for local addresses
    // define('WP_PROXY_BYPASS_HOSTS', 'localhost, www.example.com');

    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' => WP_PROXY_HOST,
    'port' => WP_PROXY_PORT,
    'host' => 'your.proxy.server',
    'port' => 'proxy_port_number',
    // Add username and password if your proxy requires authentication
    'username' => WP_PROXY_USERNAME,
    'password' => WP_PROXY_PASSWORD,
    'username' => 'your_username',
    'password' => 'your_password',
    );
    }
    return $http_args;
  2. JoelLisenby revised this gist Sep 26, 2024. 1 changed file with 4 additions and 4 deletions.
    8 changes: 4 additions & 4 deletions wpe_proxy.php
    Original file line number Diff line number Diff line change
    @@ -14,11 +14,11 @@ 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',
    'host' => WP_PROXY_HOST,
    'port' => WP_PROXY_PORT,
    // Add username and password if your proxy requires authentication
    'username' => 'your_username',
    'password' => 'your_password',
    'username' => WP_PROXY_USERNAME,
    'password' => WP_PROXY_PASSWORD,
    );
    }
    return $http_args;
  3. JoelLisenby created this gist Sep 26, 2024.
    27 changes: 27 additions & 0 deletions wpe_proxy.php
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,27 @@
    <?php
    // Add to functions.php or your own plugin

    define('WP_PROXY_HOST', 'your.proxy.server');
    define('WP_PROXY_PORT', 'proxy_port_number');
    define('WP_PROXY_USERNAME', 'your_username');
    define('WP_PROXY_PASSWORD', 'your_password');

    // Optional, if you need to bypass proxy for local addresses
    // define('WP_PROXY_BYPASS_HOSTS', 'localhost, www.example.com');

    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;
    }

    ?>