Make WordPress Core

Ticket #22949: functions.php.patch

File functions.php.patch, 2.0 KB (added by mattonomics, 12 years ago)
  • wp-includes/functions.php

     
    17661766 * @since 2.0.4
    17671767 *
    17681768 * @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.
    17701770 * @return array Values with extension first and mime type.
    17711771 */
    17721772function wp_check_filetype( $filename, $mimes = null ) {
    17731773        if ( empty($mimes) )
    17741774                $mimes = get_allowed_mime_types();
    1775         $type = false;
    1776         $ext = false;
     1775        $type = $ext = $break = false;
    17771776
    17781777        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)
    17831788                        break;
    1784                 }
    17851789        }
    17861790
    17871791        return compact( 'ext', 'type' );
     
    18631867 * @uses apply_filters() Calls 'mime_types' on returned array. This filter should
    18641868 * be used to add types, not remove them. To remove types use the upload_mimes filter.
    18651869 *
    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.
    18671871 */
    18681872function wp_get_mime_types() {
    18691873        // Accepted MIME types are set here as PCRE unless provided.
     
    18741878        'png' => 'image/png',
    18751879        'bmp' => 'image/bmp',
    18761880        'tif|tiff' => 'image/tiff',
    1877         'ico' => 'image/x-icon',
     1881        'ico' => array( 'image/x-icon', 'image/vnd.microsoft.icon' ),
    18781882        // Video formats
    18791883        'asf|asx|wax|wmv|wmx' => 'video/asf',
    18801884        'avi' => 'video/avi',