Changeset 21541 for trunk/wp-includes/functions.php
- Timestamp:
- 08/17/2012 05:25:19 PM (12 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/wp-includes/functions.php
r21527 r21541 459 459 $extension = pathinfo( $url_parts['path'], PATHINFO_EXTENSION ); 460 460 if ( !empty( $extension ) ) { 461 foreach ( get_allowed_mime_types() as $exts => $mime ) {461 foreach ( wp_get_mime_types() as $exts => $mime ) { 462 462 if ( preg_match( '!^(' . $exts . ')$!i', $extension ) ) { 463 463 $type = $mime; … … 1755 1755 1756 1756 /** 1757 * Retrieve list of mime types and file extensions. 1758 * 1759 * @since 3.5.0 1760 * 1761 * @uses apply_filters() Calls 'mime_types' on returned array. This filter should 1762 * be used to add types, not remove them. To remove types use the upload_mimes filter. 1763 * 1764 * @return array Array of mime types keyed by the file extension regex corresponding to those types. 1765 */ 1766 function wp_get_mime_types() { 1767 // Accepted MIME types are set here as PCRE unless provided. 1768 return apply_filters( 'mime_types', array( 1769 // Image formats 1770 'jpg|jpeg|jpe' => 'image/jpeg', 1771 'gif' => 'image/gif', 1772 'png' => 'image/png', 1773 'bmp' => 'image/bmp', 1774 'tif|tiff' => 'image/tiff', 1775 'ico' => 'image/x-icon', 1776 // Video formats 1777 'asf|asx|wax|wmv|wmx' => 'video/asf', 1778 'avi' => 'video/avi', 1779 'divx' => 'video/divx', 1780 'flv' => 'video/x-flv', 1781 'mov|qt' => 'video/quicktime', 1782 'mpeg|mpg|mpe' => 'video/mpeg', 1783 'mp4|m4v' => 'video/mp4', 1784 'ogv' => 'video/ogg', 1785 'mkv' => 'video/x-matroska', 1786 // Text formats 1787 'txt|asc|c|cc|h' => 'text/plain', 1788 'csv' => 'text/csv', 1789 'tsv' => 'text/tab-separated-values', 1790 'ics' => 'text/calendar', 1791 'rtx' => 'text/richtext', 1792 'css' => 'text/css', 1793 'htm|html' => 'text/html', 1794 // Audio formats 1795 'mp3|m4a|m4b' => 'audio/mpeg', 1796 'ra|ram' => 'audio/x-realaudio', 1797 'wav' => 'audio/wav', 1798 'ogg|oga' => 'audio/ogg', 1799 'mid|midi' => 'audio/midi', 1800 'wma' => 'audio/wma', 1801 'mka' => 'audio/x-matroska', 1802 // Misc application formats 1803 'rtf' => 'application/rtf', 1804 'js' => 'application/javascript', 1805 'pdf' => 'application/pdf', 1806 'swf' => 'application/x-shockwave-flash', 1807 'class' => 'application/java', 1808 'tar' => 'application/x-tar', 1809 'zip' => 'application/zip', 1810 'gz|gzip' => 'application/x-gzip', 1811 'rar' => 'application/rar', 1812 '7z' => 'application/x-7z-compressed', 1813 'exe' => 'application/x-msdownload', 1814 // MS Office formats 1815 'doc' => 'application/msword', 1816 'pot|pps|ppt' => 'application/vnd.ms-powerpoint', 1817 'wri' => 'application/vnd.ms-write', 1818 'xla|xls|xlt|xlw' => 'application/vnd.ms-excel', 1819 'mdb' => 'application/vnd.ms-access', 1820 'mpp' => 'application/vnd.ms-project', 1821 'docx' => 'application/vnd.openxmlformats-officedocument.wordprocessingml.document', 1822 'docm' => 'application/vnd.ms-word.document.macroEnabled.12', 1823 'dotx' => 'application/vnd.openxmlformats-officedocument.wordprocessingml.template', 1824 'dotm' => 'application/vnd.ms-word.template.macroEnabled.12', 1825 'xlsx' => 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet', 1826 'xlsm' => 'application/vnd.ms-excel.sheet.macroEnabled.12', 1827 'xlsb' => 'application/vnd.ms-excel.sheet.binary.macroEnabled.12', 1828 'xltx' => 'application/vnd.openxmlformats-officedocument.spreadsheetml.template', 1829 'xltm' => 'application/vnd.ms-excel.template.macroEnabled.12', 1830 'xlam' => 'application/vnd.ms-excel.addin.macroEnabled.12', 1831 'pptx' => 'application/vnd.openxmlformats-officedocument.presentationml.presentation', 1832 'pptm' => 'application/vnd.ms-powerpoint.presentation.macroEnabled.12', 1833 'ppsx' => 'application/vnd.openxmlformats-officedocument.presentationml.slideshow', 1834 'ppsm' => 'application/vnd.ms-powerpoint.slideshow.macroEnabled.12', 1835 'potx' => 'application/vnd.openxmlformats-officedocument.presentationml.template', 1836 'potm' => 'application/vnd.ms-powerpoint.template.macroEnabled.12', 1837 'ppam' => 'application/vnd.ms-powerpoint.addin.macroEnabled.12', 1838 'sldx' => 'application/vnd.openxmlformats-officedocument.presentationml.slide', 1839 'sldm' => 'application/vnd.ms-powerpoint.slide.macroEnabled.12', 1840 'onetoc|onetoc2|onetmp|onepkg' => 'application/onenote', 1841 // OpenOffice formats 1842 'odt' => 'application/vnd.oasis.opendocument.text', 1843 'odp' => 'application/vnd.oasis.opendocument.presentation', 1844 'ods' => 'application/vnd.oasis.opendocument.spreadsheet', 1845 'odg' => 'application/vnd.oasis.opendocument.graphics', 1846 'odc' => 'application/vnd.oasis.opendocument.chart', 1847 'odb' => 'application/vnd.oasis.opendocument.database', 1848 'odf' => 'application/vnd.oasis.opendocument.formula', 1849 // WordPerfect formats 1850 'wp|wpd' => 'application/wordperfect', 1851 ) ); 1852 } 1853 /** 1757 1854 * Retrieve list of allowed mime types and file extensions. 1758 1855 * … … 1760 1857 * 1761 1858 * @uses apply_filters() Calls 'upload_mimes' on returned array 1859 * @uses wp_get_upload_mime_types() to fetch the list of mime types 1860 * 1762 1861 * @return array Array of mime types keyed by the file extension regex corresponding to those types. 1763 1862 */ 1764 1863 function get_allowed_mime_types() { 1765 static $mimes = false; 1766 1767 if ( !$mimes ) { 1768 // Accepted MIME types are set here as PCRE unless provided. 1769 $mimes = apply_filters( 'upload_mimes', array( 1770 // Image formats 1771 'jpg|jpeg|jpe' => 'image/jpeg', 1772 'gif' => 'image/gif', 1773 'png' => 'image/png', 1774 'bmp' => 'image/bmp', 1775 'tif|tiff' => 'image/tiff', 1776 'ico' => 'image/x-icon', 1777 // Video formats 1778 'asf|asx|wax|wmv|wmx' => 'video/asf', 1779 'avi' => 'video/avi', 1780 'divx' => 'video/divx', 1781 'flv' => 'video/x-flv', 1782 'mov|qt' => 'video/quicktime', 1783 'mpeg|mpg|mpe' => 'video/mpeg', 1784 'mp4|m4v' => 'video/mp4', 1785 'ogv' => 'video/ogg', 1786 'mkv' => 'video/x-matroska', 1787 // Text formats 1788 'txt|asc|c|cc|h' => 'text/plain', 1789 'csv' => 'text/csv', 1790 'tsv' => 'text/tab-separated-values', 1791 'ics' => 'text/calendar', 1792 'rtx' => 'text/richtext', 1793 'css' => 'text/css', 1794 'htm|html' => 'text/html', 1795 // Audio formats 1796 'mp3|m4a|m4b' => 'audio/mpeg', 1797 'ra|ram' => 'audio/x-realaudio', 1798 'wav' => 'audio/wav', 1799 'ogg|oga' => 'audio/ogg', 1800 'mid|midi' => 'audio/midi', 1801 'wma' => 'audio/wma', 1802 'mka' => 'audio/x-matroska', 1803 // Misc application formats 1804 'rtf' => 'application/rtf', 1805 'js' => 'application/javascript', 1806 'pdf' => 'application/pdf', 1807 'swf' => 'application/x-shockwave-flash', 1808 'class' => 'application/java', 1809 'tar' => 'application/x-tar', 1810 'zip' => 'application/zip', 1811 'gz|gzip' => 'application/x-gzip', 1812 'rar' => 'application/rar', 1813 '7z' => 'application/x-7z-compressed', 1814 'exe' => 'application/x-msdownload', 1815 // MS Office formats 1816 'doc' => 'application/msword', 1817 'pot|pps|ppt' => 'application/vnd.ms-powerpoint', 1818 'wri' => 'application/vnd.ms-write', 1819 'xla|xls|xlt|xlw' => 'application/vnd.ms-excel', 1820 'mdb' => 'application/vnd.ms-access', 1821 'mpp' => 'application/vnd.ms-project', 1822 'docx' => 'application/vnd.openxmlformats-officedocument.wordprocessingml.document', 1823 'docm' => 'application/vnd.ms-word.document.macroEnabled.12', 1824 'dotx' => 'application/vnd.openxmlformats-officedocument.wordprocessingml.template', 1825 'dotm' => 'application/vnd.ms-word.template.macroEnabled.12', 1826 'xlsx' => 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet', 1827 'xlsm' => 'application/vnd.ms-excel.sheet.macroEnabled.12', 1828 'xlsb' => 'application/vnd.ms-excel.sheet.binary.macroEnabled.12', 1829 'xltx' => 'application/vnd.openxmlformats-officedocument.spreadsheetml.template', 1830 'xltm' => 'application/vnd.ms-excel.template.macroEnabled.12', 1831 'xlam' => 'application/vnd.ms-excel.addin.macroEnabled.12', 1832 'pptx' => 'application/vnd.openxmlformats-officedocument.presentationml.presentation', 1833 'pptm' => 'application/vnd.ms-powerpoint.presentation.macroEnabled.12', 1834 'ppsx' => 'application/vnd.openxmlformats-officedocument.presentationml.slideshow', 1835 'ppsm' => 'application/vnd.ms-powerpoint.slideshow.macroEnabled.12', 1836 'potx' => 'application/vnd.openxmlformats-officedocument.presentationml.template', 1837 'potm' => 'application/vnd.ms-powerpoint.template.macroEnabled.12', 1838 'ppam' => 'application/vnd.ms-powerpoint.addin.macroEnabled.12', 1839 'sldx' => 'application/vnd.openxmlformats-officedocument.presentationml.slide', 1840 'sldm' => 'application/vnd.ms-powerpoint.slide.macroEnabled.12', 1841 'onetoc|onetoc2|onetmp|onepkg' => 'application/onenote', 1842 // OpenOffice formats 1843 'odt' => 'application/vnd.oasis.opendocument.text', 1844 'odp' => 'application/vnd.oasis.opendocument.presentation', 1845 'ods' => 'application/vnd.oasis.opendocument.spreadsheet', 1846 'odg' => 'application/vnd.oasis.opendocument.graphics', 1847 'odc' => 'application/vnd.oasis.opendocument.chart', 1848 'odb' => 'application/vnd.oasis.opendocument.database', 1849 'odf' => 'application/vnd.oasis.opendocument.formula', 1850 // WordPerfect formats 1851 'wp|wpd' => 'application/wordperfect', 1852 ) ); 1853 } 1854 1855 return $mimes; 1864 return apply_filters( 'upload_mimes', wp_get_mime_types() ); 1856 1865 } 1857 1866
Note: See TracChangeset
for help on using the changeset viewer.