WordPress.org

Make WordPress Core

Changeset 31042


Ignore:
Timestamp:
01/04/2015 02:31:29 AM (5 years ago)
Author:
wonderboymusic
Message:

Improve the handling of comma-separated mime-types in wp_match_mime_types(), particularly as pertains to the mime-type selector on the Media list table screen.

Props mdgl.
Fixes #30788.

Location:
trunk/src
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-admin/includes/class-wp-media-list-table.php

    r30813 r31042  
    7676                $selected = ' selected="selected"';
    7777            if ( !empty( $num_posts[$mime_type] ) )
    78                 $type_links[$mime_type] = '<option value="post_mime_type:' . sanitize_mime_type( $mime_type ) . '"' . $selected . '>' . sprintf( translate_nooped_plural( $label[2], $num_posts[$mime_type] ), number_format_i18n( $num_posts[$mime_type] )) . '</option>';
     78                $type_links[$mime_type] = '<option value="post_mime_type:' . esc_attr( $mime_type ) . '"' . $selected . '>' . sprintf( translate_nooped_plural( $label[2], $num_posts[$mime_type] ), number_format_i18n( $num_posts[$mime_type] )) . '</option>';
    7979        }
    8080        $type_links['detached'] = '<option value="detached"' . ( $this->detached ? ' selected="selected"' : '' ) . '>' . sprintf( _nx( 'Unattached (%s)', 'Unattached (%s)', $total_orphans, 'detached files' ), number_format_i18n( $total_orphans ) ) . '</option>';
  • trunk/src/wp-includes/post.php

    r31020 r31042  
    24792479
    24802480    foreach ( (array) $wildcard_mime_types as $type ) {
    2481         $regex = str_replace( '__wildcard__', $wild, preg_quote( str_replace( '*', '__wildcard__', $type ) ) );
    2482         $patternses[1][$type] = "^$regex$";
    2483         if ( false === strpos($type, '/') ) {
    2484             $patternses[2][$type] = "^$regex/";
    2485             $patternses[3][$type] = $regex;
     2481        $mimes = array_map( 'trim', explode( ',', $type ) );
     2482        foreach ( $mimes as $mime ) {
     2483            $regex = str_replace( '__wildcard__', $wild, preg_quote( str_replace( '*', '__wildcard__', $mime ) ) );
     2484            $patternses[][$type] = "^$regex$";
     2485            if ( false === strpos( $mime, '/' ) ) {
     2486                $patternses[][$type] = "^$regex/";
     2487                $patternses[][$type] = $regex;
     2488            }
    24862489        }
    24872490    }
Note: See TracChangeset for help on using the changeset viewer.