Changeset 10194 for trunk/src/bp-core/classes/class-bp-attachment.php
- Timestamp:
- 10/06/2015 11:53:33 PM (9 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/bp-core/classes/class-bp-attachment.php
r10178 r10194 35 35 */ 36 36 protected $default_args = array( 37 'original_max_filesize' => 0, 38 'allowed_mime_types' => array(), 39 'base_dir' => '', 40 'action' => '', 41 'file_input' => '', 42 'upload_error_strings' => array(), 43 'required_wp_files' => array( 'file' ), 37 'original_max_filesize' => 0, 38 'allowed_mime_types' => array(), 39 'base_dir' => '', 40 'action' => '', 41 'file_input' => '', 42 'upload_error_strings' => array(), 43 'required_wp_files' => array( 'file' ), 44 'upload_dir_filter_args' => 0, 44 45 ); 45 46 … … 48 49 * 49 50 * @since 2.3.0 51 * @since 2.4.0 Add the $upload_dir_filter_args argument to the $arguments array 50 52 * 51 53 * @param array|string $args { 52 * @type int $original_max_filesize Maximum file size in kilobytes. Defaults to php.ini settings. 53 * @type array $allowed_mime_types List of allowed file extensions (eg: array( 'jpg', 'gif', 'png' ) ). 54 * Defaults to WordPress allowed mime types. 55 * @type string $base_dir Component's upload base directory. Defaults to WordPress 'uploads'. 56 * @type string $action The upload action used when uploading a file, $_POST['action'] must be set 57 * and its value must equal $action {@link wp_handle_upload()} (required). 58 * @type string $file_input The name attribute used in the file input. (required). 59 * @type array $upload_error_strings A list of specific error messages (optional). 60 * @type array $required_wp_files The list of required WordPress core files. Default: array( 'file' ). 54 * @type int $original_max_filesize Maximum file size in kilobytes. Defaults to php.ini settings. 55 * @type array $allowed_mime_types List of allowed file extensions (eg: array( 'jpg', 'gif', 'png' ) ). 56 * Defaults to WordPress allowed mime types. 57 * @type string $base_dir Component's upload base directory. Defaults to WordPress 'uploads'. 58 * @type string $action The upload action used when uploading a file, $_POST['action'] must be set 59 * and its value must equal $action {@link wp_handle_upload()} (required). 60 * @type string $file_input The name attribute used in the file input. (required). 61 * @type array $upload_error_strings A list of specific error messages (optional). 62 * @type array $required_wp_files The list of required WordPress core files. Default: array( 'file' ). 63 * @type int $upload_dir_filter_args 1 to receive the original Upload dir array in the Upload dir filter, 0 otherwise. 64 * Defaults to 0 (optional). 61 65 * } 62 66 * @uses sanitize_key() … … 91 95 } elseif ( 'base_dir' === $key ) { 92 96 $this->{$key} = sanitize_title( $param ); 97 98 // Sanitize the upload dir filter arg to pass 99 } elseif ( 'upload_dir_filter_args' === $key ) { 100 $this->{$key} = (int) $param; 93 101 94 102 // Action & File input are already set and sanitized … … 269 277 // Make sure the file will be uploaded in the attachment directory 270 278 if ( ! empty( $upload_dir_filter ) ) { 271 add_filter( 'upload_dir', $upload_dir_filter, 10, 0);279 add_filter( 'upload_dir', $upload_dir_filter, 10, $this->upload_dir_filter_args ); 272 280 } 273 281 … … 277 285 // Restore WordPress Uploads data 278 286 if ( ! empty( $upload_dir_filter ) ) { 279 remove_filter( 'upload_dir', $upload_dir_filter, 10, 0);287 remove_filter( 'upload_dir', $upload_dir_filter, 10, $this->upload_dir_filter_args ); 280 288 } 281 289 … … 346 354 * 347 355 * @since 2.3.0 356 * @since 2.4.0 Add the $upload_dir parameter to the method 348 357 * 349 358 * @uses apply_filters() call 'bp_attachment_upload_dir' to eventually override the upload location 350 359 * regarding to context 351 360 * 361 * @param array $upload_dir The original Uploads dir. 352 362 * @return array The upload directory data. 353 363 */ 354 public function upload_dir_filter( ) {364 public function upload_dir_filter( $upload_dir = array() ) { 355 365 356 366 /** … … 358 368 * 359 369 * @since 2.3.0 370 * @since 2.4.0 Include the original Upload directory as the second parameter of the filter. 360 371 * 361 * @param array $value Array containing the path, URL, and other helpful settings. 372 * @param array $value Array containing the path, URL, and other helpful settings. 373 * @param array $upload_dir The original Uploads dir. 362 374 */ 363 375 return apply_filters( 'bp_attachment_upload_dir', array( … … 368 380 'baseurl' => $this->url, 369 381 'error' => false 370 ) );382 ), $upload_dir ); 371 383 } 372 384
Note: See TracChangeset
for help on using the changeset viewer.