@@ -185,12 +185,13 @@ function ( $val ) use ( $media ) {
185185 /**
186186 * Download an attachment source to the file system.
187187 *
188- * @param int $attachment_id The attachment ID.
189- * @param string $source The optional source to download.
188+ * @param int $attachment_id The attachment ID.
189+ * @param string $source The optional source to download.
190+ * @param string|null $date The date of the attachment to set storage folders.
190191 *
191192 * @return array|\WP_Error
192193 */
193- public function download_asset ( $ attachment_id , $ source = null ) {
194+ public function download_asset ( $ attachment_id , $ source = null , $ date = null ) {
194195 require_once ABSPATH . 'wp-admin/includes/image.php ' ;
195196 require_once ABSPATH . 'wp-admin/includes/media.php ' ;
196197 if ( empty ( $ source ) ) {
@@ -200,7 +201,7 @@ public function download_asset( $attachment_id, $source = null ) {
200201 $ file_name = basename ( $ source );
201202 try {
202203 // Prime a file to stream to.
203- $ upload = wp_upload_bits ( $ file_name , null , 'temp ' );
204+ $ upload = wp_upload_bits ( $ file_name , null , 'temp ' , $ date );
204205 if ( ! empty ( $ upload ['error ' ] ) ) {
205206 return new \WP_Error ( 'download_error ' , $ upload ['error ' ] );
206207 }
0 commit comments