sanitize_mime_type()WP 3.1.3

Sanitize a mime type

1 time — 0.000049 sec (very fast) | 50000 times — 0.04 sec (speed of light)
Hooks from the function

Return

String. Sanitized mime type.

Usage

sanitize_mime_type( $mime_type );
$mime_type(string) (required)
Mime type.

Changelog

Since 3.1.3 Introduced.

Code of sanitize_mime_type() WP 6.0

function sanitize_mime_type( $mime_type ) {
	$sani_mime_type = preg_replace( '/[^-+*.a-zA-Z0-9\/]/', '', $mime_type );
	/**
	 * Filters a mime type following sanitization.
	 *
	 * @since 3.1.3
	 *
	 * @param string $sani_mime_type The sanitized mime type.
	 * @param string $mime_type      The mime type prior to sanitization.
	 */
	return apply_filters( 'sanitize_mime_type', $sani_mime_type, $mime_type );
}