Last active
February 21, 2021 23:13
-
-
Save bueltge/9466500 to your computer and use it in GitHub Desktop.
Change and Allow other mime types on upload
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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