Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Change and Allow other mime types on upload
<?php
/**
* Plugin Name: Mime Types
* Description: Allow other mime types on upload
* Plugin URI:
* Version: 1.0.0
* Author: Frank Bültge
* Author URI: http://bueltge.de
* License: GPLv2
* License URI: ./assets/license.txt
* Text Domain: mime-types
* Domain Path: /languages
*/
! defined( 'ABSPATH' ) && exit;
add_filter( 'upload_mimes', 'fb_custom_upload_mimes' );
/**
* Change default mime types
*
* @see wp-includes/functions.php wp_check_filetype_and_ext(), wp_get_mime_types()
*
* @param Array with existing Mime Types
* @return Array
*/
function custom_upload_mimes ( $mimes = array() ) {
// add new extension to the array
$mimes[ 'swf' ] = 'application/x-shockwave-flash';
$mimes[ 'doc' ] = 'application/msword';
$mimes[ 'pdf' ] = 'application/pdf';
$mimes[ 'ppt' ] = 'application/powerpoint';
// removing existing file types
unset( $mimes[ 'exe' ] );
return $mimes;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment