check_upload_mimes() WP 3.0.0
Check an array of MIME types against a list of allowed types.
WordPress ships with a set of allowed upload filetypes, which is defined in wp-includes/functions.php in get_allowed_mime_types(). This function is used to filter that list against the filetypes allowed provided by Multisite Super Admins at wp-admin/network/settings.php.
Хуков нет.
Возвращает
Массив
. Ничего.
Использование
check_upload_mimes( $mimes );
- $mimes(массив) (обязательный)
- -
Список изменений
С версии 3.0.0 | Введена. |
Код check_upload_mimes() check upload mimes WP 5.7.1
function check_upload_mimes( $mimes ) {
$site_exts = explode( ' ', get_site_option( 'upload_filetypes', 'jpg jpeg png gif' ) );
$site_mimes = array();
foreach ( $site_exts as $ext ) {
foreach ( $mimes as $ext_pattern => $mime ) {
if ( '' !== $ext && false !== strpos( $ext_pattern, $ext ) ) {
$site_mimes[ $ext_pattern ] = $mime;
}
}
}
return $site_mimes;
}