tables( 'ms_global' ) as $table => $prefixed_table )
$wpdb->$table = $prefixed_table;
/**
* Check for an existing network.
*
* @since 3.0.0
* @return Whether a network exists.
*/
function network_domain_check() {
global $wpdb;
if ( $wpdb->get_var( "SHOW TABLES LIKE '$wpdb->site'" ) )
return $wpdb->get_var( "SELECT domain FROM $wpdb->site ORDER BY id ASC LIMIT 1" );
return false;
}
/**
* Allow subdomain install
*
* @since 3.0.0
* @return bool Whether subdomain install is allowed
*/
function allow_subdomain_install() {
$domain = preg_replace( '|https?://([^/]+)|', '$1', get_option( 'home' ) );
if( parse_url( get_option( 'home' ), PHP_URL_PATH ) || 'localhost' == $domain || preg_match( '|^[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+$|', $domain ) )
return false;
return true;
}
/**
* Allow subdirectory install
*
* @since 3.0.0
* @return bool Whether subdirectory install is allowed
*/
function allow_subdirectory_install() {
global $wpdb;
if ( apply_filters( 'allow_subdirectory_install', false ) )
return true;
if ( defined( 'ALLOW_SUBDIRECTORY_INSTALL' ) && ALLOW_SUBDIRECTORY_INSTALL )
return true;
$post = $wpdb->get_row( "SELECT ID FROM $wpdb->posts WHERE post_date < DATE_SUB(NOW(), INTERVAL 1 MONTH) AND post_status = 'publish'" );
if ( empty( $post ) )
return true;
return false;
}
/**
* Get base domain of network.
*
* @since 3.0.0
* @return string Base domain.
*/
function get_clean_basedomain() {
if ( $existing_domain = network_domain_check() )
return $existing_domain;
$domain = preg_replace( '|https?://|', '', get_option( 'siteurl' ) );
if ( $slash = strpos( $domain, '/' ) )
$domain = substr( $domain, 0, $slash );
return $domain;
}
if ( ! network_domain_check() && ( ! defined( 'WP_ALLOW_MULTISITE' ) || ! WP_ALLOW_MULTISITE ) )
wp_die( __( 'You must define the WP_ALLOW_MULTISITE
constant as true in your wp-config.php file to allow creation of a Network.' ) );
if ( is_network_admin() ) {
$title = __( 'Network Setup' );
$parent_file = 'settings.php';
} else {
$title = __( 'Create a Network of WordPress Sites' );
$parent_file = 'tools.php';
}
$network_help = '
' . __('This screen allows you to configure a network as having subdomains (site1.example.com
) or subdirectories (example.com/site1
). Subdomains require wildcard subdomains to be enabled in Apache and DNS records, if your host allows it.') . '
' . __('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).') . '
' . '' . __('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.') . '
' . '' . __('Add the designated lines of code to wp-config.php (just before /*...stop editing...*/
) and .htaccess
(replacing the existing WordPress rules).') . '
' . __('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.') . '
' . '' . __('The choice of subdirectory sites is disabled if this setup is more than a month old because of permalink problems with “/blog/” from the main site. This disabling will be addressed in a future version.') . '
' . '' . __('For more information:') . '
' . '' . __('Documentation on Creating a Network') . '
' . '' . __('Documentation on the Network Screen') . '
'; get_current_screen()->add_help_tab( array( 'id' => 'network', 'title' => __('Network'), 'content' => $network_help, ) ); get_current_screen()->set_help_sidebar( '' . __('For more information:') . '
' . '' . __('Documentation on Creating a Network') . '
' . '' . __('Documentation on the Network Screen') . '
' . '' . __('Support Forums') . '
' ); include( ABSPATH . 'wp-admin/admin-header.php' ); ?>' . __('ERROR:') . ' ' . __( 'The constant DO_NOT_UPGRADE_GLOBAL_TABLES cannot be defined when creating a network.' ) . '
' . __('Warning:') . ' ' . sprintf( __( 'Please deactivate your plugins before enabling the Network feature.' ), admin_url( 'plugins.php?plugin_status=active' ) ) . '
' . __( 'Once the network is created, you may reactivate your plugins.' ) . '
'; echo ''; include( ABSPATH . 'wp-admin/admin-footer.php' ); die(); } $hostname = get_clean_basedomain(); $has_ports = strstr( $hostname, ':' ); if ( ( false !== $has_ports && ! in_array( $has_ports, array( ':80', ':443' ) ) ) ) { echo '' . __( 'ERROR:') . ' ' . __( 'You cannot install a network of sites with your server address.' ) . '
' . sprintf( __( 'You cannot use port numbers such as %s
.' ), $has_ports ) . '
Caution: We recommend you back up your existing wp-config.php
and %s
files.' ), '.htaccess' );
elseif ( file_exists( ABSPATH . 'web.config' ) )
printf( __( 'Caution: We recommend you back up your existing wp-config.php
and %s
files.' ), 'web.config' );
else
_e( 'Caution: We recommend you back up your existing wp-config.php
file.' );
?>
wp-config.php file in %s
above the line reading /* That’s all, stop editing! Happy blogging. */
:' ), $location_of_wp_config ); ?>
wp-config.php file.', 'These unique authentication keys are also missing from your wp-config.php
file.', $num_keys_salts ); ?>
web.config file in %s
, replacing other WordPress rules:' ), trailingslashit( str_replace( trailingslashit( $wp_siteurl_subdir ), '', ABSPATH ) ) ); ?>
.htaccess file in %s
, replacing other WordPress rules:' ), ABSPATH ); ?>