diff --git src/bp-core/classes/class-bp-attachment.php src/bp-core/classes/class-bp-attachment.php
index e4e625f..3e62182 100644
|
|
|
abstract class BP_Attachment { |
| 196 | 196 | * |
| 197 | 197 | * @param array $file The appropriate entry the from $_FILES superglobal. |
| 198 | 198 | * @param string $upload_dir_filter A specific filter to be applied to 'upload_dir' (optional). |
| | 199 | * @param string $time Optional. Time formatted in 'yyyy/mm'. Default null. |
| 199 | 200 | * @uses wp_handle_upload() To upload the file |
| 200 | 201 | * @uses add_filter() To temporarly overrides WordPress uploads data |
| 201 | 202 | * @uses remove_filter() To stop overriding WordPress uploads data |
| … |
… |
abstract class BP_Attachment { |
| 205 | 206 | * On failure, returns an array containing the error message |
| 206 | 207 | * (eg: array( 'error' => $message ) ) |
| 207 | 208 | */ |
| 208 | | public function upload( $file, $upload_dir_filter = '' ) { |
| | 209 | public function upload( $file, $upload_dir_filter = '', $time = null ) { |
| 209 | 210 | /** |
| 210 | 211 | * Upload action and the file input name are required parameters |
| 211 | 212 | * @see BP_Attachment:__construct() |
| … |
… |
abstract class BP_Attachment { |
| 264 | 265 | } |
| 265 | 266 | |
| 266 | 267 | // Make sure the file will be uploaded in the attachment directory |
| 267 | | add_filter( 'upload_dir', $upload_dir_filter, 10, 0 ); |
| | 268 | if ( ! empty( $upload_dir_filter ) ) { |
| | 269 | add_filter( 'upload_dir', $upload_dir_filter, 10, 0 ); |
| | 270 | } |
| 268 | 271 | |
| 269 | 272 | // Upload the attachment |
| 270 | | $this->attachment = wp_handle_upload( $file[ $this->file_input ], $overrides ); |
| | 273 | $this->attachment = wp_handle_upload( $file[ $this->file_input ], $overrides, $time ); |
| 271 | 274 | |
| 272 | 275 | // Restore WordPress Uploads data |
| 273 | | remove_filter( 'upload_dir', $upload_dir_filter, 10, 0 ); |
| | 276 | if ( ! empty( $upload_dir_filter ) ) { |
| | 277 | remove_filter( 'upload_dir', $upload_dir_filter, 10, 0 ); |
| | 278 | } |
| 274 | 279 | |
| 275 | 280 | // Remove the pre WordPress 4.0 static filter |
| 276 | 281 | remove_filter( 'wp_handle_upload_prefilter', array( $this, 'validate_upload' ), 10, 1 ); |