WP_Font_Utils::get_allowed_font_mime_typespublic staticWP 6.5.0

Returns the expected mime-type values for font files, depending on PHP version.

This is needed because font mime types vary by PHP version, so checking the PHP version is necessary until a list of valid mime-types for each file extension can be provided to the upload_mimes

Method of the class: WP_Font_Utils{}

Internal function — this function is designed to be used by the kernel itself. It is not recommended to use this function in your code.

No Hooks.

Returns

String[]. A collection of mime types keyed by file extension.

Usage

$result = WP_Font_Utils::get_allowed_font_mime_types();

Changelog

Since 6.5.0 Introduced.

WP_Font_Utils::get_allowed_font_mime_types() code WP 7.0

public static function get_allowed_font_mime_types() {
	$php_7_ttf_mime_type = PHP_VERSION_ID >= 70300 ? 'application/font-sfnt' : 'application/x-font-ttf';

	return array(
		'otf'   => 'application/vnd.ms-opentype',
		'ttf'   => PHP_VERSION_ID >= 70400 ? 'font/sfnt' : $php_7_ttf_mime_type,
		'woff'  => PHP_VERSION_ID >= 80112 ? 'font/woff' : 'application/font-woff',
		'woff2' => PHP_VERSION_ID >= 80112 ? 'font/woff2' : 'application/font-woff2',
	);
}