get_allowed_mime_types

Retrieve list of allowed mime types and file extensions.

Description

(array) get_allowed_mime_types( (null) $user = null ); 

Returns (array)

Array of mime types keyed by the file extension regex corresponding to those types.

Parameters (1)

0. $user — Optional. (null) => null
User to check. Defaults to current user.

Usage

  1. if ( !function_exists( 'get_allowed_mime_types' ) ) { 
  2. require_once ABSPATH . WPINC . '/functions.php'; 
  3.  
  4. // Optional. User to check. Defaults to current user. 
  5. $user = null; 
  6.  
  7. // NOTICE! Understand what this does before running. 
  8. $result = get_allowed_mime_types($user); 
  9.  

Defined (1)

The function is defined in the following location(s).

/wp-includes/functions.php  
  1. function get_allowed_mime_types( $user = null ) { 
  2.  
  3. unset( $t['swf'], $t['exe'] ); 
  4. if ( function_exists( 'current_user_can' ) ) 
  5. $unfiltered = $user ? user_can( $user, 'unfiltered_html' ) : current_user_can( 'unfiltered_html' ); 
  6.  
  7. if ( empty( $unfiltered ) ) 
  8. unset( $t['htm|html'] ); 
  9.  
  10. /** 
  11. * Filters list of allowed mime types and file extensions. 
  12. * @since 2.0.0 
  13. * @param array $t Mime types keyed by the file extension regex corresponding to 
  14. * those types. 'swf' and 'exe' removed from full list. 'htm|html' also 
  15. * removed depending on '$user' capabilities. 
  16. * @param int|WP_User|null $user User ID, User object or null if not provided (indicates current user). 
  17. */ 
  18. return apply_filters( 'upload_mimes', $t, $user );