Project

General

Profile

Actions

Feature #17445

closed

Refactor multisite mime types registration

Added by Raymond Hoh over 1 year ago. Updated over 1 year ago.

Status:
Resolved
Priority name:
Normal
Assignee:
Category name:
WordPress - Media
Target version:
Start date:
2023-01-03
Due date:
% Done:

0%

Estimated time:
Deployment actions:

Description

Right now because of WordPress multisite restrictions, when we want to allow a new file extension for uploading, we have to make the following changes:

1. Add the file extension to our custom 'pre_site_option_upload_filetypes' filter here: https://github.com/cuny-academic-commons/cac/blob/d34d10df4095d348d144f476c1a347b5527ebd9a/wp-content/mu-plugins/network-options.php#L3-L5
2. Add the mime type for the file extension to our custom cac_mime_types() function if it isn't already registered with WordPress here: https://github.com/cuny-academic-commons/cac/blob/d34d10df4095d348d144f476c1a347b5527ebd9a/wp-content/mu-plugins/cac-functions.php#L549

I'm proposing we simplify this process. For point 1, WordPress already has a predetermined list of allowable mime types -- get_allowed_mime_types(). Let's use this to populate the 'pre_site_option_upload_filetypes' filter so we only have to take care of point 2. Bonus is this would allow many more file types to be uploaded without needing users to go through Zendesk. There are only a few file types in get_allowed_mime_types() that we would want to omit. Namely any archive-related ones in the Misc section: https://github.com/WordPress/WordPress/blob/3efd18435b8a149b833bf454df4bee685dce2b93/wp-includes/functions.php#L3382. (.exe and .swf are already unset in get_allowed_mime_types() so we do not have to worry about them.)

I'm going to add some commits in a test branch for review in a bit.

Actions

Also available in: Atom PDF