check_upload_mimes

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

WordPress Version: 6.3

//
// Misc functions.
//
/**
 * Checks an array of MIME types against a list of allowed types.
 *
 * WordPress ships with a set of allowed upload filetypes,
 * which is defined in wp-includes/functions.php in
 * get_allowed_mime_types(). This function is used to filter
 * that list against the filetypes allowed provided by Multisite
 * Super Admins at wp-admin/network/settings.php.
 *
 * @since MU (3.0.0)
 *
 * @param array $mimes
 * @return array
 */
function check_upload_mimes($mimes)
{
    $site_exts = explode(' ', get_site_option('upload_filetypes', 'jpg jpeg png gif'));
    $site_mimes = array();
    foreach ($site_exts as $ext) {
        foreach ($mimes as $ext_pattern => $mime) {
            if ('' !== $ext && str_contains($ext_pattern, $ext)) {
                $site_mimes[$ext_pattern] = $mime;
            }
        }
    }
    return $site_mimes;
}

WordPress Version: 6.1

//
// Misc functions.
//
/**
 * Checks an array of MIME types against a list of allowed types.
 *
 * WordPress ships with a set of allowed upload filetypes,
 * which is defined in wp-includes/functions.php in
 * get_allowed_mime_types(). This function is used to filter
 * that list against the filetypes allowed provided by Multisite
 * Super Admins at wp-admin/network/settings.php.
 *
 * @since MU (3.0.0)
 *
 * @param array $mimes
 * @return array
 */
function check_upload_mimes($mimes)
{
    $site_exts = explode(' ', get_site_option('upload_filetypes', 'jpg jpeg png gif'));
    $site_mimes = array();
    foreach ($site_exts as $ext) {
        foreach ($mimes as $ext_pattern => $mime) {
            if ('' !== $ext && false !== strpos($ext_pattern, $ext)) {
                $site_mimes[$ext_pattern] = $mime;
            }
        }
    }
    return $site_mimes;
}

WordPress Version: 5.5

//
// Misc functions.
//
/**
 * Check an array of MIME types against a list of allowed types.
 *
 * WordPress ships with a set of allowed upload filetypes,
 * which is defined in wp-includes/functions.php in
 * get_allowed_mime_types(). This function is used to filter
 * that list against the filetypes allowed provided by Multisite
 * Super Admins at wp-admin/network/settings.php.
 *
 * @since MU (3.0.0)
 *
 * @param array $mimes
 * @return array
 */
function check_upload_mimes($mimes)
{
    $site_exts = explode(' ', get_site_option('upload_filetypes', 'jpg jpeg png gif'));
    $site_mimes = array();
    foreach ($site_exts as $ext) {
        foreach ($mimes as $ext_pattern => $mime) {
            if ('' !== $ext && false !== strpos($ext_pattern, $ext)) {
                $site_mimes[$ext_pattern] = $mime;
            }
        }
    }
    return $site_mimes;
}

WordPress Version: 5.4

//
// Misc functions.
//
/**
 * Check an array of MIME types against a whitelist.
 *
 * WordPress ships with a set of allowed upload filetypes,
 * which is defined in wp-includes/functions.php in
 * get_allowed_mime_types(). This function is used to filter
 * that list against the filetype whitelist provided by Multisite
 * Super Admins at wp-admin/network/settings.php.
 *
 * @since MU (3.0.0)
 *
 * @param array $mimes
 * @return array
 */
function check_upload_mimes($mimes)
{
    $site_exts = explode(' ', get_site_option('upload_filetypes', 'jpg jpeg png gif'));
    $site_mimes = array();
    foreach ($site_exts as $ext) {
        foreach ($mimes as $ext_pattern => $mime) {
            if ('' != $ext && false !== strpos($ext_pattern, $ext)) {
                $site_mimes[$ext_pattern] = $mime;
            }
        }
    }
    return $site_mimes;
}

WordPress Version: 5.2

// Misc functions
/**
 * Check an array of MIME types against a whitelist.
 *
 * WordPress ships with a set of allowed upload filetypes,
 * which is defined in wp-includes/functions.php in
 * get_allowed_mime_types(). This function is used to filter
 * that list against the filetype whitelist provided by Multisite
 * Super Admins at wp-admin/network/settings.php.
 *
 * @since MU (3.0.0)
 *
 * @param array $mimes
 * @return array
 */
function check_upload_mimes($mimes)
{
    $site_exts = explode(' ', get_site_option('upload_filetypes', 'jpg jpeg png gif'));
    $site_mimes = array();
    foreach ($site_exts as $ext) {
        foreach ($mimes as $ext_pattern => $mime) {
            if ($ext != '' && strpos($ext_pattern, $ext) !== false) {
                $site_mimes[$ext_pattern] = $mime;
            }
        }
    }
    return $site_mimes;
}

WordPress Version: 4.9

/**
 * Check an array of MIME types against a whitelist.
 *
 * WordPress ships with a set of allowed upload filetypes,
 * which is defined in wp-includes/functions.php in
 * get_allowed_mime_types(). This function is used to filter
 * that list against the filetype whitelist provided by Multisite
 * Super Admins at wp-admin/network/settings.php.
 *
 * @since MU (3.0.0)
 *
 * @param array $mimes
 * @return array
 */
function check_upload_mimes($mimes)
{
    $site_exts = explode(' ', get_site_option('upload_filetypes', 'jpg jpeg png gif'));
    $site_mimes = array();
    foreach ($site_exts as $ext) {
        foreach ($mimes as $ext_pattern => $mime) {
            if ($ext != '' && strpos($ext_pattern, $ext) !== false) {
                $site_mimes[$ext_pattern] = $mime;
            }
        }
    }
    return $site_mimes;
}

WordPress Version: 4.1

/**
 * Check an array of MIME types against a whitelist.
 *
 * WordPress ships with a set of allowed upload filetypes,
 * which is defined in wp-includes/functions.php in
 * get_allowed_mime_types(). This function is used to filter
 * that list against the filetype whitelist provided by Multisite
 * Super Admins at wp-admin/network/settings.php.
 *
 * @since MU
 *
 * @param array $mimes
 * @return array
 */
function check_upload_mimes($mimes)
{
    $site_exts = explode(' ', get_site_option('upload_filetypes', 'jpg jpeg png gif'));
    $site_mimes = array();
    foreach ($site_exts as $ext) {
        foreach ($mimes as $ext_pattern => $mime) {
            if ($ext != '' && strpos($ext_pattern, $ext) !== false) {
                $site_mimes[$ext_pattern] = $mime;
            }
        }
    }
    return $site_mimes;
}

WordPress Version: 3.7

/**
 * Check an array of MIME types against a whitelist.
 *
 * WordPress ships with a set of allowed upload filetypes,
 * which is defined in wp-includes/functions.php in
 * get_allowed_mime_types(). This function is used to filter
 * that list against the filetype whitelist provided by Multisite
 * Super Admins at wp-admin/network/settings.php.
 *
 * @since MU
 *
 * @param array $mimes
 * @return array
 */
function check_upload_mimes($mimes)
{
    $site_exts = explode(' ', get_site_option('upload_filetypes'));
    foreach ($site_exts as $ext) {
        foreach ($mimes as $ext_pattern => $mime) {
            if ($ext != '' && strpos($ext_pattern, $ext) !== false) {
                $site_mimes[$ext_pattern] = $mime;
            }
        }
    }
    return $site_mimes;
}