Update WP and plugins

This commit is contained in:
Oliver Davies 2019-04-16 20:56:22 +01:00
parent 10a4713229
commit 1fb77fc4ff
864 changed files with 101724 additions and 78262 deletions

View file

@ -23,8 +23,6 @@ class WP_Http_Encoding {
*
* @since 2.8.0
*
* @static
*
* @param string $raw String to compress.
* @param int $level Optional, default is 9. Compression level, 9 is highest.
* @param string $supports Optional, not used. When implemented it will choose the right compression based on what the server supports.
@ -44,31 +42,34 @@ class WP_Http_Encoding {
*
* @since 2.8.0
*
* @static
*
* @param string $compressed String to decompress.
* @param int $length The optional length of the compressed data.
* @return string|bool False on failure.
*/
public static function decompress( $compressed, $length = null ) {
if ( empty($compressed) )
if ( empty( $compressed ) ) {
return $compressed;
}
if ( false !== ( $decompressed = @gzinflate( $compressed ) ) )
if ( false !== ( $decompressed = @gzinflate( $compressed ) ) ) {
return $decompressed;
}
if ( false !== ( $decompressed = self::compatible_gzinflate( $compressed ) ) )
if ( false !== ( $decompressed = self::compatible_gzinflate( $compressed ) ) ) {
return $decompressed;
}
if ( false !== ( $decompressed = @gzuncompress( $compressed ) ) )
if ( false !== ( $decompressed = @gzuncompress( $compressed ) ) ) {
return $decompressed;
}
if ( function_exists('gzdecode') ) {
if ( function_exists( 'gzdecode' ) ) {
$decompressed = @gzdecode( $compressed );
if ( false !== $decompressed )
if ( false !== $decompressed ) {
return $decompressed;
}
}
return $compressed;
@ -91,38 +92,41 @@ class WP_Http_Encoding {
* @link https://secure.php.net/manual/en/function.gzinflate.php#70875
* @link https://secure.php.net/manual/en/function.gzinflate.php#77336
*
* @static
*
* @param string $gzData String to decompress.
* @return string|bool False on failure.
*/
public static function compatible_gzinflate($gzData) {
public static function compatible_gzinflate( $gzData ) {
// Compressed data might contain a full header, if so strip it for gzinflate().
if ( substr($gzData, 0, 3) == "\x1f\x8b\x08" ) {
$i = 10;
$flg = ord( substr($gzData, 3, 1) );
if ( substr( $gzData, 0, 3 ) == "\x1f\x8b\x08" ) {
$i = 10;
$flg = ord( substr( $gzData, 3, 1 ) );
if ( $flg > 0 ) {
if ( $flg & 4 ) {
list($xlen) = unpack('v', substr($gzData, $i, 2) );
$i = $i + 2 + $xlen;
list($xlen) = unpack( 'v', substr( $gzData, $i, 2 ) );
$i = $i + 2 + $xlen;
}
if ( $flg & 8 )
$i = strpos($gzData, "\0", $i) + 1;
if ( $flg & 16 )
$i = strpos($gzData, "\0", $i) + 1;
if ( $flg & 2 )
if ( $flg & 8 ) {
$i = strpos( $gzData, "\0", $i ) + 1;
}
if ( $flg & 16 ) {
$i = strpos( $gzData, "\0", $i ) + 1;
}
if ( $flg & 2 ) {
$i = $i + 2;
}
}
$decompressed = @gzinflate( substr($gzData, $i, -8) );
if ( false !== $decompressed )
$decompressed = @gzinflate( substr( $gzData, $i, -8 ) );
if ( false !== $decompressed ) {
return $decompressed;
}
}
// Compressed data from java.util.zip.Deflater amongst others.
$decompressed = @gzinflate( substr($gzData, 2) );
if ( false !== $decompressed )
$decompressed = @gzinflate( substr( $gzData, 2 ) );
if ( false !== $decompressed ) {
return $decompressed;
}
return false;
}
@ -132,32 +136,34 @@ class WP_Http_Encoding {
*
* @since 2.8.0
*
* @static
*
* @param string $url
* @param array $args
* @return string Types of encoding to accept.
*/
public static function accept_encoding( $url, $args ) {
$type = array();
$type = array();
$compression_enabled = self::is_available();
if ( ! $args['decompress'] ) // Decompression specifically disabled.
if ( ! $args['decompress'] ) { // Decompression specifically disabled.
$compression_enabled = false;
elseif ( $args['stream'] ) // Disable when streaming to file.
} 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.
} 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' ) )
if ( function_exists( 'gzinflate' ) ) {
$type[] = 'deflate;q=1.0';
}
if ( function_exists( 'gzuncompress' ) )
if ( function_exists( 'gzuncompress' ) ) {
$type[] = 'compress;q=0.5';
}
if ( function_exists( 'gzdecode' ) )
if ( function_exists( 'gzdecode' ) ) {
$type[] = 'gzip;q=0.5';
}
}
/**
@ -172,7 +178,7 @@ class WP_Http_Encoding {
*/
$type = apply_filters( 'wp_http_accept_encoding', $type, $url, $args );
return implode(', ', $type);
return implode( ', ', $type );
}
/**
@ -180,8 +186,6 @@ class WP_Http_Encoding {
*
* @since 2.8.0
*
* @static
*
* @return string Content-Encoding string to send in the header.
*/
public static function content_encoding() {
@ -193,17 +197,16 @@ class WP_Http_Encoding {
*
* @since 2.8.0
*
* @static
*
* @param array|string $headers All of the available headers.
* @return bool
*/
public static function should_decode($headers) {
public static function should_decode( $headers ) {
if ( is_array( $headers ) ) {
if ( array_key_exists('content-encoding', $headers) && ! empty( $headers['content-encoding'] ) )
if ( array_key_exists( 'content-encoding', $headers ) && ! empty( $headers['content-encoding'] ) ) {
return true;
}
} elseif ( is_string( $headers ) ) {
return ( stripos($headers, 'content-encoding:') !== false );
return ( stripos( $headers, 'content-encoding:' ) !== false );
}
return false;
@ -218,11 +221,9 @@ class WP_Http_Encoding {
*
* @since 2.8.0
*
* @static
*
* @return bool
*/
public static function is_available() {
return ( function_exists('gzuncompress') || function_exists('gzdeflate') || function_exists('gzinflate') );
return ( function_exists( 'gzuncompress' ) || function_exists( 'gzdeflate' ) || function_exists( 'gzinflate' ) );
}
}