X-Git-Url: https://scripts.mit.edu/gitweb/autoinstalls/wordpress.git/blobdiff_plain/699231ae09f7057a4d0000cdf32e50a3df6a04ca..5aa86a9053fb0fa15846bb60aac2fb8fdfff524a:/wp-admin/network.php diff --git a/wp-admin/network.php b/wp-admin/network.php index a2951641..a3b09e81 100644 --- a/wp-admin/network.php +++ b/wp-admin/network.php @@ -10,7 +10,7 @@ * @subpackage Administration */ -define( 'WP_NETWORK_ADMIN_PAGE', true ); +define( 'WP_INSTALLING_NETWORK', true ); /** WordPress Administration Bootstrap */ require_once( './admin.php' ); @@ -18,8 +18,14 @@ require_once( './admin.php' ); if ( ! is_super_admin() ) wp_die( __( 'You do not have sufficient permissions to manage options for this site.' ) ); -if ( is_multisite() && ! defined( 'MULTISITE' ) ) - wp_die( __( 'The Network creation panel is not for WordPress MU networks.' ) ); +if ( is_multisite() ) { + if ( ! is_network_admin() ) { + wp_redirect( network_admin_url( 'setup.php' ) ); + exit; + } + if ( ! defined( 'MULTISITE' ) ) + wp_die( __( 'The Network creation panel is not for WordPress MU networks.' ) ); +} // We need to create references to ms global tables to enable Network. foreach ( $wpdb->tables( 'ms_global' ) as $table => $prefixed_table ) @@ -89,26 +95,41 @@ function get_clean_basedomain() { 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.' ) ); -$title = __( 'Create a Network of WordPress Sites' ); -$parent_file = 'tools.php'; +if ( is_network_admin() ) { + $title = __( 'Network Setup' ); + $parent_file = 'settings.php'; +} else { + $title = __( 'Create a Network of WordPress Sites' ); + $parent_file = 'tools.php'; +} -add_contextual_help($current_screen, - '

' . __('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.') . '

' . +$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 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.') . '

' . + '

' . __('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 a blogs.dir directory under /wp-content and add the designated lines of code to wp-config.php (just before /*...stop editing...*/) and .htaccess (replacing the existing WordPress rules).') . '

' . - '

' . __('Refreshing your browser will take you to a screen with an archive of those added lines of code. A set of six links under Super Admin will appear at the top of the main left navigation menu. The multisite network is now enabled.') . '

' . - '

' . __('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 soon in a future version.') . '

' . + '

' . __('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:') . '

' . - '

' . __('General Network Creation Documentation') . '

' . - '

' . __('Tools > Network Documentation') . '

' . + '

' . __('Documentation on Creating a Network') . '

' . + '

' . __('Documentation on the Network Screen') . '

' . '

' . __('Support Forums') . '

' ); -include( './admin-header.php' ); +include( ABSPATH . 'wp-admin/admin-header.php' ); ?>
- +

' . __('Error:') . ' ' . sprintf( __( 'Your WordPress address must match your Site address before creating a Network. See General Settings.' ), esc_url( admin_url( 'options-general.php' ) ) ) . '

'; + echo '

' . __('ERROR:') . ' ' . sprintf( __( 'Your WordPress address must match your Site address before creating a Network. See General Settings.' ), esc_url( admin_url( 'options-general.php' ) ) ) . '

'; + echo ''; + include ( ABSPATH . 'wp-admin/admin-footer.php' ); + die(); + } + + if ( defined('DO_NOT_UPGRADE_GLOBAL_TABLES') ) { + echo '

' . __('ERROR:') . ' ' . __( 'The constant DO_NOT_UPGRADE_GLOBAL_TABLES cannot be defined when creating a network.' ) . '

'; echo ''; - include ('./admin-footer.php' ); + include ( ABSPATH . 'wp-admin/admin-footer.php' ); die(); } @@ -134,18 +162,18 @@ function network_step1( $errors = false ) { if ( ! empty( $active_plugins ) ) { echo '

' . __('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( './admin-footer.php' ); + 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.' ) . '

'; + echo '

' . __( 'ERROR:') . ' ' . __( 'You cannot install a network of sites with your server address.' ) . '

'; echo '

' . sprintf( __( 'You cannot use port numbers such as %s.' ), $has_ports ) . '

'; echo '' . __( 'Return to Dashboard' ) . ''; echo ''; - include( './admin-footer.php' ); + include( ABSPATH . 'wp-admin/admin-footer.php' ); die(); } @@ -211,7 +239,7 @@ function network_step1( $errors = false ) { if ( $is_www ) : ?>

-

%1$s before enabling the network feature. It will still be possible to visit your site using the www prefix with an address like %2$s but any links will not have the www prefix.' ), substr( $hostname, 4 ), $hostname ); ?> +

%1$s before enabling the network feature. It will still be possible to visit your site using the www prefix with an address like %2$s but any links will not have the www prefix.' ), substr( $hostname, 4 ), $hostname ); ?>

@@ -275,9 +303,9 @@ function network_step1( $errors = false ) {
-

' />

+ - ' . $errors->get_error_message() . ''; if ( $_POST ) { - $subdomain_install = allow_subdomain_install() ? ( allow_subdirectory_install() ? ! empty( $_POST['subdomain_install'] ) : true ) : false; + if ( allow_subdomain_install() ) + $subdomain_install = allow_subdirectory_install() ? ! empty( $_POST['subdomain_install'] ) : true; + else + $subdomain_install = false; } else { if ( is_multisite() ) { $subdomain_install = is_subdomain_install(); ?> -

-

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

@@ -314,19 +349,21 @@ function network_step2( $errors = false ) {

Caution: We recommend you back up your existing wp-config.php file.' ); + if ( file_exists( ABSPATH . '.htaccess' ) ) + printf( __( '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 and .htaccess files.' ); + _e( 'Caution: We recommend you back up your existing wp-config.php file.' ); ?>

  1. blogs.dir directory in %s. This directory is used to stored uploaded media for your additional sites and must be writeable by the web server.' ), WP_CONTENT_DIR ); + printf( __( 'Create a blogs.dir directory at %s/blogs.dir. This directory is used to store uploaded media for your additional sites and must be writeable by the web server.' ), WP_CONTENT_DIR ); if ( WP_CONTENT_DIR != ABSPATH . 'wp-content' ) - echo ' ' . __('Warning:') . ' ' . __( 'Networks may not be fully compatible with custom wp-content directories.' ) . '' . __('Warning:') . ' ' . __( 'Networks may not be fully compatible with custom wp-content directories.' ) . ''; ?>

  2. wp-config.php file in %s above the line reading /* That’s all, stop editing! Happy blogging. */:' ), ABSPATH ); ?>

    unset( $keys_salts[ $c ] ); } if ( ! empty( $keys_salts ) ) { + $keys_salts_str = ''; $from_api = wp_remote_get( 'https://api.wordpress.org/secret-key/1.1/salt/' ); if ( is_wp_error( $from_api ) ) { foreach ( $keys_salts as $c => $v ) { - $keys_salts[ $c ] = wp_generate_password( 64, true, true ); + $keys_salts_str .= "\ndefine( '$c', '" . wp_generate_password( 64, true, true ) . "' );"; } } else { $from_api = explode( "\n", wp_remote_retrieve_body( $from_api ) ); foreach ( $keys_salts as $c => $v ) { - $keys_salts[ $c ] = substr( array_shift( $from_api ), 28, 64 ); + $keys_salts_str .= "\ndefine( '$c', '" . substr( array_shift( $from_api ), 28, 64 ) . "' );"; } } $num_keys_salts = count( $keys_salts ); ?>

    wp-config.php file.', 'These unique authentication keys are also missing from your wp-config.php file.', $num_keys_salts ); ?>

    - + @@ -430,8 +464,8 @@ define( 'BLOG_ID_CURRENT_SITE', 1 ); - - + + @@ -449,7 +483,7 @@ define( 'BLOG_ID_CURRENT_SITE', 1 ); ?>
  3. web.config file in %s, replacing other WordPress rules:' ), ABSPATH ); ?>

@@ -471,14 +505,14 @@ RewriteRule ^ - [L]'; // @todo custom content dir. if ( ! $subdomain_install ) - $htaccess_file .= "\nRewriteRule ^([_0-9a-zA-Z-]+/)?(wp-(content|admin|includes).*) $2 [L]\nRewriteRule ^([_0-9a-zA-Z-]+/)?(.*\.php)$ $2 [L]"; + $htaccess_file .= "\nRewriteRule ^[_0-9a-zA-Z-]+/(wp-(content|admin|includes).*) $1 [L]\nRewriteRule ^[_0-9a-zA-Z-]+/(.*\.php)$ $1 [L]"; $htaccess_file .= "\nRewriteRule . index.php [L]"; ?>
  • .htaccess file in %s, replacing other WordPress rules:' ), ABSPATH ); ?>

  • + - +