wp_get_ext_types()
Retrieves the list of common file extensions and their types.
1 time — 0.00001 sec (speed of light) | 50000 times — 0.01 sec (speed of light) | PHP 7.0.8, WP 4.6
Hooks from the function
Return
Array[]
. Multi-dimensional array of file extensions types keyed by the type of file.
Usage
wp_get_ext_types();
Examples
#1 Get an array of all extensions
$ext = wp_get_ext_types(); /* $ext will contain: array ( 'image' => array ( 0 => 'jpg', 1 => 'jpeg', 2 => 'jpe', 3 => 'gif', 4 => 'png', 5 => 'bmp', 6 => 'tif', 7 => 'tiff', 8 => 'ico', ), 'audio' => array ( 0 => 'aac', 1 => 'ac3', 2 => 'aif', 3 => 'aiff', 4 => 'm3a', 5 => 'm4a', 6 => 'm4b', 7 => 'mka', 8 => 'mp1', 9 => 'mp2', 10 => 'mp3', 11 => 'ogg', 12 => 'oga', 13 => 'ram', 14 => 'wav', 15 => 'wma', ), 'video' => array ( 0 => '3g2', 1 => '3gp', 2 => '3gpp', 3 => 'asf', 4 => 'avi', 5 => 'divx', 6 => 'dv', 7 => 'flv', 8 => 'm4v', 9 => 'mkv', 10 => 'mov', 11 => 'mp4', 12 => 'mpeg', 13 => 'mpg', 14 => 'mpv', 15 => 'ogm', 16 => 'ogv', 17 => 'qt', 18 => 'rm', 19 => 'vob', 20 => 'wmv', ), 'document' => array ( 0 => 'doc', 1 => 'docx', 2 => 'docm', 3 => 'dotm', 4 => 'odt', 5 => 'pages', 6 => 'pdf', 7 => 'xps', 8 => 'oxps', 9 => 'rtf', 10 => 'wp', 11 => 'wpd', 12 => 'psd', 13 => 'xcf', ), 'spreadsheet' => array ( 0 => 'numbers', 1 => 'ods', 2 => 'xls', 3 => 'xlsx', 4 => 'xlsm', 5 => 'xlsb', ), 'interactive' => array ( 0 => 'swf', 1 => 'key', 2 => 'ppt', 3 => 'pptx', 4 => 'pptm', 5 => 'pps', 6 => 'ppsx', 7 => 'ppsm', 8 => 'sldx', 9 => 'sldm', 10 => 'odp', ), 'text' => array ( 0 => 'asc', 1 => 'csv', 2 => 'tsv', 3 => 'txt', ), 'archive' => array ( 0 => 'bz2', 1 => 'cab', 2 => 'dmg', 3 => 'gz', 4 => 'rar', 5 => 'sea', 6 => 'sit', 7 => 'sqx', 8 => 'tar', 9 => 'tgz', 10 => 'zip', 11 => '7z', ), 'code' => array ( 0 => 'css', 1 => 'htm', 2 => 'html', 3 => 'php', 4 => 'js', ), ) */
Changelog
Since 4.6.0 | Introduced. |