wp/wp-includes/class-wp-http-encoding.php
changeset 18 be944660c56a
parent 16 a86126ab1dd4
child 19 3d72ae0968f4
equal deleted inserted replaced
17:34716fd837a4 18:be944660c56a
    25 	 *
    25 	 *
    26 	 * @param string $raw      String to compress.
    26 	 * @param string $raw      String to compress.
    27 	 * @param int    $level    Optional. Compression level, 9 is highest. Default 9.
    27 	 * @param int    $level    Optional. Compression level, 9 is highest. Default 9.
    28 	 * @param string $supports Optional, not used. When implemented it will choose
    28 	 * @param string $supports Optional, not used. When implemented it will choose
    29 	 *                         the right compression based on what the server supports.
    29 	 *                         the right compression based on what the server supports.
    30 	 * @return string|false False on failure.
    30 	 * @return string|false Compressed string on success, false on failure.
    31 	 */
    31 	 */
    32 	public static function compress( $raw, $level = 9, $supports = null ) {
    32 	public static function compress( $raw, $level = 9, $supports = null ) {
    33 		return gzdeflate( $raw, $level );
    33 		return gzdeflate( $raw, $level );
    34 	}
    34 	}
    35 
    35 
    43 	 *
    43 	 *
    44 	 * @since 2.8.0
    44 	 * @since 2.8.0
    45 	 *
    45 	 *
    46 	 * @param string $compressed String to decompress.
    46 	 * @param string $compressed String to decompress.
    47 	 * @param int    $length     The optional length of the compressed data.
    47 	 * @param int    $length     The optional length of the compressed data.
    48 	 * @return string|bool False on failure.
    48 	 * @return string|false Decompressed string on success, false on failure.
    49 	 */
    49 	 */
    50 	public static function decompress( $compressed, $length = null ) {
    50 	public static function decompress( $compressed, $length = null ) {
    51 
    51 
    52 		if ( empty( $compressed ) ) {
    52 		if ( empty( $compressed ) ) {
    53 			return $compressed;
    53 			return $compressed;
    96 	 * @link https://core.trac.wordpress.org/ticket/18273
    96 	 * @link https://core.trac.wordpress.org/ticket/18273
    97 	 * @link https://www.php.net/manual/en/function.gzinflate.php#70875
    97 	 * @link https://www.php.net/manual/en/function.gzinflate.php#70875
    98 	 * @link https://www.php.net/manual/en/function.gzinflate.php#77336
    98 	 * @link https://www.php.net/manual/en/function.gzinflate.php#77336
    99 	 *
    99 	 *
   100 	 * @param string $gzData String to decompress.
   100 	 * @param string $gzData String to decompress.
   101 	 * @return string|bool False on failure.
   101 	 * @return string|false Decompressed string on success, false on failure.
   102 	 */
   102 	 */
   103 	public static function compatible_gzinflate( $gzData ) {
   103 	public static function compatible_gzinflate( $gzData ) {
   104 
   104 
   105 		// Compressed data might contain a full header, if so strip it for gzinflate().
   105 		// Compressed data might contain a full header, if so strip it for gzinflate().
   106 		if ( "\x1f\x8b\x08" === substr( $gzData, 0, 3 ) ) {
   106 		if ( "\x1f\x8b\x08" === substr( $gzData, 0, 3 ) ) {