mirror of
git://develop.git.wordpress.org/
synced 2025-02-25 00:52:55 +01:00
Store uploads according to the parent post date when using year/month sub-directories
git-svn-id: https://develop.svn.wordpress.org/trunk@9663 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
parent
6a0d610cb3
commit
f587fabad8
@ -213,7 +213,7 @@ function validate_file_to_edit( $file, $allowed_files = '' ) {
|
||||
* @param array $overrides Optional. An associative array of names=>values to override default variables with extract( $overrides, EXTR_OVERWRITE ).
|
||||
* @return array On success, returns an associative array of file attributes. On failure, returns $overrides['upload_error_handler'](&$file, $message ) or array( 'error'=>$message ).
|
||||
*/
|
||||
function wp_handle_upload( &$file, $overrides = false ) {
|
||||
function wp_handle_upload( &$file, $overrides = false, $time = null ) {
|
||||
// The default error handler.
|
||||
if (! function_exists( 'wp_handle_upload_error' ) ) {
|
||||
function wp_handle_upload_error( &$file, $message ) {
|
||||
@ -281,7 +281,7 @@ function wp_handle_upload( &$file, $overrides = false ) {
|
||||
}
|
||||
|
||||
// A writable uploads dir will pass this test. Again, there's no point overriding this one.
|
||||
if ( ! ( ( $uploads = wp_upload_dir() ) && false === $uploads['error'] ) )
|
||||
if ( ! ( ( $uploads = wp_upload_dir($time) ) && false === $uploads['error'] ) )
|
||||
return $upload_error_handler( $file, $uploads['error'] );
|
||||
|
||||
$filename = wp_unique_filename( $uploads['path'], $file['name'], $unique_filename_callback );
|
||||
|
@ -173,7 +173,11 @@ win.send_to_editor('<?php echo addslashes($html); ?>');
|
||||
*/
|
||||
function media_handle_upload($file_id, $post_id, $post_data = array()) {
|
||||
$overrides = array('test_form'=>false);
|
||||
$file = wp_handle_upload($_FILES[$file_id], $overrides);
|
||||
|
||||
$post = get_post($post_id);
|
||||
$time = $post->post_date_gmt;
|
||||
|
||||
$file = wp_handle_upload($_FILES[$file_id], $overrides, $time);
|
||||
|
||||
if ( isset($file['error']) )
|
||||
return new WP_Error( 'upload_error', $file['error'] );
|
||||
|
Loading…
x
Reference in New Issue
Block a user