diff --git src/wp-admin/includes/media.php src/wp-admin/includes/media.php
index 9cab599662..745a1ec314 100644
|
|
function media_handle_upload( $file_id, $post_id, $post_data = array(), $overrid |
432 | 432 | * Handles a side-loaded file in the same way as an uploaded file is handled by media_handle_upload(). |
433 | 433 | * |
434 | 434 | * @since 2.6.0 |
| 435 | * @since 5.3.0 Made `$post_id` parameter optional. |
435 | 436 | * |
436 | 437 | * @param array $file_array Array similar to a `$_FILES` upload array. |
437 | | * @param int $post_id The post ID the media is associated with. |
| 438 | * @param int $post_id Optional. The post ID the media is associated with. |
438 | 439 | * @param string $desc Optional. Description of the side-loaded file. Default null. |
439 | 440 | * @param array $post_data Optional. Post data to override. Default empty array. |
440 | 441 | * @return int|WP_Error The ID of the attachment or a WP_Error on failure. |
441 | 442 | */ |
442 | | function media_handle_sideload( $file_array, $post_id, $desc = null, $post_data = array() ) { |
| 443 | function media_handle_sideload( $file_array, $post_id = 0, $desc = null, $post_data = array() ) { |
443 | 444 | $overrides = array( 'test_form' => false ); |
444 | 445 | |
445 | 446 | $time = current_time( 'mysql' ); |
… |
… |
function wp_media_upload_handler() { |
969 | 970 | * @since 2.6.0 |
970 | 971 | * @since 4.2.0 Introduced the `$return` parameter. |
971 | 972 | * @since 4.8.0 Introduced the 'id' option within the `$return` parameter. |
| 973 | * @since 5.3.0 Made the `$post_id` parameter optional |
972 | 974 | * |
973 | 975 | * @param string $file The URL of the image to download. |
974 | | * @param int $post_id The post ID the media is to be associated with. |
| 976 | * @param int $post_id Optional. The post ID the media is to be associated with. |
975 | 977 | * @param string $desc Optional. Description of the image. |
976 | 978 | * @param string $return Optional. Accepts 'html' (image tag html) or 'src' (URL), or 'id' (attachment ID). Default 'html'. |
977 | 979 | * @return string|WP_Error Populated HTML img tag on success, WP_Error object otherwise. |
978 | 980 | */ |
979 | | function media_sideload_image( $file, $post_id, $desc = null, $return = 'html' ) { |
| 981 | function media_sideload_image( $file, $post_id = 0, $desc = null, $return = 'html' ) { |
980 | 982 | if ( ! empty( $file ) ) { |
981 | 983 | |
982 | 984 | // Set variables for storage, fix file filename for query strings. |