Switch language

wpseek.com
A WordPress-centric search engine for devs and theme authors




wp_match_mime_types [ WordPress Function ]

wp_match_mime_types ( $wildcard_mime_types, $real_mime_types )
Parameters:
  • (string|array) $wildcard_mime_types e.g. audio/mpeg or image (same as image/*) or flash (same as *flash*).
  • (string|array) $real_mime_types post_mime_type values
Returns:
  • (array) array(wildcard=>array(real types))
Defined at:



Check a MIME-Type against a list.

If the wildcard_mime_types parameter is a string, it must be comma separated list. If the real_mime_types is a string, it is also comma separated to create the list.

Source


<?php
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));
    
$wild '[-._a-z0-9]*';
    foreach ( (array) 
$wildcard_mime_types as $type ) {
        
$type str_replace('*'$wild$type);
        
$patternses[1][$type] = "^$type$";
        if ( 
false === strpos($type'/') ) {
            
$patternses[2][$type] = "^$type/";
            
$patternses[3][$type] = $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;
}
?>

Examples [ wp-snippets.com ]

Google Arama Sonuçlarý

Dahasý ...

Kullanýcý Tartýþmalarý [ wordpress.org ]

- Bulunamadý -

Yeni bir konu yaz ...

0 User Note(s)

Henüz yok. Ýlk sen ol!

Yeni Ekle ...



HTML5 Powered with CSS3 / Styling, Performance & Integration, and Semantics