-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathhabilita-arquivos-fontes-e-svg.php
30 lines (28 loc) · 1.15 KB
/
habilita-arquivos-fontes-e-svg.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
<?php
// habilita arquivos woff, woff2 e imagens svg
function afc_add_fonts_to_allowed_mimes( $mimes = array() ) {
$mimes['woff'] = 'application/x-font-woff';
$mimes['woff2'] = 'application/x-font-woff2';
$mimes['svg'] = 'image/svg+xml';
$mimes['svgz'] = 'image/svg+xml';
// era para ser esses abaixo, mas o WP nao atualizou o core
// $mimes['woff'] = 'font/woff';
// $mimes['woff2'] = 'font/woff2';
return $mimes;
} add_filter( 'upload_mimes', 'afc_add_fonts_to_allowed_mimes');
// evita erros de alerta de seguranca na leitura do svg
function afc_add_fonts_fix_mime_type_svg( $data = null, $file = null, $filename = null, $mimes = null ) {
$ext = isset( $data['ext'] ) ? $data['ext'] : '';
if ( strlen( $ext ) < 1 ) {
$exploded = explode( '.', $filename );
$ext = strtolower( end( $exploded ) );
}
if ( $ext === 'svg' ) {
$data['type'] = 'image/svg+xml';
$data['ext'] = 'svg';
} elseif ( $ext === 'svgz' ) {
$data['type'] = 'image/svg+xml';
$data['ext'] = 'svgz';
}
return $data;
} add_filter( 'wp_check_filetype_and_ext', 'afc_add_fonts_fix_mime_type_svg' , 75, 4 );