Changeset 13134
- Timestamp:
- 10/30/2021 05:27:30 PM (3 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/bp-core/bp-core-attachments.php
r13132 r13134 175 175 $exts = array(); 176 176 177 switch ( $type ) { 178 case 'video': 179 $exts = wp_get_video_extensions(); 180 break; 181 182 case 'audio': 183 $exts = wp_get_audio_extensions(); 184 break; 185 186 case isset( $wp_exts[ $type ] ): 187 $exts = $wp_exts[ $type ]; 188 break; 189 190 default: 191 $allowed_mimes = get_allowed_mime_types(); 192 193 /** 194 * Search for allowed mimes matching the type. 195 * 196 * Eg: using 'application/vnd.oasis' as the $type 197 * parameter will get all OpenOffice extensions supported 198 * by WordPress and allowed for the current user. 199 */ 200 if ( '' !== $type ) { 201 $allowed_mimes = preg_grep( '/' . addcslashes( $type, '/.+-' ) . '/', $allowed_mimes ); 202 } 203 204 $allowed_types = array_keys( $allowed_mimes ); 205 206 // Loop to explode keys using '|'. 207 foreach ( $allowed_types as $allowed_type ) { 208 $t = explode( '|', $allowed_type ); 209 $exts = array_merge( $exts, (array) $t ); 210 } 211 break; 177 if ( 'video' === $type ) { 178 $exts = wp_get_video_extensions(); 179 } elseif ( 'audio' === $type ) { 180 $exts = wp_get_audio_extensions(); 181 } elseif ( isset( $wp_exts[ $type ] ) ) { 182 $exts = $wp_exts[ $type ]; 183 } else { 184 $allowed_mimes = get_allowed_mime_types(); 185 186 /** 187 * Search for allowed mimes matching the type. 188 * 189 * Eg: using 'application/vnd.oasis' as the $type 190 * parameter will get all OpenOffice extensions supported 191 * by WordPress and allowed for the current user. 192 */ 193 if ( '' !== $type ) { 194 $allowed_mimes = preg_grep( '/' . addcslashes( $type, '/.+-' ) . '/', $allowed_mimes ); 195 } 196 197 $allowed_types = array_keys( $allowed_mimes ); 198 199 // Loop to explode keys using '|'. 200 foreach ( $allowed_types as $allowed_type ) { 201 $t = explode( '|', $allowed_type ); 202 $exts = array_merge( $exts, (array) $t ); 203 } 212 204 } 213 205 } … … 238 230 } 239 231 240 $validate_mimes = wp_match_mime_types( join( ',', $allowed_types ), wp_get_mime_types() ); 241 $allowed_mimes = array_map( 'implode', $validate_mimes ); 232 $wp_mimes = wp_get_mime_types(); 233 $allowed_mimes = array(); 234 235 foreach ( $allowed_types as $allowed_type ) { 236 $filetype = wp_check_filetype( '.' . $allowed_type, $wp_mimes ); 237 238 if ( false === $filetype['ext'] || false === $filetype['type'] ) { 239 continue; 240 } 241 242 $allowed_mimes[ $filetype['ext'] ] = $filetype['type']; 243 } 242 244 243 245 /**
Note: See TracChangeset
for help on using the changeset viewer.