Make WordPress Core

Changeset 21527


Ignore:
Timestamp:
08/15/2012 04:48:36 PM (14 years ago)
Author:
ryan
Message:

Fix MS Office mime types. Group the mime list in get_allowed_mime_types() by type. Props hebbet, markel, SergeyBiryukov. fixes #17117

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/wp-includes/functions.php

    r21485 r21527  
    16431643function wp_ext2type( $ext ) {
    16441644        $ext2type = apply_filters( 'ext2type', array(
    1645                 'audio'       => array( 'aac', 'ac3',  'aif',  'aiff', 'm3a',  'm4a',   'm4b', 'mka', 'mp1', 'mp2',  'mp3', 'ogg', 'oga', 'ram', 'wav', 'wma' ),
    1646                 'video'       => array( 'asf', 'avi',  'divx', 'dv',   'flv',  'm4v',   'mkv', 'mov', 'mp4', 'mpeg', 'mpg', 'mpv', 'ogm', 'ogv', 'qt',  'rm', 'vob', 'wmv' ),
    1647                 'document'    => array( 'doc', 'docx', 'docm', 'dotm', 'odt',  'pages', 'pdf', 'rtf', 'wp',  'wpd' ),
    1648                 'spreadsheet' => array( 'numbers',     'ods',  'xls',  'xlsx', 'xlsb',  'xlsm' ),
    1649                 'interactive' => array( 'key', 'ppt',  'pptx', 'pptm', 'odp',  'swf' ),
     1645                'audio'       => array( 'aac', 'ac3',  'aif',  'aiff', 'm3a',  'm4a',   'm4b',  'mka',  'mp1', 'mp2',  'mp3', 'ogg', 'oga', 'ram', 'wav', 'wma' ),
     1646                'video'       => array( 'asf', 'avi',  'divx', 'dv',   'flv',  'm4v',   'mkv',  'mov',  'mp4', 'mpeg', 'mpg', 'mpv', 'ogm', 'ogv', 'qt',  'rm', 'vob', 'wmv' ),
     1647                'document'    => array( 'doc', 'docx', 'docm', 'dotm', 'odt',  'pages', 'pdf',  'rtf',  'wp',   'wpd' ),
     1648                'spreadsheet' => array( 'numbers',     'ods',  'xls',  'xlsx', 'xlsm',  'xlsb' ),
     1649                'interactive' => array( 'swf', 'key',  'ppt',  'pptx', 'pptm', 'pps',   'ppsx', 'ppsm', 'sldx', 'sldm', 'odp' ),
    16501650                'text'        => array( 'asc', 'csv',  'tsv',  'txt' ),
    1651                 'archive'     => array( 'bz2', 'cab',  'dmg',  'gz',   'rar',  'sea',   'sit', 'sqx', 'tar', 'tgz',  'zip', '7z' ),
     1651                'archive'     => array( 'bz2', 'cab',  'dmg',  'gz',   'rar',  'sea',   'sit',  'sqx',  'tar', 'tgz',  'zip', '7z' ),
    16521652                'code'        => array( 'css', 'htm',  'html', 'php',  'js' ),
    16531653        ));
     
    17681768                // Accepted MIME types are set here as PCRE unless provided.
    17691769                $mimes = apply_filters( 'upload_mimes', array(
     1770                // Image formats
    17701771                'jpg|jpeg|jpe' => 'image/jpeg',
    17711772                'gif' => 'image/gif',
     
    17741775                'tif|tiff' => 'image/tiff',
    17751776                'ico' => 'image/x-icon',
     1777                // Video formats
    17761778                'asf|asx|wax|wmv|wmx' => 'video/asf',
    17771779                'avi' => 'video/avi',
     
    17801782                'mov|qt' => 'video/quicktime',
    17811783                'mpeg|mpg|mpe' => 'video/mpeg',
     1784                'mp4|m4v' => 'video/mp4',
     1785                'ogv' => 'video/ogg',
     1786                'mkv' => 'video/x-matroska',
     1787                // Text formats
    17821788                'txt|asc|c|cc|h' => 'text/plain',
    17831789                'csv' => 'text/csv',
     
    17871793                'css' => 'text/css',
    17881794                'htm|html' => 'text/html',
     1795                // Audio formats
    17891796                'mp3|m4a|m4b' => 'audio/mpeg',
    1790                 'mp4|m4v' => 'video/mp4',
    17911797                'ra|ram' => 'audio/x-realaudio',
    17921798                'wav' => 'audio/wav',
    17931799                'ogg|oga' => 'audio/ogg',
    1794                 'ogv' => 'video/ogg',
    17951800                'mid|midi' => 'audio/midi',
    17961801                'wma' => 'audio/wma',
    17971802                'mka' => 'audio/x-matroska',
    1798                 'mkv' => 'video/x-matroska',
     1803                // Misc application formats
    17991804                'rtf' => 'application/rtf',
    18001805                'js' => 'application/javascript',
    18011806                'pdf' => 'application/pdf',
    1802                 'doc|docx' => 'application/msword',
    1803                 'pot|pps|ppt|pptx|ppam|pptm|sldm|ppsm|potm' => 'application/vnd.ms-powerpoint',
    1804                 'wri' => 'application/vnd.ms-write',
    1805                 'xla|xls|xlsx|xlt|xlw|xlam|xlsb|xlsm|xltm' => 'application/vnd.ms-excel',
    1806                 'mdb' => 'application/vnd.ms-access',
    1807                 'mpp' => 'application/vnd.ms-project',
    1808                 'docm|dotm' => 'application/vnd.ms-word',
    1809                 'pptx|sldx|ppsx|potx' => 'application/vnd.openxmlformats-officedocument.presentationml',
    1810                 'xlsx|xltx' => 'application/vnd.openxmlformats-officedocument.spreadsheetml',
    1811                 'docx|dotx' => 'application/vnd.openxmlformats-officedocument.wordprocessingml',
    1812                 'onetoc|onetoc2|onetmp|onepkg' => 'application/onenote',
    18131807                'swf' => 'application/x-shockwave-flash',
    18141808                'class' => 'application/java',
     
    18191813                '7z' => 'application/x-7z-compressed',
    18201814                'exe' => 'application/x-msdownload',
    1821                 // openoffice formats
     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
    18221843                'odt' => 'application/vnd.oasis.opendocument.text',
    18231844                'odp' => 'application/vnd.oasis.opendocument.presentation',
     
    18271848                'odb' => 'application/vnd.oasis.opendocument.database',
    18281849                'odf' => 'application/vnd.oasis.opendocument.formula',
    1829                 // wordperfect formats
     1850                // WordPerfect formats
    18301851                'wp|wpd' => 'application/wordperfect',
    18311852                ) );
Note: See TracChangeset for help on using the changeset viewer.