Make WordPress Core

Ticket #40343: time_upload.diff

File time_upload.diff, 1.0 KB (added by curdin, 8 years ago)

Reads a time header to pass to wp_handle_sideload. Probably needs validation / errorhandling.

  • src/wp-includes/rest-api/endpoints/class-wp-rest-attachments-controller.php

    diff --git src/wp-includes/rest-api/endpoints/class-wp-rest-attachments-controller.php src/wp-includes/rest-api/endpoints/class-wp-rest-attachments-controller.php
    index 43d057e167..4c399e079e 100644
    class WP_REST_Attachments_Controller extends WP_REST_Posts_Controller { 
    519519                // Get the content-type.
    520520                $type = array_shift( $headers['content_type'] );
    521521
     522                $time = array_shift( $headers['time'] );
     523
    522524                /** Include admin functions to get access to wp_tempnam() and wp_handle_sideload() */
    523525                require_once ABSPATH . 'wp-admin/includes/admin.php';
    524526
    class WP_REST_Attachments_Controller extends WP_REST_Posts_Controller { 
    546548                        'test_form' => false,
    547549                );
    548550
    549                 $sideloaded = wp_handle_sideload( $file_data, $overrides );
     551                $sideloaded = wp_handle_sideload( $file_data, $overrides, $time );
    550552
    551553                if ( isset( $sideloaded['error'] ) ) {
    552554                        @unlink( $tmpfname );