diff --git src/wp-admin/includes/file.php src/wp-admin/includes/file.php
index bc98129855..361f0896c4 100644
|
|
function wp_handle_sideload( &$file, $overrides = false, $time = null ) { |
978 | 978 | * |
979 | 979 | * @since 2.5.0 |
980 | 980 | * @since 5.2.0 Signature Verification with SoftFail was added. |
| 981 | * @since 5.3.0 Introduced `download_url_remote_get_args` filter. |
981 | 982 | * |
982 | 983 | * @param string $url The URL of the file to download. |
983 | 984 | * @param int $timeout The timeout for the request to download the file. Default 300 seconds. |
… |
… |
function download_url( $url, $timeout = 300, $signature_verification = false ) { |
997 | 998 | return new WP_Error( 'http_no_file', __( 'Could not create Temporary file.' ) ); |
998 | 999 | } |
999 | 1000 | |
1000 | | $response = wp_safe_remote_get( |
1001 | | $url, |
1002 | | array( |
1003 | | 'timeout' => $timeout, |
1004 | | 'stream' => true, |
1005 | | 'filename' => $tmpfname, |
1006 | | ) |
| 1001 | /** |
| 1002 | * Filters the HTTP request arguments in `download_url`. |
| 1003 | * |
| 1004 | * @since 5.3.0 |
| 1005 | * |
| 1006 | * @see wp_safe_remote_get() |
| 1007 | * |
| 1008 | * @param array $upload Array of HTTP request arguments. `timeout`, `stream`, and `filename` cant be overridden. |
| 1009 | * @param string $url The URL of the file to download. |
| 1010 | * @param bool $signature_verification Whether to perform Signature Verification. Default false. |
| 1011 | * */ |
| 1012 | $remote_get_args = apply_filters( 'download_url_remote_get_args', array(), $url, $signature_verification ); |
| 1013 | |
| 1014 | $default_remote_get_args = array( |
| 1015 | 'timeout' => $timeout, |
| 1016 | 'stream' => true, |
| 1017 | 'filename' => $tmpfname, |
1007 | 1018 | ); |
1008 | 1019 | |
| 1020 | // Prevent the {@see 'download_url_remote_get_args'} to override default arguments. |
| 1021 | foreach( $default_remote_get_args as $default_arg_key => $default_arg_value ) { |
| 1022 | if ( isset( $remote_get_args[$default_arg_key] ) ) { |
| 1023 | unset( $remote_get_args[$default_arg_key] ); |
| 1024 | } |
| 1025 | } |
| 1026 | |
| 1027 | $remote_get_args = array_merge( $default_remote_get_args, $remote_get_args ); |
| 1028 | |
| 1029 | $response = wp_safe_remote_get( $url, $remote_get_args ); |
| 1030 | |
1009 | 1031 | if ( is_wp_error( $response ) ) { |
1010 | 1032 | unlink( $tmpfname ); |
1011 | 1033 | return $response; |