Skip to content

Instantly share code, notes, and snippets.

@bueltge
Last active February 21, 2021 23:13
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save bueltge/9466500 to your computer and use it in GitHub Desktop.
Save bueltge/9466500 to your computer and use it in GitHub Desktop.
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