Skip to content

Instantly share code, notes, and snippets.

@camaleaun
Forked from jamesdixon/custom-fonts.php
Last active May 30, 2020 15:07
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save camaleaun/05d33fb819ed8d6f6d856eb2262ea5db to your computer and use it in GitHub Desktop.
Save camaleaun/05d33fb819ed8d6f6d856eb2262ea5db to your computer and use it in GitHub Desktop.
Wordpress Allow Custom Font Upload
<?php
/**
* Allow fonts upload
*
* @param array $mime_types Current allowed mime types.
* @return array $mime_types Modified mime types.
*/
function allow_upload_fonts_mimes_types( $mime_types ) {
$mime_types = array_merge(
$mime_types,
apply_filters(
'fonts_mime_types',
array(
'otf' => 'application/vnd.ms-opentype',
'woff' => 'application/x-font-woff',
'woff2' => 'application/x-font-woff',
'ttf' => 'font/sfnt',
'svg' => 'image/svg+xml',
'eot' => 'application/vnd.ms-fontobject'
)
)
);
return $mime_types;
}
add_filter( 'upload_mimes', 'allow_upload_fonts_mimes_types' );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment