sanitize_mime_type

The timeline below displays how wordpress function sanitize_mime_type has changed across different WordPress versions. If a version is not listed, refer to the next available version below.

WordPress Version: 6.1

// phpcs:enable
/**
 * Sanitizes a mime type
 *
 * @since 3.1.3
 *
 * @param string $mime_type Mime type.
 * @return string Sanitized mime type.
 */
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);
}

WordPress Version: 5.1

// phpcs:enable
/**
 * Sanitize a mime type
 *
 * @since 3.1.3
 *
 * @param string $mime_type Mime type
 * @return string Sanitized mime type
 */
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);
}

WordPress Version: 4.6

/**
 * Sanitize a mime type
 *
 * @since 3.1.3
 *
 * @param string $mime_type Mime type
 * @return string Sanitized mime type
 */
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);
}

WordPress Version: 3.8

/**
 * Sanitize a mime type
 *
 * @since 3.1.3
 *
 * @param string $mime_type Mime type
 * @return string Sanitized mime type
 */
function sanitize_mime_type($mime_type)
{
    $sani_mime_type = preg_replace('/[^-+*.a-zA-Z0-9\/]/', '', $mime_type);
    /**
     * Filter 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);
}

WordPress Version: 3.7

/**
 * Sanitize a mime type
 *
 * @since 3.1.3
 *
 * @param string $mime_type Mime type
 * @return string Sanitized mime type
 */
function sanitize_mime_type($mime_type)
{
    $sani_mime_type = preg_replace('/[^-+*.a-zA-Z0-9\/]/', '', $mime_type);
    return apply_filters('sanitize_mime_type', $sani_mime_type, $mime_type);
}