WordPress.org

Ready to get started?Download WordPress

Forums

Fatal error: Call to undefined function get_allowed_mime_types() (3 posts)

  1. Treebeard
    Member
    Posted 4 years ago #

    Fatal error: Call to undefined function get_allowed_mime_types() in formatting.php on line 619

    Has anyone come across this one yet? I see this error when I'm trying to upgrade plugins and upgrade WP to version 2.9.

    Thanks!

  2. nthng
    Member
    Posted 4 years ago #

    I've got exactly the same problem.

    It first happened when i was trying to update the Google XML Sitemap plugin and now when i try to upgrade WordPress to 1.9 ...

    No idea what to do :(

  3. Meyway
    Member
    Posted 4 years ago #

    Hello there,

    I believe to have found (one) solution.

    I ran into that problem when uploading an image file with two extensions, say "xyz.jpg.gif". In that case wordpress will double-check allowed mime types.

    The function that is supposed to do that & that is called (in wp-includes/functions.php) seems to be removed from one of the newer wordpress versions (2.8.5 or 2.8.6) eventhough it is called in this situation. I think the latter version.

    So I copy-&-pasted the appropriate function at the end of functions.php:

    /**
    * Retrieve list of allowed mime types and file extensions.
    *
    * @since 2.8.6
    *
    * @return array Array of mime types keyed by the file extension regex corresponding to those types.
    */
    function get_allowed_mime_types() {
    static $mimes = false;

    if ( !$mimes ) {
    // Accepted MIME types are set here as PCRE unless provided.
    $mimes = apply_filters( 'upload_mimes', array(
    'jpg|jpeg|jpe' => 'image/jpeg',
    'gif' => 'image/gif',
    'png' => 'image/png',
    'bmp' => 'image/bmp',
    'tif|tiff' => 'image/tiff',
    'ico' => 'image/x-icon',
    'asf|asx|wax|wmv|wmx' => 'video/asf',
    'avi' => 'video/avi',
    'divx' => 'video/divx',
    'mov|qt' => 'video/quicktime',
    'mpeg|mpg|mpe' => 'video/mpeg',
    'txt|c|cc|h' => 'text/plain',
    'rtx' => 'text/richtext',
    'css' => 'text/css',
    'htm|html' => 'text/html',
    'mp3|m4a' => 'audio/mpeg',
    'mp4|m4v' => 'video/mp4',
    'ra|ram' => 'audio/x-realaudio',
    'wav' => 'audio/wav',
    'ogg' => 'audio/ogg',
    'mid|midi' => 'audio/midi',
    'wma' => 'audio/wma',
    'rtf' => 'application/rtf',
    'js' => 'application/javascript',
    'pdf' => 'application/pdf',
    'doc|docx' => 'application/msword',
    'pot|pps|ppt|pptx' => 'application/vnd.ms-powerpoint',
    'wri' => 'application/vnd.ms-write',
    'xla|xls|xlsx|xlt|xlw' => 'application/vnd.ms-excel',
    'mdb' => 'application/vnd.ms-access',
    'mpp' => 'application/vnd.ms-project',
    'swf' => 'application/x-shockwave-flash',
    'class' => 'application/java',
    'tar' => 'application/x-tar',
    'zip' => 'application/zip',
    'gz|gzip' => 'application/x-gzip',
    'exe' => 'application/x-msdownload',
    // openoffice formats
    'odt' => 'application/vnd.oasis.opendocument.text',
    'odp' => 'application/vnd.oasis.opendocument.presentation',
    'ods' => 'application/vnd.oasis.opendocument.spreadsheet',
    'odg' => 'application/vnd.oasis.opendocument.graphics',
    'odc' => 'application/vnd.oasis.opendocument.chart',
    'odb' => 'application/vnd.oasis.opendocument.database',
    'odf' => 'application/vnd.oasis.opendocument.formula',
    ) );
    }

    return $mimes;
    }

Topic Closed

This topic has been closed to new replies.

About this Topic