Skip to content

Instantly share code, notes, and snippets.

@reachkamrul
Last active November 26, 2022 05:37
Show Gist options
  • Save reachkamrul/0c38409bf34bf9a993ca01ba555521d1 to your computer and use it in GitHub Desktop.
Save reachkamrul/0c38409bf34bf9a993ca01ba555521d1 to your computer and use it in GitHub Desktop.
/*
* The following functions will add additional file types option to your file upload element
* In this case, You can enable STL, MAX, DWG, STEP, OBJ, FBX, Ect file format
* Just add this snippet to your theme's functions.php file or relevant place.
*/
add_filter('fluentform_file_type_options', function ($types) {
$types[] = [
'label' => __('3d files - DWG, STL, STEP, STP, SKP, MAX, FBX, 3DS, IGES, IGS, OBJ', 'fluentform'),
'value' => 'dwg|stp|stl|STEP|skp|max|fbx|3ds|iges|igs|obj',
];
return $types;
});
add_filter('upload_mimes', function ($mime_types) {
$mime_types ['dwg'] = 'image/vnd.dwg';
$mime_types ['stl'] = 'application/sla';
$mime_types ['step'] = 'application/p21';
$mime_types ['stp'] = 'application/p21';
$mime_types ['skp'] = 'application/x-koan';
$mime_types ['max'] = 'application/x-paperport';
$mime_types ['fbx'] = 'application/x-fortran';
$mime_types ['3ds'] = 'image/x-3ds';
$mime_types ['iges'] = 'model/iges';
$mime_types ['igs'] = 'model/iges';
$mime_types ['obj'] = 'application/x-tgif';
return $mime_types;
}, 1, 1);
add_action('fluentform_starting_file_upload', function () {
add_filter('fluentform_uploader_args', function ($args) {
$args['test_type'] = false;
return $args;
});
});
//http req
add_filter('ff_default_file_extensions', function ($mime_types) {
$newTypes = [
'application/x-paperport' => 'max',
'application/octet-stream' => 'fbx',
'application/p21' => 'step',
'application/p21' => 'stp',
'model/iges' => 'iges',
'model/iges' => 'igs',
'application/x-koan' => 'skp',
'application/sla' => 'stl',
'text/plain' => 'obj',
];
$mime_types = array_merge($mime_types, $newTypes);
return $mime_types;
}, 1, 1);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment