Ticket #32544: 32544.diff
File 32544.diff, 2.5 KB (added by , 8 years ago) |
---|
-
src/wp-includes/functions.php
2469 2469 * @return array Array of mime types keyed by the file extension regex corresponding 2470 2470 * to those types. 2471 2471 */ 2472 function get_allowed_mime_types( $user = null ) {2472 function get_allowed_mime_types( $user = null , $ignore_user = false ) { 2473 2473 $t = wp_get_mime_types(); 2474 2474 2475 2475 unset( $t['swf'], $t['exe'] ); … … 2484 2484 * 2485 2485 * @since 2.0.0 2486 2486 * 2487 * @param array $t Mime types keyed by the file extension regex corresponding to 2488 * those types. 'swf' and 'exe' removed from full list. 'htm|html' also 2489 * removed depending on '$user' capabilities. 2490 * @param int|WP_User|null $user User ID, User object or null if not provided (indicates current user). 2487 * @param array $t Mime types keyed by the file extension regex corresponding to 2488 * those types. 'swf' and 'exe' removed from full list. 'htm|html' also 2489 * removed depending on '$user' capabilities. 2490 * @param int|WP_User|null $user User ID, User object or null if not provided (indicates current user). 2491 * 2492 * @param bool $ignore_user An override flag to return all possible mime types regardless of user. 2491 2493 */ 2492 return apply_filters( 'upload_mimes', $t, $user );2494 return apply_filters( 'upload_mimes', $t, $user, $ignore_user ); 2493 2495 } 2494 2496 2495 2497 /** -
tests/phpunit/tests/functions.php
408 408 } 409 409 410 410 /** 411 * @ticket 32544 412 */ 413 function test_get_allowed_mime_types_all() { 414 add_filter( 'upload_mimes', array( $this, 'whitelist_test_mime_type_ignore' ), 10, 3 ); 415 $all_mimes = get_allowed_mime_types( null, true ); 416 $this->assertArrayHasKey( 'test', $all_mimes ); 417 418 $mimes = get_allowed_mime_types(); 419 $this->assertArrayNotHasKey( 'test', $mimes ); 420 } 421 422 public function whitelist_test_mime_type_ignore( $mimes, $user_id, $ignore_user ) { 423 $mime_types = array( 'test' => 'text/test' ); 424 if ( $ignore_user ) { 425 $mimes = array_merge( $mime_types, $mimes ); 426 } 427 return $mimes; 428 } 429 430 /** 411 431 * @ticket 23688 412 432 */ 413 433 function test_canonical_charset() {