Make WordPress Core

Ticket #16777: 16777.diff

File 16777.diff, 2.7 KB (added by solarissmoke, 12 years ago)
  • wp-admin/includes/file.php

     
    225225 * @uses delete_transient
    226226 * @param array $file Reference to a single element of $_FILES. Call the function once for each uploaded file.
    227227 * @param array $overrides Optional. An associative array of names=>values to override default variables with extract( $overrides, EXTR_OVERWRITE ).
     228 * @param string $time Optional. Time formatted in yyyy/mm
    228229 * @return array On success, returns an associative array of file attributes. On failure, returns $overrides['upload_error_handler'](&$file, $message ) or array( 'error'=>$message ).
    229230 */
    230231function wp_handle_upload( &$file, $overrides = false, $time = null ) {
     
    357358 * @uses wp_unique_filename
    358359 * @param array $file an array similar to that of a PHP $_FILES POST array
    359360 * @param array $overrides Optional. An associative array of names=>values to override default variables with extract( $overrides, EXTR_OVERWRITE ).
     361 * @param string $time Optional. Time formatted in yyyy/mm
    360362 * @return array On success, returns an associative array of file attributes. On failure, returns $overrides['upload_error_handler'](&$file, $message ) or array( 'error'=>$message ).
    361363 */
    362 function wp_handle_sideload( &$file, $overrides = false ) {
     364function wp_handle_sideload( &$file, $overrides = false, $time = null ) {
    363365        // The default error handler.
    364366        if (! function_exists( 'wp_handle_upload_error' ) ) {
    365367                function wp_handle_upload_error( &$file, $message ) {
     
    436438        }
    437439
    438440        // A writable uploads dir will pass this test. Again, there's no point overriding this one.
    439         if ( ! ( ( $uploads = wp_upload_dir() ) && false === $uploads['error'] ) )
     441        if ( ! ( ( $uploads = wp_upload_dir( $time ) ) && false === $uploads['error'] ) )
    440442                return $upload_error_handler( $file, $uploads['error'] );
    441443
    442444        $filename = wp_unique_filename( $uploads['path'], $file['name'], $unique_filename_callback );
  • wp-admin/includes/media.php

     
    251251 */
    252252function media_handle_sideload($file_array, $post_id, $desc = null, $post_data = array()) {
    253253        $overrides = array('test_form'=>false);
    254 
    255         $file = wp_handle_sideload($file_array, $overrides);
     254       
     255        $time = null;
     256        if ( $post = get_post($post_id) ) {
     257                if ( substr( $post->post_date, 0, 4 ) > 0 )
     258                        $time = $post->post_date;
     259        }
     260       
     261        $file = wp_handle_sideload( $file_array, $overrides, $time );
    256262        if ( isset($file['error']) )
    257263                return new WP_Error( 'upload_error', $file['error'] );
    258264