WP_Font_Utils::get_allowed_font_mime_types(): string[]

In this article

This function’s access is marked private. This means it is not intended for use by plugin or theme developers, only in other core functions. It is listed here for completeness.

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

Description

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’ filter.

Return

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

Source

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',
	);
}

Changelog

VersionDescription
6.5.0Introduced.

User Contributed Notes

You must log in before being able to contribute a note or feedback.