]> scripts.mit.edu Git - autoinstalls/wordpress.git/blob - wp-admin/network.php
Wordpress 4.5.3
[autoinstalls/wordpress.git] / wp-admin / network.php
1 <?php
2 /**
3  * Network installation administration panel.
4  *
5  * A multi-step process allowing the user to enable a network of WordPress sites.
6  *
7  * @since 3.0.0
8  *
9  * @package WordPress
10  * @subpackage Administration
11  */
12
13 define( 'WP_INSTALLING_NETWORK', true );
14
15 /** WordPress Administration Bootstrap */
16 require_once( dirname( __FILE__ ) . '/admin.php' );
17
18 if ( ! is_super_admin() ) {
19         wp_die( __( 'You do not have sufficient permissions to manage options for this site.' ) );
20 }
21
22 if ( is_multisite() ) {
23         if ( ! is_network_admin() ) {
24                 wp_redirect( network_admin_url( 'setup.php' ) );
25                 exit;
26         }
27
28         if ( ! defined( 'MULTISITE' ) ) {
29                 wp_die( __( 'The Network creation panel is not for WordPress MU networks.' ) );
30         }
31 }
32
33 require_once( dirname( __FILE__ ) . '/includes/network.php' );
34
35 // We need to create references to ms global tables to enable Network.
36 foreach ( $wpdb->tables( 'ms_global' ) as $table => $prefixed_table ) {
37         $wpdb->$table = $prefixed_table;
38 }
39
40 if ( ! network_domain_check() && ( ! defined( 'WP_ALLOW_MULTISITE' ) || ! WP_ALLOW_MULTISITE ) ) {
41         wp_die(
42                 printf(
43                         /* translators: 1: WP_ALLOW_MULTISITE 2: wp-config.php */
44                         __( 'You must define the %1$s constant as true in your %2$s file to allow creation of a Network.' ),
45                         '<code>WP_ALLOW_MULTISITE</code>',
46                         '<code>wp-config.php</code>'
47                 )
48         );
49 }
50
51 if ( is_network_admin() ) {
52         $title = __( 'Network Setup' );
53         $parent_file = 'settings.php';
54 } else {
55         $title = __( 'Create a Network of WordPress Sites' );
56         $parent_file = 'tools.php';
57 }
58
59 $network_help = '<p>' . __('This screen allows you to configure a network as having subdomains (<code>site1.example.com</code>) or subdirectories (<code>example.com/site1</code>). Subdomains require wildcard subdomains to be enabled in Apache and DNS records, if your host allows it.') . '</p>' .
60         '<p>' . __('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).') . '</p>' .
61         '<p>' . __('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.') . '</p>' .
62         '<p>' . __('Add the designated lines of code to wp-config.php (just before <code>/*...stop editing...*/</code>) and <code>.htaccess</code> (replacing the existing WordPress rules).') . '</p>' .
63         '<p>' . __('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.') . '</p>' .
64         '<p>' . __('The choice of subdirectory sites is disabled if this setup is more than a month old because of permalink problems with &#8220;/blog/&#8221; from the main site. This disabling will be addressed in a future version.') . '</p>' .
65         '<p><strong>' . __('For more information:') . '</strong></p>' .
66         '<p>' . __('<a href="https://codex.wordpress.org/Create_A_Network" target="_blank">Documentation on Creating a Network</a>') . '</p>' .
67         '<p>' . __('<a href="https://codex.wordpress.org/Tools_Network_Screen" target="_blank">Documentation on the Network Screen</a>') . '</p>';
68
69 get_current_screen()->add_help_tab( array(
70         'id'      => 'network',
71         'title'   => __('Network'),
72         'content' => $network_help,
73 ) );
74
75 get_current_screen()->set_help_sidebar(
76         '<p><strong>' . __('For more information:') . '</strong></p>' .
77         '<p>' . __('<a href="https://codex.wordpress.org/Create_A_Network" target="_blank">Documentation on Creating a Network</a>') . '</p>' .
78         '<p>' . __('<a href="https://codex.wordpress.org/Tools_Network_Screen" target="_blank">Documentation on the Network Screen</a>') . '</p>' .
79         '<p>' . __('<a href="https://wordpress.org/support/" target="_blank">Support Forums</a>') . '</p>'
80 );
81
82 include( ABSPATH . 'wp-admin/admin-header.php' );
83 ?>
84 <div class="wrap">
85 <h1><?php echo esc_html( $title ); ?></h1>
86
87 <?php
88 if ( $_POST ) {
89
90         check_admin_referer( 'install-network-1' );
91
92         require_once( ABSPATH . 'wp-admin/includes/upgrade.php' );
93         // Create network tables.
94         install_network();
95         $base              = parse_url( trailingslashit( get_option( 'home' ) ), PHP_URL_PATH );
96         $subdomain_install = allow_subdomain_install() ? !empty( $_POST['subdomain_install'] ) : false;
97         if ( ! network_domain_check() ) {
98                 $result = populate_network( 1, get_clean_basedomain(), sanitize_email( $_POST['email'] ), wp_unslash( $_POST['sitename'] ), $base, $subdomain_install );
99                 if ( is_wp_error( $result ) ) {
100                         if ( 1 == count( $result->get_error_codes() ) && 'no_wildcard_dns' == $result->get_error_code() )
101                                 network_step2( $result );
102                         else
103                                 network_step1( $result );
104                 } else {
105                         network_step2();
106                 }
107         } else {
108                 network_step2();
109         }
110 } elseif ( is_multisite() || network_domain_check() ) {
111         network_step2();
112 } else {
113         network_step1();
114 }
115 ?>
116 </div>
117
118 <?php include( ABSPATH . 'wp-admin/admin-footer.php' ); ?>