I’m about to implement the filter/function below to be able to get control of the file types a user can upload to the WordPress application I’m working on. However, the list of mime types is very long and I don’t want to put it directly into functions.php but instead loop through an external file that holds the different mime types.
How can this be done?
<?php
add_filter('upload_mimes', 'custom_upload_mimes');
function custom_upload_mimes ( $existing_mimes = array() ) {
$existing_mimes['ppt'] = 'application/vnd.ms-powerpoint';
...+ ~50 more...
return $existing_mimes;
}
?>
functions.php
is not the place to put this, you should build a plugin.Check the Codex: Writing a Plugin.
Basically:
See this WordPress Answer: Where to put my code: plugin or functions.php?
If you really want to read an external file for this, check this search query.