Store uploads according to the parent post date when using year/month sub-directories
git-svn-id: http://svn.automattic.com/wordpress/trunk@9663 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
706f9a2c9c
commit
bd2112f197
|
@ -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 ).
|
* @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 ).
|
* @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.
|
// The default error handler.
|
||||||
if (! function_exists( 'wp_handle_upload_error' ) ) {
|
if (! function_exists( 'wp_handle_upload_error' ) ) {
|
||||||
function wp_handle_upload_error( &$file, $message ) {
|
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.
|
// 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'] );
|
return $upload_error_handler( $file, $uploads['error'] );
|
||||||
|
|
||||||
$filename = wp_unique_filename( $uploads['path'], $file['name'], $unique_filename_callback );
|
$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()) {
|
function media_handle_upload($file_id, $post_id, $post_data = array()) {
|
||||||
$overrides = array('test_form'=>false);
|
$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']) )
|
if ( isset($file['error']) )
|
||||||
return new WP_Error( 'upload_error', $file['error'] );
|
return new WP_Error( 'upload_error', $file['error'] );
|
||||||
|
|
Loading…
Reference in New Issue