sanitize_mime_type
Sanitize a mime type.
Description
(string) sanitize_mime_type( (string) $mime_type );
Returns (string)
Sanitized mime type
Parameters (1)
- 0. $mime_type (string)
- The mime type.
Usage
if ( !function_exists( 'sanitize_mime_type' ) ) { require_once ABSPATH . WPINC . '/formatting.php'; } // The mime type. $mime_type = ''; // NOTICE! Understand what this does before running. $result = sanitize_mime_type($mime_type);
Defined (1)
The function is defined in the following location(s).
- /wp-includes/formatting.php
- 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 );
- }