check_upload_mimes( array $mimes )
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.
参数
- $mimes
-
(array)
(Required)
返回值
(array)
源代码
File: wp-includes/ms-functions.php
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;
}
更新日志
Version | 描述 |
---|---|
MU | Introduced. |
相关函数
Uses
-
wp-includes/option.php:
get_site_option()
User Contributed Notes
-
Skip to note content
You must log in to vote on the helpfulness of this noteVote results for this note: 0You must log in to vote on the helpfulness of this note
Contributed by
Codex
Get allowed MIME types
$mimes = array( 'jpg|jpeg|jpe' => 'image/jpeg', 'php' => 'application/x-php', // This isn't on the whitelist! ); $mimes = check_upload_mimes( $mimes ); print_r( $mimes );
Output:
Array( 'jpg|jpeg|jpe' => 'image/jpeg' )
你可能对这些文章感兴趣:
- wordpress函数esc_html_x()用法示例
- wordpress函数esc_html()用法示例
- wordpress函数esc_html_e()用法示例
- wordpress函数esc_attr_x()用法示例
- wordpress函数esc_attr__()用法示例
- wordpress函数esc_attr()用法示例
- wordpress函数esc_attr_e()用法示例
- wordpress函数enqueue_embed_scripts()用法示例
- wordpress函数ent2ncr()用法示例
- wordpress函数enqueue_comment_hotkeys_js()用法示例
- wordpress函数edit_user()用法示例
- wordpress函数email_exists()用法示例
- wordpress函数endElement()用法示例
- wordpress函数edit_term_link()用法示例
如有疑问,请前往问答中心反馈!
反馈