Make WordPress Core


Ignore:
Timestamp:
10/03/2012 06:49:37 PM (12 years ago)
Author:
nacin
Message:

Pass the post date to wp_upload_dir() during sideloads, just as we do uploads. Ensures that sideloaded images make it into the right uploads directory.

props solarisssmoke, fixes #16777.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/wp-admin/includes/file.php

    r21350 r22105  
    22/**
    33 * Functions for reading, writing, modifying, and deleting files on the file system.
    4  * Includes functionality for theme-specific files as well as operations for uploading, 
     4 * Includes functionality for theme-specific files as well as operations for uploading,
    55 * archiving, and rendering output when necessary.
    66 *
     
    228228 * @param array $file Reference to a single element of $_FILES. Call the function once for each uploaded file.
    229229 * @param array $overrides Optional. An associative array of names=>values to override default variables with extract( $overrides, EXTR_OVERWRITE ).
     230 * @param string $time Optional. Time formatted in 'yyyy/mm'.
    230231 * @return array On success, returns an associative array of file attributes. On failure, returns $overrides['upload_error_handler'](&$file, $message ) or array( 'error'=>$message ).
    231232 */
     
    360361 * @param array $file an array similar to that of a PHP $_FILES POST array
    361362 * @param array $overrides Optional. An associative array of names=>values to override default variables with extract( $overrides, EXTR_OVERWRITE ).
     363 * @param string $time Optional. Time formatted in 'yyyy/mm'.
    362364 * @return array On success, returns an associative array of file attributes. On failure, returns $overrides['upload_error_handler'](&$file, $message ) or array( 'error'=>$message ).
    363365 */
    364 function wp_handle_sideload( &$file, $overrides = false ) {
     366function wp_handle_sideload( &$file, $overrides = false, $time = null ) {
    365367    // The default error handler.
    366368    if (! function_exists( 'wp_handle_upload_error' ) ) {
     
    439441
    440442    // A writable uploads dir will pass this test. Again, there's no point overriding this one.
    441     if ( ! ( ( $uploads = wp_upload_dir() ) && false === $uploads['error'] ) )
     443    if ( ! ( ( $uploads = wp_upload_dir( $time ) ) && false === $uploads['error'] ) )
    442444        return $upload_error_handler( $file, $uploads['error'] );
    443445
Note: See TracChangeset for help on using the changeset viewer.