Changeset 9660 for trunk/src/bp-core/classes/class-bp-attachment.php
- Timestamp:
- 03/29/2015 06:25:35 PM (10 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/bp-core/classes/class-bp-attachment.php
r9622 r9660 17 17 * @since BuddyPress (2.3.0) 18 18 */ 19 class BP_Attachment {19 abstract class BP_Attachment { 20 20 21 21 /** Upload properties *****************************************************/ … … 29 29 30 30 /** 31 * Maximum file size in kilobytes 32 * 33 * @var int 34 */ 35 public $original_max_filesize = 0; 36 37 /** 38 * List of allowed file extensions 39 * Defaults to get_allowed_mime_types() 40 * 41 * @var int 42 */ 43 public $allowed_mime_types = array(); 44 45 /** 46 * component's upload base directory. 47 * 48 * @var string 49 */ 50 public $base_dir = ''; 51 52 /** 53 * The upload action. 54 * 55 * @var string 56 */ 57 public $action = ''; 58 59 /** 60 * The file input name attribute 61 * 62 * @var string 63 */ 64 public $file_input = ''; 65 66 /** 67 * List of upload errors. 31 * The default args to be merged with the 32 * ones passed by the child class 68 33 * 69 34 * @var array 70 35 */ 71 public $upload_error_strings = array(); 72 73 /** 74 * List of required core files 75 * 76 * @var array 77 */ 78 public $required_wp_files = array( 'file' ); 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' ), 44 ); 79 45 80 46 /** … … 114 80 * a multisite config, the root site fileupload_maxk option 115 81 */ 116 $this-> original_max_filesize= (int) wp_max_upload_size();117 118 $params = bp_parse_args( $args, get_class_vars( __CLASS__ ), $this->action . '_upload_params' );82 $this->default_args['original_max_filesize'] = (int) wp_max_upload_size(); 83 84 $params = bp_parse_args( $args, $this->default_args, $this->action . '_upload_params' ); 119 85 120 86 foreach ( $params as $key => $param ) { 121 87 if ( 'upload_error_strings' === $key ) { 122 88 $this->{$key} = $this->set_upload_error_strings( $param ); 123 } else { 89 90 // Sanitize the base dir 91 } elseif ( 'base_dir' === $key ) { 92 $this->{$key} = sanitize_title( $param ); 93 94 // Action & File input are already set and sanitized 95 } elseif ( 'action' !== $key && 'file_input' !== $key ) { 124 96 $this->{$key} = $param; 125 97 } … … 316 288 foreach ( (array) $this->allowed_mime_types as $ext ) { 317 289 foreach ( $wp_mimes as $ext_pattern => $mime ) { 318 if ( $ext != '' && strpos( $ext_pattern, $ext ) !== false ) {290 if ( $ext !== '' && strpos( $ext_pattern, $ext ) !== false ) { 319 291 $valid_mimes[$ext_pattern] = $mime; 320 292 } … … 396 368 397 369 // Check if upload path already exists 398 if ( ! file_exists( $this->upload_path ) ) {370 if ( ! is_dir( $this->upload_path ) ) { 399 371 400 372 // If path does not exist, attempt to create it … … 430 402 $wp_error = new WP_Error(); 431 403 432 $r = wp_parse_args( $args, array(404 $r = bp_parse_args( $args, array( 433 405 'original_file' => '', 434 406 'crop_x' => 0, … … 440 412 'src_abs' => false, 441 413 'dst_file' => false, 442 ) );414 ), 'bp_attachment_crop_args' ); 443 415 444 416 if ( empty( $r['original_file'] ) || ! file_exists( $r['original_file'] ) ) {
Note: See TracChangeset
for help on using the changeset viewer.