WP_Http_Encoding::accept_encoding()
What encoding types to accept and their priority values.
Method of the class: WP_Http_Encoding{}
Hooks from the method
Return
String
. Types of encoding to accept.
Usage
$result = WP_Http_Encoding::accept_encoding( $url, $args );
- $url(string) (required)
- -
- $args(array) (required)
- -
Changelog
Since 2.8.0 | Introduced. |
WP_Http_Encoding::accept_encoding() WP Http Encoding::accept encoding code WP 6.7.1
public static function accept_encoding( $url, $args ) { $type = array(); $compression_enabled = self::is_available(); if ( ! $args['decompress'] ) { // Decompression specifically disabled. $compression_enabled = false; } elseif ( $args['stream'] ) { // Disable when streaming to file. $compression_enabled = false; } elseif ( isset( $args['limit_response_size'] ) ) { // If only partial content is being requested, we won't be able to decompress it. $compression_enabled = false; } if ( $compression_enabled ) { if ( function_exists( 'gzinflate' ) ) { $type[] = 'deflate;q=1.0'; } if ( function_exists( 'gzuncompress' ) ) { $type[] = 'compress;q=0.5'; } if ( function_exists( 'gzdecode' ) ) { $type[] = 'gzip;q=0.5'; } } /** * Filters the allowed encoding types. * * @since 3.6.0 * * @param string[] $type Array of what encoding types to accept and their priority values. * @param string $url URL of the HTTP request. * @param array $args HTTP request arguments. */ $type = apply_filters( 'wp_http_accept_encoding', $type, $url, $args ); return implode( ', ', $type ); }