Make WordPress Core

Ticket #43579: 43579.4.diff

File 43579.4.diff, 2.2 KB (added by kirasong, 5 years ago)

Refreshed 43579.3.diff.

  • src/wp-admin/includes/media.php

    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 
    432432 * Handles a side-loaded file in the same way as an uploaded file is handled by media_handle_upload().
    433433 *
    434434 * @since 2.6.0
     435 * @since 5.3.0 Made `$post_id` parameter optional.
    435436 *
    436437 * @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.
    438439 * @param string $desc       Optional. Description of the side-loaded file. Default null.
    439440 * @param array  $post_data  Optional. Post data to override. Default empty array.
    440441 * @return int|WP_Error The ID of the attachment or a WP_Error on failure.
    441442 */
    442 function media_handle_sideload( $file_array, $post_id, $desc = null, $post_data = array() ) {
     443function media_handle_sideload( $file_array, $post_id = 0, $desc = null, $post_data = array() ) {
    443444        $overrides = array( 'test_form' => false );
    444445
    445446        $time = current_time( 'mysql' );
    function wp_media_upload_handler() { 
    969970 * @since 2.6.0
    970971 * @since 4.2.0 Introduced the `$return` parameter.
    971972 * @since 4.8.0 Introduced the 'id' option within the `$return` parameter.
     973 * @since 5.3.0 Made the `$post_id` parameter optional
    972974 *
    973975 * @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.
    975977 * @param string $desc    Optional. Description of the image.
    976978 * @param string $return  Optional. Accepts 'html' (image tag html) or 'src' (URL), or 'id' (attachment ID). Default 'html'.
    977979 * @return string|WP_Error Populated HTML img tag on success, WP_Error object otherwise.
    978980 */
    979 function media_sideload_image( $file, $post_id, $desc = null, $return = 'html' ) {
     981function media_sideload_image( $file, $post_id = 0, $desc = null, $return = 'html' ) {
    980982        if ( ! empty( $file ) ) {
    981983
    982984                // Set variables for storage, fix file filename for query strings.