From 143f4da6a6620468f1066da9c78fe716bbd32a68 Mon Sep 17 00:00:00 2001 From: Andrew Nacin Date: Thu, 27 Sep 2012 04:56:58 +0000 Subject: [PATCH] If a pre-3.0 (MU era) network disables ms-files manually, they don't need /sites/ in their wp-content/uploads directory. see #19235. git-svn-id: http://core.svn.wordpress.org/trunk@22038 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- wp-includes/functions.php | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/wp-includes/functions.php b/wp-includes/functions.php index e51c155ed1..4e47f7484b 100644 --- a/wp-includes/functions.php +++ b/wp-includes/functions.php @@ -1496,11 +1496,20 @@ function wp_upload_dir( $time = null ) { $url = trailingslashit( $siteurl ) . UPLOADS; } - // Multisite (if not the main site in a post-MU network) + // If multisite (if not the main site in a post-MU network) if ( is_multisite() && ! ( is_main_site() && defined( 'MULTISITE' ) ) ) { + if ( ! get_site_option( 'ms_files_rewriting' ) ) { - // Append sites/%d if we're not on the main site (for post-MU networks). - $ms_dir = '/sites/' . get_current_blog_id(); + // Append sites/%d if we're not on the main site (for post-MU networks). The extra directory + // prevents a four-digit ID from conflict with a year-based directory for the main site. + // If a MU-era network disables ms-files rewriting manually, they don't need the extra + // directory, as they never had wp-content/uploads for the main site. + + if ( defined( 'MULTISITE' ) ) + $ms_dir = '/sites/' . get_current_blog_id(); + else + $ms_dir = '/' . get_current_blog_id(); + $dir .= $ms_dir; $url .= $ms_dir; } elseif ( ! ms_is_switched() ) {