get_allowed_mime_types( int|WP_User $user = null ): string[]
- Since
- 2.8.6
- Source
wp-includes/functions.php:3657
Retrieves the list of allowed mime types and file extensions.
Parameters
$userint|WP_Useroptional- User to check. Defaults to current user.Default:
null
Return
string[]- Array of mime types keyed by the file extension regex corresponding to those types.
Hooks fired · 1
One hook fires while get_allowed_mime_types() runs, in this order:
- apply_filters( upload_mimes )filterline 3677 (+20 into the body)
Filters the list of allowed mime types and file extensions.
Uses · 4
- wp_get_mime_types()Retrieves the list of mime types and file extensions.
- user_can()Returns whether a particular user has the specified capability.
- current_user_can()Returns whether the current user has the specified capability.
- apply_filters()Calls the callback functions that have been added to a filter hook.
Used by · 10
- WP_REST_Attachments_Controller::get_media_types()Retrieves the supported media types.
- atom_enclosure()Displays the atom enclosure for the current post.
- download_url()Downloads a URL to a local temporary file using the WordPress HTTP API.
- get_default_block_editor_settings()Returns the default block editor settings.
- populate_network_meta()Creates WordPress network meta and sets the default values.
- sanitize_file_name()Sanitizes a filename, replacing whitespace with dashes.
- wp_check_filetype()Retrieves the file type from the file name.
- wp_check_filetype_and_ext()Attempts to determine the real file type of a file.
- wp_enqueue_media()Enqueues all scripts, styles, settings, and templates necessary to use all media JS APIs.
- wp_plupload_default_settings()Prints default Plupload arguments.
Source
function get_allowed_mime_types( $user = null ) { $t = wp_get_mime_types(); unset( $t['swf'], $t['exe'] ); if ( function_exists( 'current_user_can' ) ) { $unfiltered = $user ? user_can( $user, 'unfiltered_html' ) : current_user_can( 'unfiltered_html' ); } if ( empty( $unfiltered ) ) { unset( $t['htm|html'], $t['js'] ); } /** * Filters the list of allowed mime types and file extensions. * * @since 2.0.0 * * @param array $t Mime types keyed by the file extension regex corresponding to those types. * @param int|WP_User|null $user User ID, User object or null if not provided (indicates current user). */ return apply_filters( 'upload_mimes', $t, $user );}History
Introduced in 2.8.6. Unchanged from 6.7.7 through 7.1.0.
Signature, return type and hooks compared across 5 parsed releases.
About this page
- Parsed data
- Generated from the wordpress-develop 7.0.4 tag, from
src/wp-includes/functions.php, and regenerated for each WordPress release so it tracks the code rather than a snapshot of it. - Corrections
- Something wrong on this page? Report it and it gets fixed in the next regeneration.