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
This commit is contained in:
parent
b05593c0b9
commit
62ec4a3bfd
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -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.
|
||||
*
|
||||
|
|
|
@ -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.
|
||||
|
|
Loading…
Reference in New Issue