Preview:
/*WP-CONFIG.PHP*/
define('ALLOW_UNFILTERED_UPLOADS', true);

/*ANEBO - DÁT DO FUNCTIONS.PHP*/
global $da_allowed_mimes;
$da_allowed_mimes = ['ttf' => 'application/x-font-ttf','otf' => 'application/x-font-otf','woff' => 'application/x-font-woff','woff2' => 'application/x-font-woff2'];

/**
 * Allow Custom Mime
 *
 * @param $mimes
 *
 * @return mixed
 */
if (!function_exists('pac_da_upload_mimes')):
    function pac_da_upload_mimes($mimes)
    {
        global $da_allowed_mimes;
        foreach ($da_allowed_mimes as $key => $val) {
            $mimes[$key] = $val;
        }

        return $mimes;
    }
endif;


/**
 * Allow Divi To Upload Fonts Format
 *
 * @return string[]
 */
if (!function_exists('pac_da_filter_divi_supportedt_font_formats')):
    function pac_da_filter_divi_supportedt_font_formats()
    {
        return ['otf', 'woff', 'woff2', 'ttf'];
    }

    add_filter('et_pb_supported_font_formats', 'pac_da_filter_divi_supportedt_font_formats', 999);
endif;

/**
 * Fixes the issue in WordPress 4.7.1 being unable to correctly identify type
 *
 * @param $file
 * @param $tmp_file
 * @param $filename
 * @param $mimes
 *
 * @return array|mixed|null
 */
if (!function_exists('pac_da_fix_mime_type_ext')):
    function pac_da_fix_mime_type_ext($file, $tmp_file, $filename, $mimes)
    {
        // Get File Ext.
        if (isset($file['ext']) && empty($file['ext'])) {
            $file_ext = strtolower(pathinfo($filename, PATHINFO_EXTENSION));
            // Set File Ext.
            global $da_allowed_mimes;
            foreach ($da_allowed_mimes as $key => $val) {
                if ($key === $file_ext) {
                    $file['ext'] = $key;
                    $file['type'] = $val;
                }
            }
        }

        return $file;
    }
endif;
if (current_user_can('administrator')) {
    add_filter('upload_mimes', 'pac_da_upload_mimes');
    add_filter('wp_check_filetype_and_ext', 'pac_da_fix_mime_type_ext', 75, 4);
}
downloadDownload PNG downloadDownload JPEG downloadDownload SVG

Tip: You can change the style, width & colours of the snippet with the inspect tool before clicking Download!

Click to optimize width for Twitter