Enable upload of exe files in WordPress

PHP

// Allow upload of exe file type
add_filter( 'upload_mimes', 'themeslug_mime_types' );
function themeslug_mime_types( $mime_types ) {
    $mime_types[ 'exe' ]  = 'application/x-msdownload';
    return $mime_types;
}
add_filter( 'wp_check_filetype_and_ext', 'themeslug_wp_check_filetype_and_ext', 10, 4 );
function themeslug_wp_check_filetype_and_ext( $types, $file, $filename, $mimes ){
	if(substr($filename, -4) == ".exe" && $types['ext'] == "" && $types['type'] == ""){
        $filetype = wp_check_filetype( $filename, $mimes );
		$types['ext'] = $filetype['ext'];
		$types['type'] = $filetype['type'];
	}
	return $types;
}