check_upload_mimes()
check_upload_mimes( array $mimes ) 根据白名单检查MIME类型数组。Chec…
check_upload_mimes( array $mimes )
根据白名单检查MIME类型数组。
Check an array of MIME types against a whitelist.
根据白名单检查MIME类型数组。
Check an array of MIME types against a whitelist.
目录锚点:#说明#参数#返回#源码#笔记
说明(Description)
WordPress附带一组允许上传的文件类型,在wp includes中定义/函数.php在get_allowed_mime_types()中。此函数用于根据wp admin/network上的多站点超级管理员提供的文件类型白名单筛选该列表/设置.php.
参数(Parameters)
| 参数 | 类型 | 必填 | 说明 |
|---|---|---|---|
| $mimes | (array) | 必需 |
返回(Return)
(array)
源码(Source)
/**
* Check an array of MIME types against a whitelist.
*
* 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 filetype whitelist provided by Multisite
* Super Admins at wp-admin/network/settings.php.
*
* @since MU
*
* @param array $mimes
* @return array
*/
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 != '' && strpos( $ext_pattern, $ext ) !== false )
$site_mimes[$ext_pattern] = $mime;
}
}
return $site_mimes;
}| 更新版本 | 源码位置 | 使用 | 被使用 |
|---|---|---|---|
| MU (3.0.0) | wp-includes/ms-functions.php:1847 | 0 | 1 function |
笔记(Notes)
获取允许的MIME类型
类别:WordPress 函数手册、
本文收集自互联网,转载请注明来源。
如有侵权,请联系 wper_net@163.com 删除。

还没有任何评论,赶紧来占个楼吧!