From 62ec4a3bfdf84aff5c88f746e2eb9557249c7afe Mon Sep 17 00:00:00 2001 From: Scott Taylor Date: Wed, 9 Sep 2015 04:26:25 +0000 Subject: [PATCH] Deprecate `wp_get_http()` - function isn't used anywhere (apart from itself). Props swissspidy. Fixes #33709. Built from https://develop.svn.wordpress.org/trunk@33969 git-svn-id: http://core.svn.wordpress.org/trunk@33938 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- wp-includes/deprecated.php | 59 ++++++++++++++++++++++++++++++++++++++ wp-includes/functions.php | 56 ------------------------------------ wp-includes/version.php | 2 +- 3 files changed, 60 insertions(+), 57 deletions(-) diff --git a/wp-includes/deprecated.php b/wp-includes/deprecated.php index 582b2fd5f2..914d137658 100644 --- a/wp-includes/deprecated.php +++ b/wp-includes/deprecated.php @@ -3561,3 +3561,62 @@ function post_permalink( $post_id = 0 ) { return get_permalink( $post_id ); } +/** + * Perform a HTTP HEAD or GET request. + * + * If $file_path is a writable filename, this will do a GET request and write + * the file to that path. + * + * @since 2.5.0 + * @deprecated 4.4.0 Use WP_Http + * @see WP_Http + * + * @param string $url URL to fetch. + * @param string|bool $file_path Optional. File path to write request to. Default false. + * @param int $red Optional. The number of Redirects followed, Upon 5 being hit, + * returns false. Default 1. + * @return bool|string False on failure and string of headers if HEAD request. + */ +function wp_get_http( $url, $file_path = false, $red = 1 ) { + _deprecated_function( __FUNCTION__, '4.4', 'WP_Http' ); + + @set_time_limit( 60 ); + + if ( $red > 5 ) + return false; + + $options = array(); + $options['redirection'] = 5; + + if ( false == $file_path ) + $options['method'] = 'HEAD'; + else + $options['method'] = 'GET'; + + $response = wp_safe_remote_request( $url, $options ); + + if ( is_wp_error( $response ) ) + return false; + + $headers = wp_remote_retrieve_headers( $response ); + $headers['response'] = wp_remote_retrieve_response_code( $response ); + + // WP_HTTP no longer follows redirects for HEAD requests. + if ( 'HEAD' == $options['method'] && in_array($headers['response'], array(301, 302)) && isset( $headers['location'] ) ) { + return wp_get_http( $headers['location'], $file_path, ++$red ); + } + + if ( false == $file_path ) + return $headers; + + // GET request - write it to the supplied filename + $out_fp = fopen($file_path, 'w'); + if ( !$out_fp ) + return $headers; + + fwrite( $out_fp, wp_remote_retrieve_body( $response ) ); + fclose($out_fp); + clearstatcache(); + + return $headers; +} diff --git a/wp-includes/functions.php b/wp-includes/functions.php index 9206f9bffd..2f55528c7b 100644 --- a/wp-includes/functions.php +++ b/wp-includes/functions.php @@ -563,62 +563,6 @@ function do_enclose( $content, $post_ID ) { } } -/** - * Perform a HTTP HEAD or GET request. - * - * If $file_path is a writable filename, this will do a GET request and write - * the file to that path. - * - * @since 2.5.0 - * - * @param string $url URL to fetch. - * @param string|bool $file_path Optional. File path to write request to. Default false. - * @param int $red Optional. The number of Redirects followed, Upon 5 being hit, - * returns false. Default 1. - * @return bool|string False on failure and string of headers if HEAD request. - */ -function wp_get_http( $url, $file_path = false, $red = 1 ) { - @set_time_limit( 60 ); - - if ( $red > 5 ) - return false; - - $options = array(); - $options['redirection'] = 5; - - if ( false == $file_path ) - $options['method'] = 'HEAD'; - else - $options['method'] = 'GET'; - - $response = wp_safe_remote_request( $url, $options ); - - if ( is_wp_error( $response ) ) - return false; - - $headers = wp_remote_retrieve_headers( $response ); - $headers['response'] = wp_remote_retrieve_response_code( $response ); - - // WP_HTTP no longer follows redirects for HEAD requests. - if ( 'HEAD' == $options['method'] && in_array($headers['response'], array(301, 302)) && isset( $headers['location'] ) ) { - return wp_get_http( $headers['location'], $file_path, ++$red ); - } - - if ( false == $file_path ) - return $headers; - - // GET request - write it to the supplied filename - $out_fp = fopen($file_path, 'w'); - if ( !$out_fp ) - return $headers; - - fwrite( $out_fp, wp_remote_retrieve_body( $response ) ); - fclose($out_fp); - clearstatcache(); - - return $headers; -} - /** * Retrieve HTTP Headers from URL. * diff --git a/wp-includes/version.php b/wp-includes/version.php index 0b0f60e50a..3f79114f98 100644 --- a/wp-includes/version.php +++ b/wp-includes/version.php @@ -4,7 +4,7 @@ * * @global string $wp_version */ -$wp_version = '4.4-alpha-33968'; +$wp_version = '4.4-alpha-33969'; /** * Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.