From 20d9c165ee9b14ee854364ff555e99462d646662 Mon Sep 17 00:00:00 2001 From: Ryan Boren Date: Mon, 3 Dec 2012 22:24:06 +0000 Subject: [PATCH] Properly set the base URL for the main site when ms-files rewriting is enabled for MU-era installs. Props nacin fixes #22702 git-svn-id: http://core.svn.wordpress.org/trunk@23002 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- wp-includes/functions.php | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/wp-includes/functions.php b/wp-includes/functions.php index ac814f9fe9..a41d32fe97 100644 --- a/wp-includes/functions.php +++ b/wp-includes/functions.php @@ -1537,10 +1537,17 @@ function wp_upload_dir( $time = null ) { // as wp-content/uploads is used there, and // 2) we are not switched, as ms_upload_constants() hardcodes // these constants to reflect the original blog ID. + // + // Rather than UPLOADS, we actually use BLOGUPLOADDIR if it is set, as it is absolute. + // (And it will be set, see ms_upload_constants().) Otherwise, UPLOADS can be used, as + // as it is relative to ABSPATH. For the final piece: when UPLOADS is used with ms-files + // rewriting in multisite, the resulting URL is /files. (#WP22702 for background.) if ( defined( 'BLOGUPLOADDIR' ) ) $dir = untrailingslashit( BLOGUPLOADDIR ); - $url = str_replace( untrailingslashit( UPLOADS ), 'files', $url ); + else + $dir = ABSPATH . UPLOADS; + $url = trailingslashit( $siteurl ) . 'files'; } }