#20527 closed feature request (wontfix)
Adding sunrise-like capability to ms-files
Reported by: | isaacchapman | Owned by: | |
---|---|---|---|
Milestone: | Priority: | normal | |
Severity: | normal | Version: | |
Component: | Multisite | Keywords: | |
Focuses: | Cc: |
Description
Currently sunrise.php is not included on multi-site file downloads as it is only called from /wp-includes/ms-settings.php, which is not included by /wp-includes/ms-files.php. Since mu-plugins and plugins are also skipped by SHORTINIT, there is no way to customize file downloading of which I am aware.
Because the existing sunrise.php include capability isn't exactly aligned with this issue, a separate file to be included makes sense to me. The attached diff will include a WP_CONTENT_DIR . '/sunrise_ms_files.php' file if SUNRISE_MS_FILES is defined in wp-config.php.
While my concern is securing file downloads for members-only sites (by including custom user-to-file authorization code), this fix could also allow for easily setting custom mime types. Example sunrise_ms_files.php content:
<?php add_filter('upload_mimes', 'add_custom_mime_types'); function add_custom_mime_types($mimes = array()) { $mimes['abc'] = 'application/abracadabra'; $mimes['def'] = 'application/defense'; return $mimes; } ?>
Attachments (2)
Change History (8)
#2
@
13 years ago
#19235 is related in a somewhat opposite manner. Instead of using a central file serving script (ms-files.php), my understanding is #19235 is aimed at directly serving the files. (To offset partially the overhead of using ms-files.php in serving files I am using mod_xsendfile and defining WPMU_SENDFILE.)
The sunrise-ms-files.diff attachment includes reporting sunrise-ms-files.php (replaced the underscores with hyphens for WP consistency) as a drop-in on the Network Admin -> Plugins screen.
#3
@
13 years ago
If we do #19235 (and we will), we will likely stop supporting ms-files.php. Certainly no more enhancements, in that case.
Rather than using wp-includes/ms-files.php, you could always use wp-content/ms-files.php and change your rewrite rules. This is how things worked in WordPress MU. Obviously, that means you won't get future updates to ms-files.php, so it may increase the burden a bit in making sure you end up with bugfixes. But, as I said, we're ideally going to kill ms-files.php usage for new installs (in 3.5, I think).
ms-files.php.diff