block subdomain install when install is in a folder, see #12736
git-svn-id: https://develop.svn.wordpress.org/trunk@13926 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
parent
736637fb27
commit
fc051c063f
@ -36,6 +36,19 @@ function network_domain_check() {
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Allow subdomain install
|
||||
*
|
||||
* @since 3.0.0
|
||||
* @return bool - whether subdomain install is allowed
|
||||
*/
|
||||
function allow_subdomain_install() {
|
||||
$path = preg_replace( '|https?://[^/]|', '', get_option( 'siteurl' ) );
|
||||
if( strlen( $path ) > 1 || 'localhost' == $_SERVER[ 'HTTP_HOST' ] )
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
/**
|
||||
* Get base domain of network.
|
||||
*
|
||||
@ -134,7 +147,7 @@ function network_step1( $errors = false ) {
|
||||
echo '<p>' . __( 'If <code>mod_rewrite</code> is disabled, ask your administrator to enable that module, or look at the <a href="http://httpd.apache.org/docs/mod/mod_rewrite.html">Apache documentation</a> or <a href="http://www.google.com/search?q=apache+mod_rewrite">elsewhere</a> for help setting it up.' ) . '</p></div>';
|
||||
}
|
||||
|
||||
if ( 'localhost' != $hostname ) : ?>
|
||||
if ( allow_subdomain_install() ) : ?>
|
||||
<h3><?php esc_html_e( 'Addresses of Sites in your Network' ); ?></h3>
|
||||
<p><?php _e( 'Please choose whether you would like sites in your WordPress network to use sub-domains or sub-directories. <strong>You cannot change this later.</strong>' ); ?></p>
|
||||
<p><?php _e( "You will need a wildcard DNS record if you're going to use the virtual host (sub-domain) functionality." ); ?></p>
|
||||
@ -175,6 +188,11 @@ function network_step1( $errors = false ) {
|
||||
<th scope="row"><?php esc_html_e( 'Sub-directory Install' ); ?></th>
|
||||
<td><?php _e('Because you are using <code>localhost</code>, the sites in your WordPress network must use sub-directories. Consider using <code>localhost.localdomain</code> if you wish to use sub-domains.'); ?></td>
|
||||
</tr>
|
||||
<?php elseif ( !allow_subdomain_install() ) : ?>
|
||||
<tr>
|
||||
<th scope="row"><?php esc_html_e( 'Sub-directory Install' ); ?></th>
|
||||
<td><?php _e('Because your install is in a directory, the sites in your WordPress network must use sub-directories.'); ?></td>
|
||||
</tr>
|
||||
<?php endif; ?>
|
||||
<?php if ( ! $is_www ) : ?>
|
||||
<tr>
|
||||
@ -217,7 +235,7 @@ function network_step2( $errors = false ) {
|
||||
echo '<div class="error">' . $errors->get_error_message() . '</div>';
|
||||
|
||||
if ( $_POST ) {
|
||||
$vhost = 'localhost' == $hostname ? false : (bool) $_POST['subdomain_install'];
|
||||
$vhost = !allow_subdomain_install() ? false : (bool) $_POST['subdomain_install'];
|
||||
} else {
|
||||
if ( is_multisite() ) {
|
||||
$vhost = is_subdomain_install();
|
||||
@ -326,7 +344,7 @@ if ( $_POST ) {
|
||||
// create network tables
|
||||
install_network();
|
||||
$hostname = get_clean_basedomain();
|
||||
$subdomain_install = 'localhost' == $hostname ? false : (bool) $_POST['subdomain_install'];
|
||||
$subdomain_install = !allow_subdomain_install() ? false : (bool) $_POST['subdomain_install'];
|
||||
if ( ! network_domain_check() ) {
|
||||
$result = populate_network( 1, get_clean_basedomain(), sanitize_email( $_POST['email'] ), $_POST['sitename'], $base, $subdomain_install );
|
||||
if ( is_wp_error( $result ) ) {
|
||||
|
Loading…
Reference in New Issue
Block a user