WordPress.org

Make WordPress Core

Changeset 9663


Ignore:
Timestamp:
11/13/2008 06:22:00 PM (10 years ago)
Author:
azaozz
Message:

Store uploads according to the parent post date when using year/month sub-directories

Location:
trunk/wp-admin/includes
Files:
2 edited

Legend:

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

    r9612 r9663  
    214214 * @return array On success, returns an associative array of file attributes. On failure, returns $overrides['upload_error_handler'](&$file, $message ) or array( 'error'=>$message ).
    215215 */
    216 function wp_handle_upload( &$file, $overrides = false ) {
     216function wp_handle_upload( &$file, $overrides = false, $time = null ) {
    217217    // The default error handler.
    218218    if (! function_exists( 'wp_handle_upload_error' ) ) {
     
    282282
    283283    // A writable uploads dir will pass this test. Again, there's no point overriding this one.
    284     if ( ! ( ( $uploads = wp_upload_dir() ) && false === $uploads['error'] ) )
     284    if ( ! ( ( $uploads = wp_upload_dir($time) ) && false === $uploads['error'] ) )
    285285        return $upload_error_handler( $file, $uploads['error'] );
    286286
  • trunk/wp-admin/includes/media.php

    r9654 r9663  
    174174function media_handle_upload($file_id, $post_id, $post_data = array()) {
    175175    $overrides = array('test_form'=>false);
    176     $file = wp_handle_upload($_FILES[$file_id], $overrides);
     176   
     177    $post = get_post($post_id);
     178    $time = $post->post_date_gmt;
     179
     180    $file = wp_handle_upload($_FILES[$file_id], $overrides, $time);
    177181
    178182    if ( isset($file['error']) )
Note: See TracChangeset for help on using the changeset viewer.