Ticket #22949: functions.php.patch
File functions.php.patch, 2.0 KB (added by , 12 years ago) |
---|
-
wp-includes/functions.php
1766 1766 * @since 2.0.4 1767 1767 * 1768 1768 * @param string $filename File name or path. 1769 * @param array $mimes Optional. Key is the file extension with value as the mime type .1769 * @param array $mimes Optional. Key is the file extension with value as the mime type or array of mime types. 1770 1770 * @return array Values with extension first and mime type. 1771 1771 */ 1772 1772 function wp_check_filetype( $filename, $mimes = null ) { 1773 1773 if ( empty($mimes) ) 1774 1774 $mimes = get_allowed_mime_types(); 1775 $type = false; 1776 $ext = false; 1775 $type = $ext = $break = false; 1777 1776 1778 1777 foreach ( $mimes as $ext_preg => $mime_match ) { 1779 $ext_preg = '!\.(' . $ext_preg . ')$!i'; 1780 if ( preg_match( $ext_preg, $filename, $ext_matches ) ) { 1781 $type = $mime_match; 1782 $ext = $ext_matches[1]; 1778 $ext_preg = '!\.(' . str_replace( '.', '\.', $ext_preg ) . ')$!i'; 1779 foreach ( (array) $mime_match as $mime_type ) { 1780 if ( preg_match( $ext_preg, $filename, $ext_matches ) ) { 1781 $type = $mime_type; 1782 $ext = $ext_matches[1]; 1783 $break = true; 1784 break; 1785 } 1786 } 1787 if ($break) 1783 1788 break; 1784 }1785 1789 } 1786 1790 1787 1791 return compact( 'ext', 'type' ); … … 1863 1867 * @uses apply_filters() Calls 'mime_types' on returned array. This filter should 1864 1868 * be used to add types, not remove them. To remove types use the upload_mimes filter. 1865 1869 * 1866 * @return array Array of mime types keyed by the file extension regex corresponding to those types.1870 * @return array Array of mime types keyed by the file extension regex, or an array thereof, corresponding to those types. 1867 1871 */ 1868 1872 function wp_get_mime_types() { 1869 1873 // Accepted MIME types are set here as PCRE unless provided. … … 1874 1878 'png' => 'image/png', 1875 1879 'bmp' => 'image/bmp', 1876 1880 'tif|tiff' => 'image/tiff', 1877 'ico' => 'image/x-icon',1881 'ico' => array( 'image/x-icon', 'image/vnd.microsoft.icon' ), 1878 1882 // Video formats 1879 1883 'asf|asx|wax|wmv|wmx' => 'video/asf', 1880 1884 'avi' => 'video/avi',