diff --git a/wp-admin/network.php b/wp-admin/network.php index 4caf4cdea..351f7432f 100644 --- a/wp-admin/network.php +++ b/wp-admin/network.php @@ -40,7 +40,7 @@ function network_domain_check() { * Allow subdomain install * * @since 3.0.0 - * @return bool - whether subdomain install is allowed + * @return bool Whether subdomain install is allowed */ function allow_subdomain_install() { $domain = preg_replace( '|https?://[^/]|', '', get_option( 'siteurl' ) ); @@ -237,14 +237,14 @@ function network_step2( $errors = false ) { echo '
' . $errors->get_error_message() . '
'; if ( $_POST ) { - $vhost = !allow_subdomain_install() ? false : (bool) $_POST['subdomain_install']; + $subdomain_install = allow_subdomain_install() ? ! empty( $_POST['subdomain_install'] ) : false; } else { if ( is_multisite() ) { - $vhost = is_subdomain_install(); + $subdomain_install = is_subdomain_install(); ?>

get_var( "SELECT meta_value FROM $wpdb->sitemeta WHERE site_id = 1 AND meta_key = 'subdomain_install'" ); + $subdomain_install = (bool) $wpdb->get_var( "SELECT meta_value FROM $wpdb->sitemeta WHERE site_id = 1 AND meta_key = 'subdomain_install'" ); ?>

@@ -265,7 +265,7 @@ function network_step2( $errors = false ) {
  • wp-config.php file in %s above the line reading /* That’s all, stop editing! Happy blogging. */:' ), ABSPATH ); ?>

  • diff --git a/wp-includes/ms-default-constants.php b/wp-includes/ms-default-constants.php index 23e04f3c4..38dce50fb 100644 --- a/wp-includes/ms-default-constants.php +++ b/wp-includes/ms-default-constants.php @@ -91,4 +91,50 @@ function ms_file_constants( ) { if ( !defined( 'WPMU_ACCEL_REDIRECT' ) ) define( 'WPMU_ACCEL_REDIRECT', false ); } + +/** + * Defines Multisite subdomain constants and handles warnings and notices. + * + * VHOST is deprecated in favor of SUBDOMAIN_INSTALL, which is a bool. + * + * On first call, the constants are checked and defined. On second call, + * we will have translations loaded and can trigger warnings easily. + * + * @since 3.0.0 + */ +function ms_subdomain_constants() { + static $error = null; + static $error_warn = false; + + if ( false === $error ) + return; + + if ( $error ) { + $vhost_deprecated = __( 'The constant VHOST is deprecated. Use the boolean constant SUBDOMAIN_INSTALL in wp-config.php to enable a subdomain configuration. Use is_subdomain_install() to check whether a subdomain configuration is enabled.' ); + if ( $error_warn ) { + trigger_error( __( 'Conflicting values for the constants VHOST and SUBDOMAIN_INSTALL. The value of SUBDOMAIN_INSTALL will be assumed to be your subdomain configuration setting.' ) . ' ' . $vhost_deprecated, E_USER_WARNING ); + } else { + _deprecated_argument( 'define()', '3.0', $vhost_deprecated ); + } + return; + } + + if ( defined( 'SUBDOMAIN_INSTALL' ) && defined( 'VHOST' ) ) { + if ( SUBDOMAIN_INSTALL == ( 'yes' == VHOST ) ) { + $error = true; + } else { + $error = $error_warn = true; + } + } elseif ( defined( 'SUBDOMAIN_INSTALL' ) ) { + define( 'VHOST', SUBDOMAIN_INSTALL ? 'yes' : 'no' ); + } elseif ( defined( 'VHOST' ) ) { + $error = true; + define( 'SUBDOMAIN_INSTALL', 'yes' == VHOST ); + } else { + define( 'SUBDOMAIN_INSTALL', false ); + define( 'VHOST', 'no' ); + } +} +add_action( 'init', 'ms_subdomain_constants' ); + ?> diff --git a/wp-includes/ms-load.php b/wp-includes/ms-load.php index ecb83d77a..bcb075cda 100644 --- a/wp-includes/ms-load.php +++ b/wp-includes/ms-load.php @@ -16,6 +16,9 @@ * @return bool True if subdomain configuration is enabled, false otherwise. */ function is_subdomain_install() { + if ( defined('SUBDOMAIN_INSTALL') ) + return SUBDOMAIN_INSTALL; + if ( defined('VHOST') && VHOST == 'yes' ) return true; diff --git a/wp-includes/ms-settings.php b/wp-includes/ms-settings.php index cc0691cad..14862f9e1 100644 --- a/wp-includes/ms-settings.php +++ b/wp-includes/ms-settings.php @@ -21,6 +21,9 @@ require( ABSPATH . WPINC . '/ms-default-constants.php' ); if ( defined( 'SUNRISE' ) ) include_once( WP_CONTENT_DIR . '/sunrise.php' ); +/** Check for and define SUBDOMAIN_INSTALL and the deprecated VHOST constant. */ +ms_subdomain_constants(); + if ( !isset( $current_site ) || !isset( $current_blog ) ) { $domain = addslashes( $_SERVER['HTTP_HOST'] ); diff --git a/wp-includes/wp-db.php b/wp-includes/wp-db.php index 64e812be1..de63b7188 100644 --- a/wp-includes/wp-db.php +++ b/wp-includes/wp-db.php @@ -575,7 +575,7 @@ class wpdb { foreach ( $this->tables( 'global' ) as $table => $prefixed_table ) $this->$table = $prefixed_table; - if ( defined( 'VHOST' ) && empty( $this->blogid ) ) + if ( is_multisite() && empty( $this->blogid ) ) return $old_prefix; $this->prefix = $this->get_blog_prefix();