Skip to content

Instantly share code, notes, and snippets.

@itzmekhokan
Created March 28, 2019 17:47
Show Gist options
  • Save itzmekhokan/925d8a4d00c6938ecabbb6748dab0317 to your computer and use it in GitHub Desktop.
Save itzmekhokan/925d8a4d00c6938ecabbb6748dab0317 to your computer and use it in GitHub Desktop.
to handle file types not permitted for security reasons
<?php
function add_allow_upload_extension_exception( $types, $file, $filename, $mimes ) {
// Do basic extension validation and MIME mapping
$wp_filetype = wp_check_filetype( $filename, $mimes );
$ext = $wp_filetype['ext'];
$type = $wp_filetype['type'];
if( in_array( $ext, array( 'ai', 'eps' ) ) ) { // if follows illustrator files have
$types['ext'] = $ext;
$types['type'] = $type;
}
return $types;
}
add_filter( 'wp_check_filetype_and_ext', 'add_allow_upload_extension_exception', 99, 4 );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment