функция
since 2.8.6
get_allowed_mime_types()
Проверено на WordPress 6.9, обновлено Источник: WordPress Developer Resources.
Сигнатура
get_allowed_mime_types( int|WP_User $user = null ): string[]
Описание
Возвращает список разрешённых MIME-типов и расширений файлов.
Параметры
$user
int|WP_User
необязательный
= null
Пользователь для проверки. По умолчанию — текущий пользователь.
Возвращаемое значение
string[]
Исходный код
wp-includes/functions.php:3657
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 );
}
История изменений
| Версия | Описание |
|---|---|
| 2.8.6 | Introduced. |

