WordPress.org

Make WordPress Core


Ignore:
Timestamp:
09/11/2012 10:22:20 PM (9 years ago)
Author:
nacin
Message:

Remove ms-files.php rewriting from WordPress multisite. fixes #19235.

Keep existing networks compatible with a ms_files_rewriting network option.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/wp-includes/functions.php

    r21822 r21823  
    14331433 */
    14341434function wp_upload_dir( $time = null ) {
    1435     global $_wp_switched;
    14361435    $siteurl = get_option( 'siteurl' );
    1437     $upload_path = get_option( 'upload_path' );
    1438     $upload_path = trim($upload_path);
    1439     $main_override = is_multisite() && defined( 'MULTISITE' ) && is_main_site();
    1440     if ( empty($upload_path) ) {
     1436    $upload_path = trim( get_option( 'upload_path' ) );
     1437
     1438    if ( empty( $upload_path ) || 'wp-content/uploads' == $upload_path ) {
    14411439        $dir = WP_CONTENT_DIR . '/uploads';
     1440    } elseif ( 0 !== strpos( $upload_path, ABSPATH ) ) {
     1441        // $dir is absolute, $upload_path is (maybe) relative to ABSPATH
     1442        $dir = path_join( ABSPATH, $upload_path );
    14421443    } else {
    14431444        $dir = $upload_path;
    1444         if ( 'wp-content/uploads' == $upload_path ) {
    1445             $dir = WP_CONTENT_DIR . '/uploads';
    1446         } elseif ( 0 !== strpos($dir, ABSPATH) ) {
    1447             // $dir is absolute, $upload_path is (maybe) relative to ABSPATH
    1448             $dir = path_join( ABSPATH, $dir );
    1449         }
    14501445    }
    14511446
     
    14571452    }
    14581453
    1459     if ( defined('UPLOADS') && ! $main_override && ! $_wp_switched ) {
     1454    if ( defined( 'UPLOADS' ) ) {
    14601455        $dir = ABSPATH . UPLOADS;
    14611456        $url = trailingslashit( $siteurl ) . UPLOADS;
    14621457    }
    14631458
    1464     if ( is_multisite() && ! $main_override && ! $_wp_switched  ) {
    1465         if ( defined( 'BLOGUPLOADDIR' ) )
    1466             $dir = untrailingslashit(BLOGUPLOADDIR);
    1467         $url = str_replace( UPLOADS, 'files', $url );
     1459    // Multisite (if not the main site in a post-MU network)
     1460    if ( is_multisite() && ! ( is_main_site() && defined( 'MULTISITE' ) ) ) {
     1461        if ( ! get_site_option( 'ms_files_rewriting' ) ) {
     1462            // Append sites/%d if we're not on the main site (for post-MU networks).
     1463            $ms_dir = '/sites/' . get_current_blog_id();
     1464            $dir .= $ms_dir;
     1465            $url .= $ms_dir;
     1466        } elseif ( ! ms_is_switched() ) {
     1467            // Handle the old-form ms-files.php rewriting if the network still has that enabled.
     1468            if ( defined( 'BLOGUPLOADDIR' ) )
     1469                $dir = untrailingslashit( BLOGUPLOADDIR );
     1470            $url = str_replace( UPLOADS, 'files', $url );
     1471        }
    14681472    }
    14691473
Note: See TracChangeset for help on using the changeset viewer.