diff --git a/src/wp-includes/functions.php b/src/wp-includes/functions.php
index 67544bc..0c3334b 100644
a
|
b
|
function wp_filesize( $path ) { |
3598 | 3598 | * Retrieves the list of allowed mime types and file extensions. |
3599 | 3599 | * |
3600 | 3600 | * @since 2.8.6 |
| 3601 | * @since 6.7 Added the `$ignore_user` parameter to return all possible mime types regardless of user. |
3601 | 3602 | * |
3602 | | * @param int|WP_User $user Optional. User to check. Defaults to current user. |
3603 | | * @return string[] Array of mime types keyed by the file extension regex corresponding |
| 3603 | * @param int|WP_User $user Optional. User to check. Defaults to current user. |
| 3604 | * @param bool $ignore_user Optional. An override flag to return all possible mime types regardless of user. |
| 3605 | * @return string[] Array of mime types keyed by the file extension regex corresponding |
3604 | 3606 | * to those types. |
3605 | 3607 | */ |
3606 | | function get_allowed_mime_types( $user = null ) { |
| 3608 | function get_allowed_mime_types( $user = null, $ignore_user = false ) { |
3607 | 3609 | $t = wp_get_mime_types(); |
3608 | 3610 | |
3609 | 3611 | unset( $t['swf'], $t['exe'] ); |
… |
… |
function get_allowed_mime_types( $user = null ) { |
3616 | 3618 | } |
3617 | 3619 | |
3618 | 3620 | /** |
3619 | | * Filters the list of allowed mime types and file extensions. |
3620 | | * |
3621 | | * @since 2.0.0 |
3622 | | * |
3623 | | * @param array $t Mime types keyed by the file extension regex corresponding to those types. |
3624 | | * @param int|WP_User|null $user User ID, User object or null if not provided (indicates current user). |
| 3621 | * @param array $t Mime types keyed by the file extension regex corresponding to |
| 3622 | * those types. 'swf' and 'exe' removed from full list. 'htm|html' also |
| 3623 | * removed depending on '$user' capabilities. |
| 3624 | * @param int|WP_User|null $user User ID, User object or null if not provided (indicates current user). |
| 3625 | * |
| 3626 | * @param bool $ignore_user An override flag to return all possible mime types regardless of user. |
| 3627 | * |
3625 | 3628 | */ |
3626 | | return apply_filters( 'upload_mimes', $t, $user ); |
| 3629 | return apply_filters( 'upload_mimes', $t, $user, $ignore_user ); |
3627 | 3630 | } |
3628 | 3631 | |
3629 | 3632 | /** |
diff --git a/tests/phpunit/tests/functions.php b/tests/phpunit/tests/functions.php
index 9d3260a..1a539d6 100644
a
|
b
|
class Tests_Functions extends WP_UnitTestCase { |
2218 | 2218 | ); |
2219 | 2219 | $this->assertSameSetsWithIndex( $theme_json, $expected_theme_json ); |
2220 | 2220 | } |
| 2221 | |
| 2222 | /** |
| 2223 | * @ticket 32544 |
| 2224 | */ |
| 2225 | function test_get_allowed_mime_types_all() { |
| 2226 | add_filter( 'upload_mimes', array( $this, 'add_mime_type_for_all_mime_test' ), 10, 3 ); |
| 2227 | $all_mimes = get_allowed_mime_types( null, true ); |
| 2228 | $this->assertArrayHasKey( 'test', $all_mimes ); |
| 2229 | |
| 2230 | $mimes = get_allowed_mime_types(); |
| 2231 | $this->assertArrayNotHasKey( 'test', $mimes ); |
| 2232 | } |
| 2233 | |
| 2234 | public function add_mime_type_for_all_mime_test( $mimes, $user_id, $ignore_user ) { |
| 2235 | $mime_types = array( 'test' => 'text/test' ); |
| 2236 | if ( $ignore_user ) { |
| 2237 | $mimes = array_merge( $mime_types, $mimes ); |
| 2238 | } |
| 2239 | return $mimes; |
| 2240 | } |
2221 | 2241 | } |