Additional security & fix for mimetype filter hook

* [Bug fix] The new mimetype filter hook was called before the theme (and therefore the functions.php file) was loaded.
* [Security] Added some extra security measures