WordPress.org

Codex

Interested in functions, hooks, classes, or methods? Check out the new WordPress Code Reference!

Plugin API/Filter Reference/wp http accept encoding

Description

The *wp_http_accept_encoding* filter works with the HTTP API methods to set allowed compression encoding when making external HTTP calls.

Usage

When the 'wp_http_accept_encoding' filter is called, it is passed three parameters: an array of encoding types, URL of target site, array of all HTTP arguments.

add_filter( 'wp_http_accept_encoding', 'filter_function_name', 10, 3 );

function filter_function_name( $type, $url, $args ) {
    // Alter available encoding types
    return $type;
}

Where 'filter_function_name' is the function WordPress should call when filter is run. Note that the filter function must return an value after it is finished processing or the HTTP call will fail.

filter_function_name should be unique function name. It cannot match any other function name already declared.

Examples

add_filter( 'wp_http_accept_encoding', 'filter_function_name', 10, 3 );

function filter_function_name( $type, $url, $args ) {
    // Alter available encoding types
    return $type;
}


add_action( 'init', 'get_google_home' );

function get_google_home() {
    $google = wp_remote_get( "http://google.com" );
}

Change Log

See Also