Make WordPress Core

Ticket #43579: 43579.3.diff

File 43579.3.diff, 2.2 KB (added by donmhico, 5 years ago)
  • src/wp-admin/includes/media.php

    diff --git src/wp-admin/includes/media.php src/wp-admin/includes/media.php
    index ed850ec02d..f46ef83b63 100644
    function media_handle_upload( $file_id, $post_id, $post_data = array(), $overrid 
    413413 * Handles a side-loaded file in the same way as an uploaded file is handled by media_handle_upload().
    414414 *
    415415 * @since 2.6.0
     416 * @since 5.3.0 Made `$post_id` parameter optional.
    416417 *
    417418 * @param array  $file_array Array similar to a `$_FILES` upload array.
    418  * @param int    $post_id    The post ID the media is associated with.
     419 * @param int    $post_id    Optional. The post ID the media is associated with.
    419420 * @param string $desc       Optional. Description of the side-loaded file. Default null.
    420421 * @param array  $post_data  Optional. Post data to override. Default empty array.
    421422 * @return int|object The ID of the attachment or a WP_Error on failure.
    422423 */
    423 function media_handle_sideload( $file_array, $post_id, $desc = null, $post_data = array() ) {
     424function media_handle_sideload( $file_array, $post_id = 0, $desc = null, $post_data = array() ) {
    424425        $overrides = array( 'test_form' => false );
    425426
    426427        $time = current_time( 'mysql' );
    function wp_media_upload_handler() { 
    924925 * @since 2.6.0
    925926 * @since 4.2.0 Introduced the `$return` parameter.
    926927 * @since 4.8.0 Introduced the 'id' option within the `$return` parameter.
     928 * @since 5.3.0 Made the `$post_id` parameter optional
    927929 *
    928930 * @param string $file    The URL of the image to download.
    929  * @param int    $post_id The post ID the media is to be associated with.
     931 * @param int    $post_id Optional. The post ID the media is to be associated with.
    930932 * @param string $desc    Optional. Description of the image.
    931933 * @param string $return  Optional. Accepts 'html' (image tag html) or 'src' (URL), or 'id' (attachment ID). Default 'html'.
    932934 * @return string|WP_Error Populated HTML img tag on success, WP_Error object otherwise.
    933935 */
    934 function media_sideload_image( $file, $post_id, $desc = null, $return = 'html' ) {
     936function media_sideload_image( $file, $post_id = 0, $desc = null, $return = 'html' ) {
    935937        if ( ! empty( $file ) ) {
    936938
    937939                // Set variables for storage, fix file filename for query strings.