WordPress.org

Make WordPress Core

Ticket #19235: 19235.4.diff

File 19235.4.diff, 27.2 KB (added by wpmuguru, 6 years ago)

refresh of 19235.4.diff to current trunk

  • wp-includes/ms-default-filters.php

     
    6161// WP_HOME and WP_SITEURL should not have any effect in MS
    6262remove_filter( 'option_siteurl', '_config_wp_siteurl' );
    6363remove_filter( 'option_home',    '_config_wp_home'    );
     64
     65// If the network upgrade hasn't run yet, assume ms-files.php rewriting is used.
     66add_filter( 'default_site_option_ms_files_rewriting', '__return_true' );
     67 No newline at end of file
  • wp-includes/post.php

     
    204204                return false;
    205205
    206206        $file = apply_filters( 'update_attached_file', $file, $attachment_id );
    207         $file = _wp_relative_upload_path($file);
     207        $file = _wp_relative_upload_path( $file );
    208208
    209209        return update_post_meta( $attachment_id, '_wp_attached_file', $file );
    210210}
     
    223223function _wp_relative_upload_path( $path ) {
    224224        $new_path = $path;
    225225
    226         if ( ($uploads = wp_upload_dir()) && false === $uploads['error'] ) {
    227                 if ( 0 === strpos($new_path, $uploads['basedir']) ) {
    228                                 $new_path = str_replace($uploads['basedir'], '', $new_path);
    229                                 $new_path = ltrim($new_path, '/');
    230                 }
     226        $uploads = wp_upload_dir();
     227        if ( 0 === strpos( $new_path, $uploads['basedir'] ) ) {
     228                $new_path = str_replace( $uploads['basedir'], '', $new_path );
     229                $new_path = ltrim( $new_path, '/' );
    231230        }
    232231
    233232        return apply_filters( '_wp_relative_upload_path', $new_path, $path );
  • wp-includes/functions.php

     
    14321432 * @return array See above for description.
    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
    14521447        if ( !$url = get_option( 'upload_url_path' ) ) {
     
    14561451                        $url = trailingslashit( $siteurl ) . $upload_path;
    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 ( empty( $GLOBALS['_wp_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
    1470         $bdir = $dir;
    1471         $burl = $url;
     1474        $basedir = $dir;
     1475        $baseurl = $url;
    14721476
    14731477        $subdir = '';
    14741478        if ( get_option( 'uploads_use_yearmonth_folders' ) ) {
     
    14831487        $dir .= $subdir;
    14841488        $url .= $subdir;
    14851489
    1486         $uploads = apply_filters( 'upload_dir', array( 'path' => $dir, 'url' => $url, 'subdir' => $subdir, 'basedir' => $bdir, 'baseurl' => $burl, 'error' => false ) );
     1490        $uploads = apply_filters( 'upload_dir',
     1491                array(
     1492                        'path'    => $dir,
     1493                        'url'     => $url,
     1494                        'subdir'  => $subdir,
     1495                        'basedir' => $basedir,
     1496                        'baseurl' => $baseurl,
     1497                        'error'   => false,
     1498                )
     1499        );
    14871500
    14881501        // Make sure we have an uploads dir
    14891502        if ( ! wp_mkdir_p( $uploads['path'] ) ) {
    14901503                $message = sprintf( __( 'Unable to create directory %s. Is its parent directory writable by the server?' ), $uploads['path'] );
    1491                 return array( 'error' => $message );
     1504                $uploads['error'] = $message;
     1505                return $uploads;
    14921506        }
    14931507
    14941508        return $uploads;
  • wp-includes/option.php

     
    174174        if ( empty($site_id) )
    175175                $site_id = $wpdb->siteid;
    176176
    177         $core_options = array('site_name', 'siteurl', 'active_sitewide_plugins', '_site_transient_timeout_theme_roots', '_site_transient_theme_roots', 'site_admins', 'can_compress_scripts', 'global_terms_enabled' );
     177        $core_options = array('site_name', 'siteurl', 'active_sitewide_plugins', '_site_transient_timeout_theme_roots', '_site_transient_theme_roots', 'site_admins', 'can_compress_scripts', 'global_terms_enabled', 'ms_files_rewriting' );
    178178
    179179        $core_options_in = "'" . implode("', '", $core_options) . "'";
    180180        $options = $wpdb->get_results( $wpdb->prepare("SELECT meta_key, meta_value FROM $wpdb->sitemeta WHERE meta_key IN ($core_options_in) AND site_id = %d", $site_id) );
  • wp-includes/rewrite.php

     
    17391739                } else {
    17401740                        if (is_subdomain_install()) {
    17411741                                $rules .= '
    1742                                 <rule name="wordpress - Rule 1" stopProcessing="true">
     1742                                <rule name="WordPress Rule 1" stopProcessing="true">
    17431743                                        <match url="^index\.php$" ignoreCase="false" />
    17441744                                        <action type="None" />
    1745                                 </rule>
    1746                                 <rule name="wordpress - Rule 2" stopProcessing="true">
     1745                                </rule>';
     1746                                if ( get_site_option( 'ms_files_rewriting' ) ) {
     1747                                        $rules .= '
     1748                                <rule name="WordPress Rule for Files" stopProcessing="true">
    17471749                                        <match url="^files/(.+)" ignoreCase="false" />
    17481750                                        <action type="Rewrite" url="wp-includes/ms-files.php?file={R:1}" appendQueryString="false" />
    1749                                 </rule>
    1750                                 <rule name="wordpress - Rule 3" stopProcessing="true">
     1751                                </rule>';
     1752                                }
     1753                                $rules .= '
     1754                                <rule name="WordPress Rule 2" stopProcessing="true">
    17511755                                        <match url="^" ignoreCase="false" />
    17521756                                        <conditions logicalGrouping="MatchAny">
    17531757                                                <add input="{REQUEST_FILENAME}" matchType="IsFile" ignoreCase="false" />
     
    17551759                                        </conditions>
    17561760                                        <action type="None" />
    17571761                                </rule>
    1758                                 <rule name="wordpress - Rule 4" stopProcessing="true">
     1762                                <rule name="WordPress Rule 3" stopProcessing="true">
    17591763                                        <match url="." ignoreCase="false" />
    17601764                                        <action type="Rewrite" url="index.php" />
    17611765                                </rule>';
    17621766                        } else {
    17631767                                $rules .= '
    1764                                 <rule name="wordpress - Rule 1" stopProcessing="true">
     1768                                <rule name="WordPress Rule 1" stopProcessing="true">
    17651769                                        <match url="^index\.php$" ignoreCase="false" />
    17661770                                        <action type="None" />
    1767                                 </rule>
    1768                                 <rule name="wordpress - Rule 2" stopProcessing="true">
     1771                                </rule>';
     1772                                if ( get_site_option( 'ms_files_rewriting' ) ) {
     1773                                        $rules .= '
     1774                                <rule name="WordPress Rule for Files" stopProcessing="true">
    17691775                                        <match url="^([_0-9a-zA-Z-]+/)?files/(.+)" ignoreCase="false" />
    17701776                                        <action type="Rewrite" url="wp-includes/ms-files.php?file={R:2}" appendQueryString="false" />
    1771                                 </rule>
    1772                                 <rule name="wordpress - Rule 3" stopProcessing="true">
     1777                                </rule>';
     1778                                }
     1779                                $rules .= '
     1780                                <rule name="WordPress Rule 2" stopProcessing="true">
    17731781                                        <match url="^([_0-9a-zA-Z-]+/)?wp-admin$" ignoreCase="false" />
    17741782                                        <action type="Redirect" url="{R:1}wp-admin/" redirectType="Permanent" />
    17751783                                </rule>
    1776                                 <rule name="wordpress - Rule 4" stopProcessing="true">
     1784                                <rule name="WordPress Rule 3" stopProcessing="true">
    17771785                                        <match url="^" ignoreCase="false" />
    17781786                                        <conditions logicalGrouping="MatchAny">
    17791787                                                <add input="{REQUEST_FILENAME}" matchType="IsFile" ignoreCase="false" />
     
    17811789                                        </conditions>
    17821790                                        <action type="None" />
    17831791                                </rule>
    1784                                 <rule name="wordpress - Rule 5" stopProcessing="true">
     1792                                <rule name="WordPress Rule 4" stopProcessing="true">
    17851793                                        <match url="^([_0-9a-zA-Z-]+/)?(wp-(content|admin|includes).*)" ignoreCase="false" />
    17861794                                        <action type="Rewrite" url="{R:1}" />
    17871795                                </rule>
    1788                                 <rule name="wordpress - Rule 6" stopProcessing="true">
     1796                                <rule name="WordPress Rule 5" stopProcessing="true">
    17891797                                        <match url="^([_0-9a-zA-Z-]+/)?(.*\.php)$" ignoreCase="false" />
    17901798                                        <action type="Rewrite" url="{R:2}" />
    17911799                                </rule>
    1792                                 <rule name="wordpress - Rule 7" stopProcessing="true">
     1800                                <rule name="WordPress Rule 6" stopProcessing="true">
    17931801                                        <match url="." ignoreCase="false" />
    17941802                                        <action type="Rewrite" url="index.php" />
    17951803                                </rule>';
  • wp-includes/ms-default-constants.php

     
    1010/**
    1111 * Defines Multisite upload constants.
    1212 *
     13 * Exists for backward compatibility with legacy file-serving through
     14 * wp-includes/ms-files.php (wp-content/blogs.php in MU).
     15 *
    1316 * @since 3.0.0
    1417 */
    15 function ms_upload_constants(  ) {
     18function ms_upload_constants() {
    1619        global $wpdb;
    1720
     21        if ( ! get_site_option( 'ms_files_rewriting' ) )
     22                return;
     23
    1824        /** @since 3.0.0 */
    1925        // Base uploads dir relative to ABSPATH
    2026        if ( !defined( 'UPLOADBLOGSDIR' ) )
     
    2430        if ( !defined( 'UPLOADS' ) ) {
    2531                // Uploads dir relative to ABSPATH
    2632                define( 'UPLOADS', UPLOADBLOGSDIR . "/{$wpdb->blogid}/files/" );
    27                 if ( 'wp-content/blogs.dir' == UPLOADBLOGSDIR )
     33                if ( 'wp-content/blogs.dir' == UPLOADBLOGSDIR && ! defined( 'BLOGUPLOADDIR' ) )
    2834                        define( 'BLOGUPLOADDIR', WP_CONTENT_DIR . "/blogs.dir/{$wpdb->blogid}/files/" );
    2935        }
    3036}
     
    7480/**
    7581 * Defines Multisite file constants.
    7682 *
     83 * Exists for backward compatibility with legacy file-serving through
     84 * wp-includes/ms-files.php (wp-content/blogs.php in MU).
     85 *
    7786 * @since 3.0.0
    7887 */
    79 function ms_file_constants(  ) {
     88function ms_file_constants() {
    8089        /**
    8190         * Optional support for X-Sendfile header
    8291         * @since 3.0.0
  • wp-includes/ms-functions.php

     
    11291129 * @param string $blog_title The title of the new site.
    11301130 */
    11311131function install_blog($blog_id, $blog_title = '') {
    1132         global $wpdb, $table_prefix, $wp_roles;
    1133         $wpdb->suppress_errors();
     1132        global $wpdb, $wp_roles, $current_site;
    11341133
    11351134        // Cast for security
    11361135        $blog_id = (int) $blog_id;
     
    11381137        require_once( ABSPATH . 'wp-admin/includes/upgrade.php' );
    11391138
    11401139        if ( $wpdb->get_results("SELECT ID FROM $wpdb->posts") )
    1141                 die(__('<h1>Already Installed</h1><p>You appear to have already installed WordPress. To reinstall please clear your old database tables first.</p>') . '</body></html>');
     1140                die( __( '<h1>Already Installed</h1><p>You appear to have already installed WordPress. To reinstall please clear your old database tables first.</p>' ) . '</body></html>' );
    11421141
    1143         $wpdb->suppress_errors(false);
     1142        $url = get_blogaddress_by_id( $blog_id );
    11441143
    1145         $url = get_blogaddress_by_id($blog_id);
    1146 
    11471144        // Set everything up
    11481145        make_db_current_silent( 'blog' );
    11491146        populate_options();
     
    11511148        $wp_roles->_init();
    11521149
    11531150        $url = untrailingslashit( $url );
    1154         // fix url.
    1155         update_option('siteurl', $url);
    1156         update_option('home', $url);
    1157         update_option('fileupload_url', $url . "/files" );
    1158         update_option('upload_path', UPLOADBLOGSDIR . "/$blog_id/files");
    1159         update_option('blogname', stripslashes( $blog_title ) );
    1160         update_option('admin_email', '');
    1161         $wpdb->update( $wpdb->options, array('option_value' => ''), array('option_name' => 'admin_email') );
    11621151
    1163         // remove all perms
    1164         $wpdb->delete( $wpdb->usermeta, array( 'meta_key' => $table_prefix.'user_level' ) );
     1152        update_option( 'siteurl', $url );
     1153        update_option( 'home', $url );
    11651154
    1166         $wpdb->delete( $wpdb->usermeta, array( 'meta_key' => $table_prefix.'capabilities' ) );
     1155        if ( get_site_option( 'ms_files_rewriting' ) )
     1156                update_option( 'upload_path', UPLOADBLOGSDIR . "/$blog_id/files" );
     1157        else
     1158                update_option( 'upload_path', get_blog_option( $current_site->blog_id, 'upload_path' ) );
    11671159
    1168         $wpdb->suppress_errors( false );
     1160        update_option( 'blogname', stripslashes( $blog_title ) );
     1161        update_option( 'admin_email', '' );
     1162
     1163        // remove all perms
     1164        $table_prefix = $wpdb->get_blog_prefix();
     1165        delete_metadata( 'user', 0, $table_prefix . 'user_level',   null, true ); // delete all
     1166        delete_metadata( 'user', 0, $table_prefix . 'capabilities', null, true ); // delete all
    11691167}
    11701168
    11711169/**
  • wp-admin/network.php

     
    106106$network_help = '<p>' . __('This screen allows you to configure a network as having subdomains (<code>site1.example.com</code>) or subdirectories (<code>example.com/site1</code>). Subdomains require wildcard subdomains to be enabled in Apache and DNS records, if your host allows it.') . '</p>' .
    107107        '<p>' . __('Choose subdomains or subdirectories; this can only be switched afterwards by reconfiguring your install. Fill out the network details, and click install. If this does not work, you may have to add a wildcard DNS record (for subdomains) or change to another setting in Permalinks (for subdirectories).') . '</p>' .
    108108        '<p>' . __('The next screen for Network Setup will give you individually-generated lines of code to add to your wp-config.php and .htaccess files. Make sure the settings of your FTP client make files starting with a dot visible, so that you can find .htaccess; you may have to create this file if it really is not there. Make backup copies of those two files.') . '</p>' .
    109         '<p>' . __('Add a <code>blogs.dir</code> directory under <code>/wp-content</code> and add the designated lines of code to wp-config.php (just before <code>/*...stop editing...*/</code>) and <code>.htaccess</code> (replacing the existing WordPress rules).') . '</p>' .
     109        '<p>' . __('Add the designated lines of code to wp-config.php (just before <code>/*...stop editing...*/</code>) and <code>.htaccess</code> (replacing the existing WordPress rules).') . '</p>' .
    110110        '<p>' . __('Once you add this code and refresh your browser, multisite should be enabled. This screen, now in the Network Admin navigation menu, will keep an archive of the added code. You can toggle between Network Admin and Site Admin by clicking on the Network Admin or an individual site name under the My Sites dropdown in the Toolbar.') . '</p>' .
    111111        '<p>' . __('The choice of subdirectory sites is disabled if this setup is more than a month old because of permalink problems with &#8220;/blog/&#8221; from the main site. This disabling will be addressed in a future version.') . '</p>' .
    112112        '<p><strong>' . __('For more information:') . '</strong></p>' .
     
    190190                $error_codes = $errors->get_error_codes();
    191191        }
    192192
    193         if ( WP_CONTENT_DIR != ABSPATH . 'wp-content' )
    194                 echo '<div class="error"><p><strong>' . __('Warning!') . '</strong> ' . __( 'Networks may not be fully compatible with custom wp-content directories.' ) . '</p></div>';
    195 
    196193        $site_name = ( ! empty( $_POST['sitename'] ) && ! in_array( 'empty_sitename', $error_codes ) ) ? $_POST['sitename'] : sprintf( _x('%s Sites', 'Default network name' ), get_option( 'blogname' ) );
    197194        $admin_email = ( ! empty( $_POST['email'] ) && ! in_array( 'invalid_email', $error_codes ) ) ? $_POST['email'] : get_option( 'admin_email' );
    198195        ?>
     
    235232<?php
    236233        endif;
    237234
     235                if ( WP_CONTENT_DIR != ABSPATH . 'wp-content' && ( allow_subdirectory_install() || ! allow_subdomain_install() ) )
     236                        echo '<div class="error inline"><p><strong>' . __('Warning!') . '</strong> ' . __( 'Subdirectory networks may not be fully compatible with custom wp-content directories.' ) . '</p></div>';
     237
    238238                $is_www = ( 0 === strpos( $hostname, 'www.' ) );
    239239                if ( $is_www ) :
    240240                ?>
     
    360360        }
    361361?>
    362362                <ol>
    363                         <li><p><?php
    364                                 printf( __( 'Create a <code>blogs.dir</code> directory at <code>%s/blogs.dir</code>. This directory is used to store uploaded media for your additional sites and must be writeable by the web server.' ), WP_CONTENT_DIR );
    365                                 if ( WP_CONTENT_DIR != ABSPATH . 'wp-content' )
    366                                         echo ' <strong>' . __('Warning:') . ' ' . __( 'Networks may not be fully compatible with custom wp-content directories.' ) . '</strong>';
    367                         ?></p></li>
    368363                        <li><p><?php printf( __( 'Add the following to your <code>wp-config.php</code> file in <code>%s</code> <strong>above</strong> the line reading <code>/* That&#8217;s all, stop editing! Happy blogging. */</code>:' ), ABSPATH ); ?></p>
    369364                                <textarea class="code" readonly="readonly" cols="100" rows="7">
    370365define('MULTISITE', true);
     
    415410                <rule name="WordPress Rule 1" stopProcessing="true">
    416411                    <match url="^index\.php$" ignoreCase="false" />
    417412                    <action type="None" />
    418                 </rule>
    419                 <rule name="WordPress Rule 2" stopProcessing="true">
     413                </rule>';
     414                                if ( is_multisite() && get_site_option( 'ms_files_rewriting' ) ) {
     415                                        $web_config_file .= '
     416                <rule name="WordPress Rule for Files" stopProcessing="true">
    420417                    <match url="^files/(.+)" ignoreCase="false" />
    421418                    <action type="Rewrite" url="wp-includes/ms-files.php?file={R:1}" appendQueryString="false" />
    422                 </rule>
    423                 <rule name="WordPress Rule 3" stopProcessing="true">
     419                </rule>';
     420                }
     421                $web_config_file .= '
     422                <rule name="WordPress Rule 2" stopProcessing="true">
    424423                    <match url="^" ignoreCase="false" />
    425424                    <conditions logicalGrouping="MatchAny">
    426425                        <add input="{REQUEST_FILENAME}" matchType="IsFile" ignoreCase="false" />
     
    428427                    </conditions>
    429428                    <action type="None" />
    430429                </rule>
    431                 <rule name="WordPress Rule 4" stopProcessing="true">
     430                <rule name="WordPress Rule 3" stopProcessing="true">
    432431                    <match url="." ignoreCase="false" />
    433432                    <action type="Rewrite" url="index.php" />
    434433                </rule>
     
    446445                <rule name="WordPress Rule 1" stopProcessing="true">
    447446                    <match url="^index\.php$" ignoreCase="false" />
    448447                    <action type="None" />
    449                 </rule>
     448                </rule>';
     449                                if ( is_multisite() && get_site_option( 'ms_files_rewriting' ) ) {
     450                                        $web_config_file .= '
     451                <rule name="WordPress Rule for Files" stopProcessing="true">
     452                    <match url="^files/(.+)" ignoreCase="false" />
     453                    <action type="Rewrite" url="wp-includes/ms-files.php?file={R:1}" appendQueryString="false" />
     454                </rule>';
     455                }
     456                $web_config_file .= '
    450457                <rule name="WordPress Rule 2" stopProcessing="true">
    451                     <match url="^([_0-9a-zA-Z-]+/)?files/(.+)" ignoreCase="false" />
    452                     <action type="Rewrite" url="wp-includes/ms-files.php?file={R:2}" appendQueryString="false" />
    453                 </rule>
    454                 <rule name="WordPress Rule 3" stopProcessing="true">
    455458                    <match url="^([_0-9a-zA-Z-]+/)?wp-admin$" ignoreCase="false" />
    456459                    <action type="Redirect" url="{R:1}wp-admin/" redirectType="Permanent" />
    457460                </rule>
    458                 <rule name="WordPress Rule 4" stopProcessing="true">
     461                <rule name="WordPress Rule 3" stopProcessing="true">
    459462                    <match url="^" ignoreCase="false" />
    460463                    <conditions logicalGrouping="MatchAny">
    461464                        <add input="{REQUEST_FILENAME}" matchType="IsFile" ignoreCase="false" />
     
    463466                    </conditions>
    464467                    <action type="None" />
    465468                </rule>
    466                 <rule name="WordPress Rule 5" stopProcessing="true">
     469                <rule name="WordPress Rule 4" stopProcessing="true">
    467470                    <match url="^[_0-9a-zA-Z-]+/(wp-(content|admin|includes).*)" ignoreCase="false" />
    468471                    <action type="Rewrite" url="{R:1}" />
    469472                </rule>
    470                 <rule name="WordPress Rule 6" stopProcessing="true">
     473                <rule name="WordPress Rule 5" stopProcessing="true">
    471474                    <match url="^([_0-9a-zA-Z-]+/)?(.*\.php)$" ignoreCase="false" />
    472475                    <action type="Rewrite" url="{R:2}" />
    473476                </rule>
    474                 <rule name="WordPress Rule 7" stopProcessing="true">
     477                <rule name="WordPress Rule 6" stopProcessing="true">
    475478                    <match url="." ignoreCase="false" />
    476479                    <action type="Rewrite" url="index.php" />
    477480                </rule>
     
    482485                        }
    483486        ?>
    484487                <li><p><?php printf( __( 'Add the following to your <code>web.config</code> file in <code>%s</code>, replacing other WordPress rules:' ), ABSPATH ); ?></p>
    485                 <textarea class="code" readonly="readonly" cols="100" rows="20">
    486                 <?php echo esc_textarea( $web_config_file ); ?>
     488                <?php
     489                if ( ! $subdomain_install && WP_CONTENT_DIR != ABSPATH . 'wp-content' )
     490                        echo '<p><strong>' . __('Warning:') . ' ' . __( 'Subdirectory networks may not be fully compatible with custom wp-content directories.' ) . '</strong></p>';
     491                ?>
     492                <textarea class="code" readonly="readonly" cols="100" rows="20"><?php echo esc_textarea( $web_config_file ); ?>
    487493                </textarea></li>
    488494                </ol>
    489495
     
    491497
    492498                $htaccess_file = 'RewriteEngine On
    493499RewriteBase ' . $base . '
    494 RewriteRule ^index\.php$ - [L]
     500RewriteRule ^index\.php$ - [L]' . "\n";
    495501
    496 # uploaded files
    497 RewriteRule ^' . ( $subdomain_install ? '' : '([_0-9a-zA-Z-]+/)?' ) . 'files/(.+) wp-includes/ms-files.php?file=$' . ( $subdomain_install ? 1 : 2 ) . ' [L]' . "\n";
     502                if ( is_multisite() && get_site_option( 'ms_files_rewriting' ) ) {
     503                        $htaccess_file .= "\n\n# uploaded files\nRewriteRule ^";
     504                        $htaccess_file .= ( $subdomain_install ? '' : '([_0-9a-zA-Z-]+/)?' ) . 'files/(.+) wp-includes/ms-files.php?file=$' . ( $subdomain_install ? 1 : 2 ) . ' [L]' . "\n";
     505                }
    498506
    499507                if ( ! $subdomain_install )
    500508                        $htaccess_file .= "\n# add a trailing slash to /wp-admin\n" . 'RewriteRule ^([_0-9a-zA-Z-]+/)?wp-admin$ $1wp-admin/ [R=301,L]' . "\n";
     
    511519
    512520                ?>
    513521                <li><p><?php printf( __( 'Add the following to your <code>.htaccess</code> file in <code>%s</code>, replacing other WordPress rules:' ), ABSPATH ); ?></p>
    514                 <textarea class="code" readonly="readonly" cols="100" rows="<?php echo $subdomain_install ? 11 : 16; ?>">
     522                <?php
     523                if ( ! $subdomain_install && WP_CONTENT_DIR != ABSPATH . 'wp-content' )
     524                        echo '<p><strong>' . __('Warning:') . ' ' . __( 'Subdirectory networks may not be fully compatible with custom wp-content directories.' ) . '</strong></p>';
     525                ?>
     526                <textarea class="code" readonly="readonly" cols="100" rows="<?php echo substr_count( $htaccess_file, "\n" ) + 1; ?>">
    515527<?php echo esc_textarea( $htaccess_file ); ?></textarea></li>
    516528                </ol>
    517529
  • wp-admin/includes/ms-deprecated.php

     
    7373function wpmu_get_blog_allowedthemes( $blog_id = 0 ) {
    7474        _deprecated_function( __FUNCTION__, '3.4', 'WP_Theme::get_allowed_on_site()' );
    7575        return array_map( 'intval', WP_Theme::get_allowed_on_site( $blog_id ) );
    76 }
    77  No newline at end of file
     76}
     77
     78function ms_deprecated_blogs_file() {}
     79 No newline at end of file
  • wp-admin/includes/upgrade.php

     
    12631263                        delete_site_option( 'allowed_themes' );
    12641264                }
    12651265        }
     1266
     1267        if ( $wp_current_db_version < 20600 )
     1268                update_site_option( 'ms_files_rewriting', '1' );
    12661269}
    12671270
    12681271// The functions we use to actually do stuff
  • wp-admin/includes/schema.php

     
    899899                'upload_space_check_disabled' => '0',
    900900                'subdomain_install' => intval( $subdomain_install ),
    901901                'global_terms_enabled' => global_terms_enabled() ? '1' : '0',
     902                'ms_files_rewriting' => is_multisite() ? get_site_option( 'ms_files_rewriting' ) : '0',
    902903                'initial_db_version' => get_option( 'initial_db_version' ),
    903904                'active_sitewide_plugins' => array(),
    904905        );
     
    926927                $blog_id = $wpdb->insert_id;
    927928                update_user_meta( $site_user->ID, 'source_domain', $domain );
    928929                update_user_meta( $site_user->ID, 'primary_blog', $blog_id );
    929                 if ( !$upload_path = get_option( 'upload_path' ) ) {
    930                         $upload_path = substr( WP_CONTENT_DIR, strlen( ABSPATH ) ) . '/uploads';
    931                         update_option( 'upload_path', $upload_path );
    932                 }
    933                 update_option( 'fileupload_url', get_option( 'siteurl' ) . '/' . $upload_path );
    934930        }
    935931
    936932        if ( $subdomain_install )
  • wp-admin/includes/ms.php

     
    9090
    9191                $wpdb->delete( $wpdb->blogs, array( 'blog_id' => $blog_id ) );
    9292
    93                 $dir = apply_filters( 'wpmu_delete_blog_upload_dir', WP_CONTENT_DIR . "/blogs.dir/{$blog_id}/files/", $blog_id );
     93                $uploads = wp_upload_dir();
     94                $dir = apply_filters( 'wpmu_delete_blog_upload_dir', $uploads['basedir'], $blog_id );
    9495                $dir = rtrim( $dir, DIRECTORY_SEPARATOR );
    9596                $top_dir = $dir;
    9697                $stack = array($dir);
     
    356357function get_space_used() {
    357358        // Allow for an alternative way of tracking storage space used
    358359        $space_used = apply_filters( 'pre_get_space_used', false );
    359         if ( false === $space_used )
    360                 $space_used = get_dirsize( BLOGUPLOADDIR ) / 1024 / 1024;
     360        if ( false === $space_used ) {
     361                $upload_dir = wp_upload_dir();
     362                $space_used = get_dirsize( $upload_dir['basedir'] );
     363        }
    361364
    362365        return $space_used;
    363366}
     
    681684        <?php
    682685}
    683686
    684 function ms_deprecated_blogs_file() {
    685         if ( ! is_super_admin() )
    686                 return;
    687         if ( ! file_exists( WP_CONTENT_DIR . '/blogs.php' ) )
    688                 return;
    689         echo '<div class="update-nag">' . sprintf( __( 'The <code>%1$s</code> file is deprecated. Please remove it and update your server rewrite rules to use <code>%2$s</code> instead.' ), 'wp-content/blogs.php', 'wp-includes/ms-files.php' ) . '</div>';
    690 }
    691 add_action( 'network_admin_notices', 'ms_deprecated_blogs_file' );
    692 
    693687/**
    694688 * Grants super admin privileges.
    695689 *