Changeset 3894 for trunk/wp-includes/functions.php
- Timestamp:
- 06/21/2006 11:17:19 PM (18 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/wp-includes/functions.php
r3893 r3894 964 964 function wp_upload_bits($name, $type, $bits) { 965 965 if ( empty($name) ) 966 return array('error' => "Empty filename"); 966 return array('error' => __("Empty filename")); 967 968 $wp_filetype = wp_check_filetype($name); 969 if ( !$wp_filetype['ext'] ) 970 return array('error' => __("Invalid file type")); 967 971 968 972 $upload = wp_upload_dir(); … … 1010 1014 } 1011 1015 1016 function wp_check_filetype($filename, $mimes = null) { 1017 // Accepted MIME types are set here as PCRE unless provided. 1018 $mimes = is_array($mimes) ? $mimes : apply_filters('upload_mimes', array ( 1019 'jpg|jpeg|jpe' => 'image/jpeg', 1020 'gif' => 'image/gif', 1021 'png' => 'image/png', 1022 'bmp' => 'image/bmp', 1023 'tif|tiff' => 'image/tiff', 1024 'ico' => 'image/x-icon', 1025 'asf|asx|wax|wmv|wmx' => 'video/asf', 1026 'avi' => 'video/avi', 1027 'mov|qt' => 'video/quicktime', 1028 'mpeg|mpg|mpe' => 'video/mpeg', 1029 'txt|c|cc|h' => 'text/plain', 1030 'rtx' => 'text/richtext', 1031 'css' => 'text/css', 1032 'htm|html' => 'text/html', 1033 'mp3|mp4' => 'audio/mpeg', 1034 'ra|ram' => 'audio/x-realaudio', 1035 'wav' => 'audio/wav', 1036 'ogg' => 'audio/ogg', 1037 'mid|midi' => 'audio/midi', 1038 'wma' => 'audio/wma', 1039 'rtf' => 'application/rtf', 1040 'js' => 'application/javascript', 1041 'pdf' => 'application/pdf', 1042 'doc' => 'application/msword', 1043 'pot|pps|ppt' => 'application/vnd.ms-powerpoint', 1044 'wri' => 'application/vnd.ms-write', 1045 'xla|xls|xlt|xlw' => 'application/vnd.ms-excel', 1046 'mdb' => 'application/vnd.ms-access', 1047 'mpp' => 'application/vnd.ms-project', 1048 'swf' => 'application/x-shockwave-flash', 1049 'class' => 'application/java', 1050 'tar' => 'application/x-tar', 1051 'zip' => 'application/zip', 1052 'gz|gzip' => 'application/x-gzip', 1053 'exe' => 'application/x-msdownload' 1054 )); 1055 1056 $type = false; 1057 $ext = false; 1058 1059 foreach ($mimes as $ext_preg => $mime_match) { 1060 $ext_preg = '!\.(' . $ext_preg . ')$!i'; 1061 if ( preg_match($ext_preg, $filename, $ext_matches) ) { 1062 $type = $mime_match; 1063 $ext = $ext_matches[1]; 1064 break; 1065 } 1066 } 1067 1068 return compact('ext', 'type'); 1069 } 1070 1012 1071 function do_trackbacks($post_id) { 1013 1072 global $wpdb;
Note: See TracChangeset
for help on using the changeset viewer.