From 46892ffb12b0b59c83f404590dbe986faf349e15 Mon Sep 17 00:00:00 2001 From: antpb Date: Mon, 23 Sep 2019 16:03:56 +0000 Subject: [PATCH] Media: Sets `post_id` optional in `media_sideload_image()` and `media_handle_sideload()`. Props SergeyBiryukov, donmhico, mikeschroder, sebastian.pisula. Fixes #43579. Built from https://develop.svn.wordpress.org/trunk@46245 git-svn-id: http://core.svn.wordpress.org/trunk@46057 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- wp-admin/includes/media.php | 10 ++++++---- wp-includes/version.php | 2 +- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/wp-admin/includes/media.php b/wp-admin/includes/media.php index 9cab599662..745a1ec314 100644 --- a/wp-admin/includes/media.php +++ b/wp-admin/includes/media.php @@ -432,14 +432,15 @@ function media_handle_upload( $file_id, $post_id, $post_data = array(), $overrid * Handles a side-loaded file in the same way as an uploaded file is handled by media_handle_upload(). * * @since 2.6.0 + * @since 5.3.0 Made `$post_id` parameter optional. * * @param array $file_array Array similar to a `$_FILES` upload array. - * @param int $post_id The post ID the media is associated with. + * @param int $post_id Optional. The post ID the media is associated with. * @param string $desc Optional. Description of the side-loaded file. Default null. * @param array $post_data Optional. Post data to override. Default empty array. * @return int|WP_Error The ID of the attachment or a WP_Error on failure. */ -function media_handle_sideload( $file_array, $post_id, $desc = null, $post_data = array() ) { +function media_handle_sideload( $file_array, $post_id = 0, $desc = null, $post_data = array() ) { $overrides = array( 'test_form' => false ); $time = current_time( 'mysql' ); @@ -969,14 +970,15 @@ function wp_media_upload_handler() { * @since 2.6.0 * @since 4.2.0 Introduced the `$return` parameter. * @since 4.8.0 Introduced the 'id' option within the `$return` parameter. + * @since 5.3.0 Made the `$post_id` parameter optional * * @param string $file The URL of the image to download. - * @param int $post_id The post ID the media is to be associated with. + * @param int $post_id Optional. The post ID the media is to be associated with. * @param string $desc Optional. Description of the image. * @param string $return Optional. Accepts 'html' (image tag html) or 'src' (URL), or 'id' (attachment ID). Default 'html'. * @return string|WP_Error Populated HTML img tag on success, WP_Error object otherwise. */ -function media_sideload_image( $file, $post_id, $desc = null, $return = 'html' ) { +function media_sideload_image( $file, $post_id = 0, $desc = null, $return = 'html' ) { if ( ! empty( $file ) ) { // Set variables for storage, fix file filename for query strings. diff --git a/wp-includes/version.php b/wp-includes/version.php index 17ef1af0b9..068e093fcf 100644 --- a/wp-includes/version.php +++ b/wp-includes/version.php @@ -13,7 +13,7 @@ * * @global string $wp_version */ -$wp_version = '5.3-alpha-46244'; +$wp_version = '5.3-alpha-46245'; /** * Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.