Created
November 21, 2022 17:46
-
-
Save ryanshoover/8c10debb76b9e9f20dfb9517bd26e136 to your computer and use it in GitHub Desktop.
Retrofit WPMS blogs.dir structure
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Sunrise - load very early. | |
*/ | |
/** | |
* If the request is for a file, send it to the legacy ms-files.php for processing. | |
* | |
* File requests follow the pattern `multisite.com/sitename/files/2022/06/filename.jpg` | |
*/ | |
function maybe_redirect_ms_files() { | |
$path = parse_url( $_SERVER['REQUEST_URI'], PHP_URL_PATH ); | |
$is_file = preg_match( '/[\w-]*\/files\/(.*)/', $path, $matches ); | |
// If this is a file request, send it to ms-files. | |
if ( $is_file ) { | |
$_GET['file'] = $matches[1]; | |
require_once ABSPATH . WPINC . '/ms-files.php'; | |
die; | |
} | |
} | |
// Wait for all the multisite code to be loaded, then check if we should process this as a file. | |
add_action( 'ms_loaded', 'maybe_redirect_ms_files' ); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Load sunrise.php file early. | |
define( 'SUNRISE', true ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment