Convert download_url() to http api. Props DD32. see #7793
git-svn-id: http://svn.automattic.com/wordpress/trunk@9142 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
01ee36d7c8
commit
bb87dcac69
|
@ -434,16 +434,14 @@ function download_url( $url ) {
|
||||||
if( ! $handle )
|
if( ! $handle )
|
||||||
return new WP_Error('http_no_file', __('Could not create Temporary file'));
|
return new WP_Error('http_no_file', __('Could not create Temporary file'));
|
||||||
|
|
||||||
require_once( ABSPATH . 'wp-includes/class-snoopy.php' );
|
$response = wp_remote_get($url);
|
||||||
$snoopy = new Snoopy();
|
|
||||||
$snoopy->fetch($url);
|
|
||||||
|
|
||||||
if( $snoopy->status != '200' ){
|
if( $response['response']['code'] != '200' ){
|
||||||
fclose($handle);
|
fclose($handle);
|
||||||
unlink($tmpfname);
|
unlink($tmpfname);
|
||||||
return new WP_Error('http_404', trim($snoopy->response_code));
|
return new WP_Error('http_404', trim($response['response']['message']));
|
||||||
}
|
}
|
||||||
fwrite($handle, $snoopy->results);
|
fwrite($handle, $response['body']);
|
||||||
fclose($handle);
|
fclose($handle);
|
||||||
|
|
||||||
return $tmpfname;
|
return $tmpfname;
|
||||||
|
|
Loading…
Reference in New Issue