From 1bb4914c3a6b7eda25ad5e1a5e3340fd8cfd1010 Mon Sep 17 00:00:00 2001 From: westi Date: Tue, 7 Dec 2010 12:45:24 +0000 Subject: [PATCH] Allow for the callee of download_url() to specify a different timeout if they want to - maybe they don't want to wait that long. git-svn-id: http://svn.automattic.com/wordpress/trunk@16763 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- wp-admin/includes/file.php | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/wp-admin/includes/file.php b/wp-admin/includes/file.php index c70347497..31a90385c 100644 --- a/wp-admin/includes/file.php +++ b/wp-admin/includes/file.php @@ -507,9 +507,10 @@ function wp_handle_sideload( &$file, $overrides = false ) { * @since 2.5.0 * * @param string $url the URL of the file to download + * @param int $timeout The timeout for the request to download the file default 300 seconds * @return mixed WP_Error on failure, string Filename on success. */ -function download_url( $url ) { +function download_url( $url, $timeout = 300 ) { //WARNING: The file is not automatically deleted, The script must unlink() the file. if ( ! $url ) return new WP_Error('http_no_url', __('Invalid URL Provided.')); @@ -522,7 +523,7 @@ function download_url( $url ) { if ( ! $handle ) return new WP_Error('http_no_file', __('Could not create Temporary file.')); - $response = wp_remote_get($url, array('timeout' => 300)); + $response = wp_remote_get($url, array('timeout' => $timeout)); if ( is_wp_error($response) ) { fclose($handle);