WordPress at a glance

get_allowed_mime_types() WP 1.0

Retrieve list of allowed mime types and file extensions.

Works based on: wp_get_mime_types()

No Hooks.

Return

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

Usage

get_allowed_mime_types( $user );
$user(int/WP_User)
User to check.
Default: current user

Code of get_allowed_mime_types: wp-includes/functions.php VER 5.0.1

<?php
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 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. 'swf' and 'exe' removed from full list. 'htm|html' also
	 *                               removed depending on '$user' capabilities.
	 * @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 );
}

Related Functions

From category: Rarely used

No comments
    Hello, !     Log In . Register