Make WordPress Core

Ticket #19796: 19796.diff

File 19796.diff, 26.7 KB (added by nacin, 12 years ago)

Refreshed patch that tries to stick to rewrites to make things work. I think the .htaccess $subdir_match rules are borked, and the technique needs to be tested on Apache 1.3 as well.

  • wp-includes/functions.php

     
    14321432 * @return array See above for description.
    14331433 */
    14341434function wp_upload_dir( $time = null ) {
    1435         $siteurl = get_option( 'siteurl' );
    14361435        $upload_path = trim( get_option( 'upload_path' ) );
    14371436
    14381437        if ( empty( $upload_path ) || 'wp-content/uploads' == $upload_path ) {
     
    14481447                if ( empty($upload_path) || ( 'wp-content/uploads' == $upload_path ) || ( $upload_path == $dir ) )
    14491448                        $url = WP_CONTENT_URL . '/uploads';
    14501449                else
    1451                         $url = trailingslashit( $siteurl ) . $upload_path;
     1450                        $url = trailingslashit( get_option( 'siteurl' ) ) . $upload_path;
    14521451        }
    14531452
    14541453        if ( defined( 'UPLOADS' ) ) {
    14551454                $dir = ABSPATH . UPLOADS;
    1456                 $url = trailingslashit( $siteurl ) . UPLOADS;
     1455                $url = trailingslashit( get_option( 'siteurl' ) ) . UPLOADS;
    14571456        }
    14581457
    14591458        // Multisite (if not the main site in a post-MU network)
  • wp-includes/link-template.php

     
    19471947 * @return string Site url link with optional path appended.
    19481948*/
    19491949function get_site_url( $blog_id = null, $path = '', $scheme = null ) {
    1950         if ( empty( $blog_id ) || !is_multisite() ) {
    1951                 $url = get_option( 'siteurl' );
     1950        if ( empty( $blog_id ) ) {
     1951                if ( is_multisite() )
     1952                        $url = get_option( 'home' );
     1953                else
     1954                        $url = get_option( 'siteurl' );
    19521955        } else {
    19531956                switch_to_blog( $blog_id );
    1954                 $url = get_option( 'siteurl' );
     1957                $url = get_option( 'home' );
    19551958                restore_current_blog();
    19561959        }
    19571960
     
    20572060        else
    20582061                $url = WP_PLUGIN_URL;
    20592062
    2060        
     2063
    20612064        $url = set_url_scheme( $url );
    20622065
    20632066        if ( !empty($plugin) && is_string($plugin) ) {
  • wp-includes/formatting.php

     
    13551355}
    13561356
    13571357/**
     1358 * Removes trailing and leading strings from elements (array), then combines elements
     1359 * with a string in between each element. Leading and trailing strings should be
     1360 * manually concatenated.
     1361 *
     1362 * @since  3.5.0
     1363 *
     1364 * @param  array $parts Items to be combined
     1365 * @param  string $string String to be used to combine items
     1366 * @return  string Concatenated parts with given strings in between each element.
     1367 */
     1368function join_with_string( $parts, $string ) {
     1369        $members = array();
     1370        foreach ( (array) $parts as $part ) {
     1371                if ( is_array( $part ) ) {
     1372                        foreach ( $part as $member ) {
     1373                                $members[] = trim( $member, $string );
     1374                        }
     1375                } else {
     1376                        $members[] = trim( $part, $string );
     1377                }
     1378        }
     1379
     1380        return implode( $string, $members );
     1381}
     1382
     1383/**
     1384 * Removes trailing and leading slashes from elements (array or string args), then combines elements
     1385 * with a slash in between each element. Leading and trailing slashes should be
     1386 * manually concatenated.
     1387 *
     1388 * @since  3.5.0
     1389 *
     1390 * @return  string Concatenated string with slashes in between each element.
     1391 */
     1392function join_with_slashes() {
     1393        $args = func_get_args();
     1394        return join_with_string( $args, '/' );
     1395}
     1396
     1397/**
    13581398 * Adds slashes to escape strings.
    13591399 *
    13601400 * Slashes will first be removed if magic_quotes_gpc is set, see {@link
  • wp-includes/rewrite.php

     
    17291729                <rewrite>
    17301730                        <rules>';
    17311731                }
    1732                 if ( !is_multisite() ) {
    1733                         $rules .= '
    1734                                 <rule name="wordpress" patternSyntax="Wildcard">
    1735                                         <match url="*" />
    1736                                                 <conditions>
    1737                                                         <add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" />
    1738                                                         <add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true" />
    1739                                                 </conditions>
    1740                                         <action type="Rewrite" url="index.php" />
    1741                                 </rule>';
    1742                 } else {
    1743                         if (is_subdomain_install()) {
    1744                                 $rules .= '
    1745                                 <rule name="WordPress Rule 1" stopProcessing="true">
    1746                                         <match url="^index\.php$" ignoreCase="false" />
    1747                                         <action type="None" />
    1748                                 </rule>';
    1749                                 if ( get_site_option( 'ms_files_rewriting' ) ) {
    1750                                         $rules .= '
    1751                                 <rule name="WordPress Rule for Files" stopProcessing="true">
    1752                                         <match url="^files/(.+)" ignoreCase="false" />
    1753                                         <action type="Rewrite" url="wp-includes/ms-files.php?file={R:1}" appendQueryString="false" />
    1754                                 </rule>';
    1755                                 }
    1756                                 $rules .= '
    1757                                 <rule name="WordPress Rule 2" stopProcessing="true">
    1758                                         <match url="^" ignoreCase="false" />
    1759                                         <conditions logicalGrouping="MatchAny">
    1760                                                 <add input="{REQUEST_FILENAME}" matchType="IsFile" ignoreCase="false" />
    1761                                                 <add input="{REQUEST_FILENAME}" matchType="IsDirectory" ignoreCase="false" />
     1732
     1733                $rules .= '
     1734                        <rule name="wordpress" patternSyntax="Wildcard">
     1735                                <match url="*" />
     1736                                        <conditions>
     1737                                                <add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" />
     1738                                                <add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true" />
    17621739                                        </conditions>
    1763                                         <action type="None" />
    1764                                 </rule>
    1765                                 <rule name="WordPress Rule 3" stopProcessing="true">
    1766                                         <match url="." ignoreCase="false" />
    1767                                         <action type="Rewrite" url="index.php" />
    1768                                 </rule>';
    1769                         } else {
    1770                                 $rules .= '
    1771                                 <rule name="WordPress Rule 1" stopProcessing="true">
    1772                                         <match url="^index\.php$" ignoreCase="false" />
    1773                                         <action type="None" />
    1774                                 </rule>';
    1775                                 if ( get_site_option( 'ms_files_rewriting' ) ) {
    1776                                         $rules .= '
    1777                                 <rule name="WordPress Rule for Files" stopProcessing="true">
    1778                                         <match url="^([_0-9a-zA-Z-]+/)?files/(.+)" ignoreCase="false" />
    1779                                         <action type="Rewrite" url="wp-includes/ms-files.php?file={R:2}" appendQueryString="false" />
    1780                                 </rule>';
    1781                                 }
    1782                                 $rules .= '
    1783                                 <rule name="WordPress Rule 2" stopProcessing="true">
    1784                                         <match url="^([_0-9a-zA-Z-]+/)?wp-admin$" ignoreCase="false" />
    1785                                         <action type="Redirect" url="{R:1}wp-admin/" redirectType="Permanent" />
    1786                                 </rule>
    1787                                 <rule name="WordPress Rule 3" stopProcessing="true">
    1788                                         <match url="^" ignoreCase="false" />
    1789                                         <conditions logicalGrouping="MatchAny">
    1790                                                 <add input="{REQUEST_FILENAME}" matchType="IsFile" ignoreCase="false" />
    1791                                                 <add input="{REQUEST_FILENAME}" matchType="IsDirectory" ignoreCase="false" />
    1792                                         </conditions>
    1793                                         <action type="None" />
    1794                                 </rule>
    1795                                 <rule name="WordPress Rule 4" stopProcessing="true">
    1796                                         <match url="^([_0-9a-zA-Z-]+/)?(wp-(content|admin|includes).*)" ignoreCase="false" />
    1797                                         <action type="Rewrite" url="{R:1}" />
    1798                                 </rule>
    1799                                 <rule name="WordPress Rule 5" stopProcessing="true">
    1800                                         <match url="^([_0-9a-zA-Z-]+/)?(.*\.php)$" ignoreCase="false" />
    1801                                         <action type="Rewrite" url="{R:2}" />
    1802                                 </rule>
    1803                                 <rule name="WordPress Rule 6" stopProcessing="true">
    1804                                         <match url="." ignoreCase="false" />
    1805                                         <action type="Rewrite" url="index.php" />
    1806                                 </rule>';
    1807                         }
    1808                 }
     1740                                <action type="Rewrite" url="index.php" />
     1741                        </rule>';
     1742
    18091743                if ( $add_parent_tags ) {
    18101744                        $rules .= '
    18111745                        </rules>
  • wp-includes/canonical.php

     
    517517                site_url( 'dashboard', 'relative' ),
    518518                site_url( 'admin', 'relative' ),
    519519        );
    520         if ( in_array( untrailingslashit( $_SERVER['REQUEST_URI'] ), $admins ) ) {
     520        if ( parse_url( admin_url( '', 'relative' ), PHP_URL_PATH ) !== $_SERVER['REQUEST_URI'] && in_array( untrailingslashit( $_SERVER['REQUEST_URI'] ), $admins ) ) {
    521521                wp_redirect( admin_url() );
    522522                exit;
    523523        }
  • wp-includes/ms-load.php

     
    142142                $current_site->id = defined( 'SITE_ID_CURRENT_SITE' ) ? SITE_ID_CURRENT_SITE : 1;
    143143                $current_site->domain = DOMAIN_CURRENT_SITE;
    144144                $current_site->path   = $path = PATH_CURRENT_SITE;
     145
    145146                if ( defined( 'BLOG_ID_CURRENT_SITE' ) )
    146147                        $current_site->blog_id = BLOG_ID_CURRENT_SITE;
    147148                elseif ( defined( 'BLOGID_CURRENT_SITE' ) ) // deprecated.
  • wp-includes/class-oembed.php

     
    4848                        '#http://(.+\.)?polldaddy\.com/.*#i'                 => array( 'http://polldaddy.com/oembed/',                      true  ),
    4949                        '#http://(www\.)?funnyordie\.com/videos/.*#i'        => array( 'http://www.funnyordie.com/oembed',                  true  ),
    5050                        '#https?://(www\.)?twitter.com/.+?/status(es)?/.*#i' => array( 'http://api.twitter.com/1/statuses/oembed.{format}', true  ),
     51                        '#https?://(.+\.)?imgur\.com/.*#i'                   => array( 'http://api.imgur.com/oembed',                       true  ),
    5152                ) );
    5253
    5354                // Fix any embeds that contain new lines in the middle of the HTML which breaks wpautop().
  • wp-includes/ms-settings.php

     
    8686                        if ( '%siteurl%' == $destination )
    8787                                $destination = "http://" . $current_site->domain . $current_site->path;
    8888                } else {
    89                         $destination = 'http://' . $current_site->domain . $current_site->path . 'wp-signup.php?new=' . str_replace( '.' . $current_site->domain, '', $domain );
     89                        $destination = 'http://' . $current_site->domain . $current_site->wp_siteurl_subdir . 'wp-signup.php?new=' . str_replace( '.' . $current_site->domain, '', $domain );
    9090                }
    9191                header( 'Location: ' . $destination );
    9292                die();
  • wp-includes/ms-functions.php

     
    586586                $mydomain = $blogname . '.' . preg_replace( '|^www\.|', '', $domain );
    587587                $path = $base;
    588588        } else {
    589                 $mydomain = "$domain";
    590                 $path = $base.$blogname.'/';
     589                $mydomain = $domain;
     590                $path = '/' . join_with_slashes( $base, $blogname ) . '/';
    591591        }
    592592        if ( domain_exists($mydomain, $path) )
    593593                $errors->add('blogname', __('Sorry, that site already exists!'));
     
    11321132
    11331133        $url = get_blogaddress_by_id( $blog_id );
    11341134
     1135        $url = untrailingslashit( get_blogaddress_by_id( $blog_id ) );
     1136
    11351137        // Set everything up
    11361138        make_db_current_silent( 'blog' );
    11371139        populate_options();
    11381140        populate_roles();
    11391141        $wp_roles->_init();
    11401142
    1141         $url = untrailingslashit( $url );
    1142 
    11431143        update_option( 'siteurl', $url );
    11441144        update_option( 'home', $url );
    11451145
     
    18741874
    18751875/**
    18761876 * Formats a URL to use https.
    1877  * 
     1877 *
    18781878 * Useful as a filter.
    18791879 *
    18801880 * @since 2.8.5
  • wp-admin/network.php

     
    5151 * @return bool Whether subdomain install is allowed
    5252 */
    5353function allow_subdomain_install() {
    54         $domain = preg_replace( '|https?://([^/]+)|', '$1', get_option( 'siteurl' ) );
    55         if( false !== strpos( $domain, '/' ) || 'localhost' == $domain || preg_match( '|[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+|', $domain ) )
     54        $domain = preg_replace( '|https?://([^/]+)|', '$1', get_option( 'home' ) );
     55        if( parse_url( get_option( 'home' ), PHP_URL_PATH ) || 'localhost' == $domain || preg_match( '|^[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+$|', $domain ) )
    5656                return false;
    5757
    5858        return true;
     
    144144function network_step1( $errors = false ) {
    145145        global $is_apache;
    146146
    147         if ( get_option( 'siteurl' ) != get_option( 'home' ) ) {
    148                 echo '<div class="error"><p><strong>' . __('ERROR:') . '</strong> ' . sprintf( __( 'Your <strong>WordPress address</strong> must match your <strong>Site address</strong> before creating a Network. See <a href="%s">General Settings</a>.' ), esc_url( admin_url( 'options-general.php' ) ) ) . '</p></div>';
    149                 echo '</div>';
    150                 include ( ABSPATH . 'wp-admin/admin-footer.php' );
    151                 die();
    152         }
    153 
    154147        if ( defined('DO_NOT_UPGRADE_GLOBAL_TABLES') ) {
    155148                echo '<div class="error"><p><strong>' . __('ERROR:') . '</strong> ' . __( 'The constant DO_NOT_UPGRADE_GLOBAL_TABLES cannot be defined when creating a network.' ) . '</p></div>';
    156149                echo '</div>';
     
    314307 * @since 3.0.0
    315308 */
    316309function network_step2( $errors = false ) {
    317         global $base, $wpdb;
    318         $hostname = get_clean_basedomain();
     310        global $wpdb;
    319311
    320         if ( ! isset( $base ) )
    321                 $base = trailingslashit( stripslashes( dirname( dirname( $_SERVER['SCRIPT_NAME'] ) ) ) );
     312        $hostname          = get_clean_basedomain();
     313        $slashed_home      = trailingslashit( get_option( 'home'    ) );
     314        $slashed_siteurl   = trailingslashit( get_option( 'siteurl' ) );
     315        $wp_siteurl_subdir = '/' . str_replace( $slashed_home, '', $slashed_siteurl );
     316        $rewrite_base      = ! empty( $wp_siteurl_subdir ) ? ltrim( trailingslashit( $wp_siteurl_subdir ), '/' ) : '';
     317        $base              = parse_url( $slashed_home, PHP_URL_PATH );
    322318
    323319        // Wildcard DNS message.
    324320        if ( is_wp_error( $errors ) )
     
    344340                }
    345341        }
    346342
     343        $subdir_match       = $subdomain_install ? '' : '(?:[_0-9a-zA-Z-]+/)?';
     344        $subdir_replacement = $subdomain_install ? '' : '$1';
     345
    347346        if ( $_POST || ! is_multisite() ) {
    348347?>
    349348                <h3><?php esc_html_e( 'Enabling the Network' ); ?></h3>
     
    364363                                <textarea class="code" readonly="readonly" cols="100" rows="7">
    365364define('MULTISITE', true);
    366365define('SUBDOMAIN_INSTALL', <?php echo $subdomain_install ? 'true' : 'false'; ?>);
    367 $base = '<?php echo $base; ?>';
    368366define('DOMAIN_CURRENT_SITE', '<?php echo $hostname; ?>');
    369367define('PATH_CURRENT_SITE', '<?php echo $base; ?>');
    370368define('SITE_ID_CURRENT_SITE', 1);
    371 define('BLOG_ID_CURRENT_SITE', 1);</textarea>
     369define('BLOG_ID_CURRENT_SITE', 1);
     370<?php if ( $wp_siteurl_subdir ): ?>
     371define('WP_SITEURL_SUBDIR', '<?php echo $wp_siteurl_subdir; ?>');
     372<?php endif; // $wp_siteurl_subdir ?>
     373</textarea>
    372374<?php
    373375        $keys_salts = array( 'AUTH_KEY' => '', 'SECURE_AUTH_KEY' => '', 'LOGGED_IN_KEY' => '', 'NONCE_KEY' => '', 'AUTH_SALT' => '', 'SECURE_AUTH_SALT' => '', 'LOGGED_IN_SALT' => '', 'NONCE_SALT' => '' );
    374376        foreach ( $keys_salts as $c => $v ) {
    375377                if ( defined( $c ) )
    376378                        unset( $keys_salts[ $c ] );
    377379        }
     380
    378381        if ( ! empty( $keys_salts ) ) {
    379382                $keys_salts_str = '';
    380383                $from_api = wp_remote_get( 'https://api.wordpress.org/secret-key/1.1/salt/' );
     
    399402</li>
    400403<?php
    401404        if ( iis7_supports_permalinks() ) :
     405                // IIS doesn't support RewriteBase, all your RewriteBase are belong to us
     406                $iis_subdir_match = ltrim( $base, '/' ) . $subdir_match;
     407                $iis_rewrite_base = ltrim( $base, '/' ) . $rewrite_base;
     408                $iis_subdir_replacement = $subdomain_install ? '' : '{R:1}';
    402409
    403                         if ( $subdomain_install ) {
    404                                 $web_config_file =
    405 '<?xml version="1.0" encoding="UTF-8"?>
     410                $web_config_file = <<<EOF
     411<?xml version="1.0" encoding="UTF-8"?>
    406412<configuration>
    407413    <system.webServer>
    408414        <rewrite>
     
    414420                                if ( is_multisite() && get_site_option( 'ms_files_rewriting' ) ) {
    415421                                        $web_config_file .= '
    416422                <rule name="WordPress Rule for Files" stopProcessing="true">
    417                     <match url="^files/(.+)" ignoreCase="false" />
    418                     <action type="Rewrite" url="wp-includes/ms-files.php?file={R:1}" appendQueryString="false" />
     423                    <match url="^{$iis_subdir_match}files/(.+)" ignoreCase="false" />
     424                    <action type="Rewrite" url="{$iis_rewrite_base}wp-includes/ms-files.php?file={R:1}" appendQueryString="false" />
    419425                </rule>';
    420426                }
    421427                $web_config_file .= '
    422428                <rule name="WordPress Rule 2" stopProcessing="true">
    423                     <match url="^" ignoreCase="false" />
    424                     <conditions logicalGrouping="MatchAny">
    425                         <add input="{REQUEST_FILENAME}" matchType="IsFile" ignoreCase="false" />
    426                         <add input="{REQUEST_FILENAME}" matchType="IsDirectory" ignoreCase="false" />
    427                     </conditions>
    428                     <action type="None" />
     429                    <match url="^{$iis_subdir_match}wp-admin$" ignoreCase="false" />
     430                    <action type="Redirect" url="{$iis_subdir_replacement}wp-admin/" redirectType="Permanent" />
    429431                </rule>
    430432                <rule name="WordPress Rule 3" stopProcessing="true">
    431                     <match url="." ignoreCase="false" />
    432                     <action type="Rewrite" url="index.php" />
    433                 </rule>
    434             </rules>
    435         </rewrite>
    436     </system.webServer>
    437 </configuration>';
    438                         } else {
    439                                 $web_config_file =
    440 '<?xml version="1.0" encoding="UTF-8"?>
    441 <configuration>
    442     <system.webServer>
    443         <rewrite>
    444             <rules>
    445                 <rule name="WordPress Rule 1" stopProcessing="true">
    446                     <match url="^index\.php$" ignoreCase="false" />
    447                     <action type="None" />
    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 .= '
    457                 <rule name="WordPress Rule 2" stopProcessing="true">
    458                     <match url="^([_0-9a-zA-Z-]+/)?wp-admin$" ignoreCase="false" />
    459                     <action type="Redirect" url="{R:1}wp-admin/" redirectType="Permanent" />
    460                 </rule>
    461                 <rule name="WordPress Rule 3" stopProcessing="true">
    462433                    <match url="^" ignoreCase="false" />
    463434                    <conditions logicalGrouping="MatchAny">
    464435                        <add input="{REQUEST_FILENAME}" matchType="IsFile" ignoreCase="false" />
     
    467438                    <action type="None" />
    468439                </rule>
    469440                <rule name="WordPress Rule 4" stopProcessing="true">
    470                     <match url="^[_0-9a-zA-Z-]+/(wp-(content|admin|includes).*)" ignoreCase="false" />
    471                     <action type="Rewrite" url="{R:1}" />
     441                    <match url="^{$iis_subdir_match}(wp-(content|admin|includes).*)" ignoreCase="false" />
     442                    <action type="Rewrite" url="{$iis_rewrite_base}{R:1}" />
    472443                </rule>
    473444                <rule name="WordPress Rule 5" stopProcessing="true">
    474                     <match url="^([_0-9a-zA-Z-]+/)?(.*\.php)$" ignoreCase="false" />
    475                     <action type="Rewrite" url="{R:2}" />
     445                    <match url="^{$iis_subdir_match}([_0-9a-zA-Z-]+/)?(.*\.php)$" ignoreCase="false" />
     446                    <action type="Rewrite" url="{$iis_rewrite_base}{R:2}" />
    476447                </rule>
    477448                <rule name="WordPress Rule 6" stopProcessing="true">
    478449                    <match url="." ignoreCase="false" />
     
    481452            </rules>
    482453        </rewrite>
    483454    </system.webServer>
    484 </configuration>';
    485                         }
     455</configuration>
     456EOF;
     457
    486458        ?>
    487                 <li><p><?php printf( __( 'Add the following to your <code>web.config</code> file in <code>%s</code>, replacing other WordPress rules:' ), ABSPATH ); ?></p>
     459                <li><p><?php printf( __( 'Add the following to your <code>web.config</code> file in <code>%s</code>, replacing other WordPress rules:' ), trailingslashit( str_replace( trailingslashit( $wp_siteurl_subdir ), '', ABSPATH ) ) ); ?></p>
    488460                <?php
    489461                if ( ! $subdomain_install && WP_CONTENT_DIR != ABSPATH . 'wp-content' )
    490462                        echo '<p><strong>' . __('Warning:') . ' ' . __( 'Subdirectory networks may not be fully compatible with custom wp-content directories.' ) . '</strong></p>';
     
    495467
    496468        <?php else : // end iis7_supports_permalinks(). construct an htaccess file instead:
    497469
    498                 $htaccess_file = 'RewriteEngine On
    499 RewriteBase ' . $base . '
    500 RewriteRule ^index\.php$ - [L]' . "\n";
    501 
     470                $ms_files_rewriting = '';
    502471                if ( is_multisite() && get_site_option( 'ms_files_rewriting' ) ) {
    503                         $htaccess_file .= "\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";
     472                        $ms_files_rewriting = "\n# uploaded files\nRewriteRule ^";
     473                        $ms_files_rewriting .= $subdir_match . 'files/(.+) wp-includes/ms-files.php?file=$1 [L]' . "\n";
    505474                }
    506475
    507                 if ( ! $subdomain_install )
    508                         $htaccess_file .= "\n# add a trailing slash to /wp-admin\n" . 'RewriteRule ^([_0-9a-zA-Z-]+/)?wp-admin$ $1wp-admin/ [R=301,L]' . "\n";
     476                $htaccess_file = <<<EOF
     477RewriteEngine On
     478RewriteBase {$base}
     479RewriteRule ^index\.php$ - [L]
     480{$ms_files_rewriting}
     481# add a trailing slash to /wp-admin
     482RewriteRule ^{$subdir_match}wp-admin$ {$subdir_replacement}wp-admin/ [R=301,L]
    509483
    510                 $htaccess_file .= "\n" . 'RewriteCond %{REQUEST_FILENAME} -f [OR]
     484RewriteCond %{REQUEST_FILENAME} -f [OR]
    511485RewriteCond %{REQUEST_FILENAME} -d
    512 RewriteRule ^ - [L]';
     486RewriteRule ^ - [L]
     487RewriteRule ^{$subdir_match}(wp-(content|admin|includes).*) {$rewrite_base}$1 [L]
     488RewriteRule ^{$subdir_match}(.*\.php)$ {$rewrite_base}$1 [L]
     489RewriteRule . index.php [L]
     490EOF;
    513491
    514                 // @todo custom content dir.
    515                 if ( ! $subdomain_install )
    516                         $htaccess_file .= "\nRewriteRule  ^[_0-9a-zA-Z-]+/(wp-(content|admin|includes).*) $1 [L]\nRewriteRule  ^[_0-9a-zA-Z-]+/(.*\.php)$ $1 [L]";
    517 
    518                 $htaccess_file .= "\nRewriteRule . index.php [L]";
    519 
    520492                ?>
    521493                <li><p><?php printf( __( 'Add the following to your <code>.htaccess</code> file in <code>%s</code>, replacing other WordPress rules:' ), ABSPATH ); ?></p>
    522494                <?php
     
    537509
    538510if ( $_POST ) {
    539511
    540         $base = trailingslashit( stripslashes( dirname( dirname( $_SERVER['SCRIPT_NAME'] ) ) ) );
    541 
    542512        check_admin_referer( 'install-network-1' );
    543513
    544514        require_once( ABSPATH . 'wp-admin/includes/upgrade.php' );
    545515        // create network tables
    546516        install_network();
    547         $hostname = get_clean_basedomain();
     517        $base              = parse_url( trailingslashit( get_option( 'home' ) ), PHP_URL_PATH );
    548518        $subdomain_install = allow_subdomain_install() ? !empty( $_POST['subdomain_install'] ) : false;
    549519        if ( ! network_domain_check() ) {
    550520                $result = populate_network( 1, get_clean_basedomain(), sanitize_email( $_POST['email'] ), stripslashes( $_POST['sitename'] ), $base, $subdomain_install );
  • wp-admin/network/site-new.php

     
    6262
    6363        if ( is_subdomain_install() ) {
    6464                $newdomain = $domain . '.' . preg_replace( '|^www\.|', '', $current_site->domain );
    65                 $path = $base;
     65                $path      = $current_site->path;
    6666        } else {
    6767                $newdomain = $current_site->domain;
    68                 $path = $base . $domain . '/';
     68                $path      = $current_site->path . $domain . '/';
    6969        }
    7070
    7171        $password = 'N/A';
  • wp-admin/network/site-users.php

     
    249249<?php do_action( 'network_site_users_after_list_table', '' );?>
    250250
    251251<?php if ( current_user_can( 'promote_users' ) && apply_filters( 'show_network_site_users_add_existing_form', true ) ) : ?>
    252 <h4 id="add-user"><?php _e('Add User to This Site') ?></h4>
    253         <?php if ( current_user_can( 'create_users' ) && apply_filters( 'show_network_site_users_add_new_form', true ) ) : ?>
    254 <p><?php _e( 'You may add from existing network users, or set up a new user to add to this site.' ); ?></p>
    255         <?php else : ?>
    256 <p><?php _e( 'You may add from existing network users to this site.' ); ?></p>
    257         <?php endif; ?>
    258 <h5 id="add-existing-user"><?php _e('Add Existing User') ?></h5>
     252<h3 id="add-existing-user"><?php _e( 'Add Existing User' ); ?></h3>
    259253<form action="site-users.php?action=adduser" id="adduser" method="post">
    260254        <?php wp_nonce_field( 'edit-site' ); ?>
    261255        <input type="hidden" name="id" value="<?php echo esc_attr( $id ) ?>" />
     
    265259                        <td><input type="text" class="regular-text wp-suggest-user" name="newuser" id="newuser" /></td>
    266260                </tr>
    267261                <tr>
    268                         <th scope="row"><?php _e( 'Role'); ?></th>
     262                        <th scope="row"><?php _e( 'Role' ); ?></th>
    269263                        <td><select name="new_role" id="new_role_0">
    270264                        <?php
    271265                        reset( $editblog_roles );
    272                         foreach ( $editblog_roles as $role => $role_assoc ){
     266                        foreach ( $editblog_roles as $role => $role_assoc ) {
    273267                                $name = translate_user_role( $role_assoc['name'] );
    274                                 $selected = ( $role == $default_role ) ? 'selected="selected"' : '';
    275                                 echo '<option ' . $selected . ' value="' . esc_attr( $role ) . '">' . esc_html( $name ) . '</option>';
     268                                echo '<option ' . selected( $default_role, $role, false ) . ' value="' . esc_attr( $role ) . '">' . esc_html( $name ) . '</option>';
    276269                        }
    277270                        ?>
    278271                        </select></td>
    279272                </tr>
    280273        </table>
    281274        <?php wp_nonce_field( 'add-user', '_wpnonce_add-user' ) ?>
    282         <?php submit_button( __('Add User'), 'primary', 'add-user', false, array( 'id' => 'submit-add-existing-user' ) ); ?>
     275        <?php submit_button( __( 'Add User' ), 'primary', 'add-user', true, array( 'id' => 'submit-add-existing-user' ) ); ?>
    283276</form>
    284277<?php endif; ?>
    285278
    286279<?php if ( current_user_can( 'create_users' ) && apply_filters( 'show_network_site_users_add_new_form', true ) ) : ?>
    287 <h5 id="add-new-user"><?php _e('Add New User') ?></h5>
     280<h3 id="add-new-user"><?php _e( 'Add New User' ); ?></h3>
    288281<form action="<?php echo network_admin_url('site-users.php?action=newuser'); ?>" id="newuser" method="post">
    289282        <?php wp_nonce_field( 'edit-site' ); ?>
    290283        <input type="hidden" name="id" value="<?php echo esc_attr( $id ) ?>" />
     
    298291                        <td><input type="text" class="regular-text" name="user[email]" /></td>
    299292                </tr>
    300293                <tr>
    301                         <th scope="row"><?php _e( 'Role'); ?></th>
     294                        <th scope="row"><?php _e( 'Role' ); ?></th>
    302295                        <td><select name="new_role" id="new_role_0">
    303296                        <?php
    304297                        reset( $editblog_roles );
    305                         foreach ( $editblog_roles as $role => $role_assoc ){
     298                        foreach ( $editblog_roles as $role => $role_assoc ) {
    306299                                $name = translate_user_role( $role_assoc['name'] );
    307                                 $selected = ( $role == $default_role ) ? 'selected="selected"' : '';
    308                                 echo '<option ' . $selected . ' value="' . esc_attr( $role ) . '">' . esc_html( $name ) . '</option>';
     300                                echo '<option ' . selected( $default_role, $role, false ) . ' value="' . esc_attr( $role ) . '">' . esc_html( $name ) . '</option>';
    309301                        }
    310302                        ?>
    311303                        </select></td>
     
    315307                </tr>
    316308        </table>
    317309        <?php wp_nonce_field( 'add-user', '_wpnonce_add-new-user' ) ?>
    318         <?php submit_button( __('Add New User'), 'primary', 'add-user', false, array( 'id' => 'submit-add-user' ) ); ?>
     310        <?php submit_button( __( 'Add New User' ), 'primary', 'add-user', true, array( 'id' => 'submit-add-user' ) ); ?>
    319311</form>
    320312<?php endif; ?>
    321313</div>