author | ymh <ymh.work@gmail.com> |
Tue, 22 Oct 2019 16:11:46 +0200 | |
changeset 15 | 3d4e9c994f10 |
parent 9 | 177826044cd9 |
child 16 | a86126ab1dd4 |
permissions | -rw-r--r-- |
0 | 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 |
||
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
18 |
if ( ! current_user_can( 'setup_network' ) ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
19 |
wp_die( __( 'Sorry, you are not allowed to manage options for this site.' ) ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
20 |
} |
0 | 21 |
|
22 |
if ( is_multisite() ) { |
|
23 |
if ( ! is_network_admin() ) { |
|
24 |
wp_redirect( network_admin_url( 'setup.php' ) ); |
|
25 |
exit; |
|
26 |
} |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
27 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
28 |
if ( ! defined( 'MULTISITE' ) ) { |
0 | 29 |
wp_die( __( 'The Network creation panel is not for WordPress MU networks.' ) ); |
5 | 30 |
} |
0 | 31 |
} |
32 |
||
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
33 |
require_once( dirname( __FILE__ ) . '/includes/network.php' ); |
0 | 34 |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
35 |
// We need to create references to ms global tables to enable Network. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
36 |
foreach ( $wpdb->tables( 'ms_global' ) as $table => $prefixed_table ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
37 |
$wpdb->$table = $prefixed_table; |
0 | 38 |
} |
39 |
||
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
40 |
if ( ! network_domain_check() && ( ! defined( 'WP_ALLOW_MULTISITE' ) || ! WP_ALLOW_MULTISITE ) ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
41 |
wp_die( |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
42 |
printf( |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
43 |
/* translators: 1: WP_ALLOW_MULTISITE 2: wp-config.php */ |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
44 |
__( 'You must define the %1$s constant as true in your %2$s file to allow creation of a Network.' ), |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
45 |
'<code>WP_ALLOW_MULTISITE</code>', |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
46 |
'<code>wp-config.php</code>' |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
47 |
) |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
48 |
); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
49 |
} |
0 | 50 |
|
51 |
if ( is_network_admin() ) { |
|
9 | 52 |
$title = __( 'Network Setup' ); |
0 | 53 |
$parent_file = 'settings.php'; |
54 |
} else { |
|
9 | 55 |
$title = __( 'Create a Network of WordPress Sites' ); |
0 | 56 |
$parent_file = 'tools.php'; |
57 |
} |
|
58 |
||
9 | 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 installation. 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 “/blog/” from the main site. This disabling will be addressed in a future version.' ) . '</p>' . |
|
65 |
'<p><strong>' . __( 'For more information:' ) . '</strong></p>' . |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
66 |
'<p>' . __( '<a href="https://codex.wordpress.org/Create_A_Network">Documentation on Creating a Network</a>' ) . '</p>' . |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
67 |
'<p>' . __( '<a href="https://codex.wordpress.org/Tools_Network_Screen">Documentation on the Network Screen</a>' ) . '</p>'; |
0 | 68 |
|
9 | 69 |
get_current_screen()->add_help_tab( |
70 |
array( |
|
71 |
'id' => 'network', |
|
72 |
'title' => __( 'Network' ), |
|
73 |
'content' => $network_help, |
|
74 |
) |
|
75 |
); |
|
0 | 76 |
|
77 |
get_current_screen()->set_help_sidebar( |
|
9 | 78 |
'<p><strong>' . __( 'For more information:' ) . '</strong></p>' . |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
79 |
'<p>' . __( '<a href="https://codex.wordpress.org/Create_A_Network">Documentation on Creating a Network</a>' ) . '</p>' . |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
80 |
'<p>' . __( '<a href="https://codex.wordpress.org/Tools_Network_Screen">Documentation on the Network Screen</a>' ) . '</p>' . |
9 | 81 |
'<p>' . __( '<a href="https://wordpress.org/support/">Support</a>' ) . '</p>' |
0 | 82 |
); |
83 |
||
84 |
include( ABSPATH . 'wp-admin/admin-header.php' ); |
|
85 |
?> |
|
86 |
<div class="wrap"> |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
87 |
<h1><?php echo esc_html( $title ); ?></h1> |
0 | 88 |
|
89 |
<?php |
|
90 |
if ( $_POST ) { |
|
91 |
||
92 |
check_admin_referer( 'install-network-1' ); |
|
93 |
||
94 |
require_once( ABSPATH . 'wp-admin/includes/upgrade.php' ); |
|
5 | 95 |
// Create network tables. |
0 | 96 |
install_network(); |
97 |
$base = parse_url( trailingslashit( get_option( 'home' ) ), PHP_URL_PATH ); |
|
9 | 98 |
$subdomain_install = allow_subdomain_install() ? ! empty( $_POST['subdomain_install'] ) : false; |
0 | 99 |
if ( ! network_domain_check() ) { |
100 |
$result = populate_network( 1, get_clean_basedomain(), sanitize_email( $_POST['email'] ), wp_unslash( $_POST['sitename'] ), $base, $subdomain_install ); |
|
101 |
if ( is_wp_error( $result ) ) { |
|
9 | 102 |
if ( 1 == count( $result->get_error_codes() ) && 'no_wildcard_dns' == $result->get_error_code() ) { |
0 | 103 |
network_step2( $result ); |
9 | 104 |
} else { |
0 | 105 |
network_step1( $result ); |
9 | 106 |
} |
0 | 107 |
} else { |
108 |
network_step2(); |
|
109 |
} |
|
110 |
} else { |
|
111 |
network_step2(); |
|
112 |
} |
|
113 |
} elseif ( is_multisite() || network_domain_check() ) { |
|
114 |
network_step2(); |
|
115 |
} else { |
|
116 |
network_step1(); |
|
117 |
} |
|
118 |
?> |
|
119 |
</div> |
|
120 |
||
121 |
<?php include( ABSPATH . 'wp-admin/admin-footer.php' ); ?> |