December 28, 2018 at 1:41 pm
Hello Team Kadence!
I’m enjoying the custom fonts plugin but as I run a multisite setup, I’ve run into the issue where the font files receive an error on upload (Sorry, this file type is not permitted for security reasons).
Luckily, this can be overcome by adding a custom function to the child theme (or creating a plugin). I can’t guarantee it’ll work for everyone but I’ve tested it on a few different servers and it works for me so I thought I’d share the code I found in case anyone else runs into this issue.
function add_custom_upload_mimes( $existing_mimes ) {
return array_merge( $existing_mimes, array(
'csv' => 'application/octet-stream',
'woff|woff2' => 'application/x-font',
'ttf' => 'application/x-font'
) );
return $existing_mimes;
}
add_filter( 'upload_mimes', 'add_custom_upload_mimes' );
Hope this helps someone.
PS. The only issue I seem to have is if the font file is already uploaded to media, when I try to add it via Custom Fonts using “add font” is that it does not see already added files and I have to upload the file again. Is that normal? Thanks!