mirror of
https://github.com/gosticks/wordpress-develop.git
synced 2026-04-07 22:24:36 +00:00
Fix parsing in wp_match_mime_types() to allow some mime-types with + in them to appear in the list of filter links shown above the list table on upload.php.
Props _duck. Fixes #20672. git-svn-id: https://develop.svn.wordpress.org/trunk@28553 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
@@ -2329,27 +2329,37 @@ function get_post_mime_types() {
|
||||
* @param string|array $real_mime_types post_mime_type values
|
||||
* @return array array(wildcard=>array(real types))
|
||||
*/
|
||||
function wp_match_mime_types($wildcard_mime_types, $real_mime_types) {
|
||||
function wp_match_mime_types( $wildcard_mime_types, $real_mime_types ) {
|
||||
$matches = array();
|
||||
if ( is_string($wildcard_mime_types) )
|
||||
$wildcard_mime_types = array_map('trim', explode(',', $wildcard_mime_types));
|
||||
if ( is_string($real_mime_types) )
|
||||
$real_mime_types = array_map('trim', explode(',', $real_mime_types));
|
||||
if ( is_string( $wildcard_mime_types ) ) {
|
||||
$wildcard_mime_types = array_map( 'trim', explode( ',', $wildcard_mime_types ) );
|
||||
}
|
||||
if ( is_string( $real_mime_types ) ) {
|
||||
$real_mime_types = array_map( 'trim', explode( ',', $real_mime_types ) );
|
||||
}
|
||||
|
||||
$patternses = array();
|
||||
$wild = '[-._a-z0-9]*';
|
||||
|
||||
foreach ( (array) $wildcard_mime_types as $type ) {
|
||||
$type = str_replace('*', $wild, $type);
|
||||
$patternses[1][$type] = "^$type$";
|
||||
$regex = str_replace( '__wildcard__', $wild, preg_quote( str_replace( '*', '__wildcard__', $type ) ) );
|
||||
$patternses[1][$type] = "^$regex$";
|
||||
if ( false === strpos($type, '/') ) {
|
||||
$patternses[2][$type] = "^$type/";
|
||||
$patternses[3][$type] = $type;
|
||||
$patternses[2][$type] = "^$regex/";
|
||||
$patternses[3][$type] = $regex;
|
||||
}
|
||||
}
|
||||
asort($patternses);
|
||||
foreach ( $patternses as $patterns )
|
||||
foreach ( $patterns as $type => $pattern )
|
||||
foreach ( (array) $real_mime_types as $real )
|
||||
if ( preg_match("#$pattern#", $real) && ( empty($matches[$type]) || false === array_search($real, $matches[$type]) ) )
|
||||
asort( $patternses );
|
||||
|
||||
foreach ( $patternses as $patterns ) {
|
||||
foreach ( $patterns as $type => $pattern ) {
|
||||
foreach ( (array) $real_mime_types as $real ) {
|
||||
if ( preg_match( "#$pattern#", $real ) && ( empty( $matches[$type] ) || false === array_search( $real, $matches[$type] ) ) ) {
|
||||
$matches[$type][] = $real;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return $matches;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user