wpseek.com
WordPress开发者和主题制作者的搜索引擎
check_upload_mimes › WordPress Function
Sincen/a
已弃用n/a
› check_upload_mimes ( $mimes )
| 参数: |
|
| 返回: |
|
| 定义在: |
|
| 文档: | |
| Change Log: |
|
Checks 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.Related Functions: check_upload_size, get_upload_iframe_src, media_upload_image, check_comment, media_upload_file
源码
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 && str_contains( $ext_pattern, $ext ) ) {
$site_mimes[ $ext_pattern ] = $mime;
}
}
}
return $site_mimes;
}