Changeset 28553 for trunk/src/wp-includes/post.php
- Timestamp:
- 05/22/2014 09:35:36 PM (11 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-includes/post.php
r28471 r28553 2330 2330 * @return array array(wildcard=>array(real types)) 2331 2331 */ 2332 function wp_match_mime_types( $wildcard_mime_types, $real_mime_types) {2332 function wp_match_mime_types( $wildcard_mime_types, $real_mime_types ) { 2333 2333 $matches = array(); 2334 if ( is_string($wildcard_mime_types) ) 2335 $wildcard_mime_types = array_map('trim', explode(',', $wildcard_mime_types)); 2336 if ( is_string($real_mime_types) ) 2337 $real_mime_types = array_map('trim', explode(',', $real_mime_types)); 2334 if ( is_string( $wildcard_mime_types ) ) { 2335 $wildcard_mime_types = array_map( 'trim', explode( ',', $wildcard_mime_types ) ); 2336 } 2337 if ( is_string( $real_mime_types ) ) { 2338 $real_mime_types = array_map( 'trim', explode( ',', $real_mime_types ) ); 2339 } 2340 2341 $patternses = array(); 2338 2342 $wild = '[-._a-z0-9]*'; 2343 2339 2344 foreach ( (array) $wildcard_mime_types as $type ) { 2340 $ type = str_replace('*', $wild, $type);2341 $patternses[1][$type] = "^$ type$";2345 $regex = str_replace( '__wildcard__', $wild, preg_quote( str_replace( '*', '__wildcard__', $type ) ) ); 2346 $patternses[1][$type] = "^$regex$"; 2342 2347 if ( false === strpos($type, '/') ) { 2343 $patternses[2][$type] = "^$type/"; 2344 $patternses[3][$type] = $type; 2345 } 2346 } 2347 asort($patternses); 2348 foreach ( $patternses as $patterns ) 2349 foreach ( $patterns as $type => $pattern ) 2350 foreach ( (array) $real_mime_types as $real ) 2351 if ( preg_match("#$pattern#", $real) && ( empty($matches[$type]) || false === array_search($real, $matches[$type]) ) ) 2348 $patternses[2][$type] = "^$regex/"; 2349 $patternses[3][$type] = $regex; 2350 } 2351 } 2352 asort( $patternses ); 2353 2354 foreach ( $patternses as $patterns ) { 2355 foreach ( $patterns as $type => $pattern ) { 2356 foreach ( (array) $real_mime_types as $real ) { 2357 if ( preg_match( "#$pattern#", $real ) && ( empty( $matches[$type] ) || false === array_search( $real, $matches[$type] ) ) ) { 2352 2358 $matches[$type][] = $real; 2359 } 2360 } 2361 } 2362 } 2353 2363 return $matches; 2354 2364 }
Note: See TracChangeset
for help on using the changeset viewer.