wp/wp-admin/network.php
author ymh <ymh.work@gmail.com>
Thu, 29 Sep 2022 08:06:27 +0200
changeset 20 7b1b88e27a20
parent 19 3d72ae0968f4
child 21 48c4eec2b7e6
permissions -rw-r--r--
Modified Readme
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
     1
<?php
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
     2
/**
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
     3
 * Network installation administration panel.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
     4
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
     5
 * A multi-step process allowing the user to enable a network of WordPress sites.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
     6
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
     7
 * @since 3.0.0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
     8
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
     9
 * @package WordPress
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    10
 * @subpackage Administration
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    11
 */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    12
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    13
define( 'WP_INSTALLING_NETWORK', true );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    14
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    15
/** WordPress Administration Bootstrap */
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
    16
require_once __DIR__ . '/admin.php';
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    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
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    21
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    22
if ( is_multisite() ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    23
	if ( ! is_network_admin() ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    24
		wp_redirect( network_admin_url( 'setup.php' ) );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    25
		exit;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    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
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    29
		wp_die( __( 'The Network creation panel is not for WordPress MU networks.' ) );
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
    30
	}
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    31
}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    32
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
    33
require_once __DIR__ . '/includes/network.php';
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    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
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    38
}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    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(
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
    43
			/* translators: 1: WP_ALLOW_MULTISITE, 2: wp-config.php */
7
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
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    50
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    51
if ( is_network_admin() ) {
19
3d72ae0968f4 upgrade wordpress to 6.0.2
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
    52
	// Used in the HTML title tag.
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
    53
	$title       = __( 'Network Setup' );
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    54
	$parent_file = 'settings.php';
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    55
} else {
19
3d72ae0968f4 upgrade wordpress to 6.0.2
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
    56
	// Used in the HTML title tag.
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
    57
	$title       = __( 'Create a Network of WordPress Sites' );
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    58
	$parent_file = 'tools.php';
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    59
}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    60
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
    61
$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>' .
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
    62
	'<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>' .
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
    63
	'<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>' .
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
    64
	'<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>' .
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
    65
	'<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>' .
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
    66
	'<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>' .
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
    67
	'<p><strong>' . __( 'For more information:' ) . '</strong></p>' .
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
    68
	'<p>' . __( '<a href="https://wordpress.org/support/article/create-a-network/">Documentation on Creating a Network</a>' ) . '</p>' .
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
    69
	'<p>' . __( '<a href="https://wordpress.org/support/article/tools-network-screen/">Documentation on the Network Screen</a>' ) . '</p>';
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    70
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
    71
get_current_screen()->add_help_tab(
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
    72
	array(
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
    73
		'id'      => 'network',
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
    74
		'title'   => __( 'Network' ),
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
    75
		'content' => $network_help,
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
    76
	)
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
    77
);
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    78
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    79
get_current_screen()->set_help_sidebar(
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
    80
	'<p><strong>' . __( 'For more information:' ) . '</strong></p>' .
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
    81
	'<p>' . __( '<a href="https://wordpress.org/support/article/create-a-network/">Documentation on Creating a Network</a>' ) . '</p>' .
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
    82
	'<p>' . __( '<a href="https://wordpress.org/support/article/tools-network-screen/">Documentation on the Network Screen</a>' ) . '</p>' .
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
    83
	'<p>' . __( '<a href="https://wordpress.org/support/">Support</a>' ) . '</p>'
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    84
);
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    85
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
    86
require_once ABSPATH . 'wp-admin/admin-header.php';
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    87
?>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    88
<div class="wrap">
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
    89
<h1><?php echo esc_html( $title ); ?></h1>
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    90
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    91
<?php
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    92
if ( $_POST ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    93
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    94
	check_admin_referer( 'install-network-1' );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    95
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
    96
	require_once ABSPATH . 'wp-admin/includes/upgrade.php';
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
    97
	// Create network tables.
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    98
	install_network();
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    99
	$base              = parse_url( trailingslashit( get_option( 'home' ) ), PHP_URL_PATH );
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   100
	$subdomain_install = allow_subdomain_install() ? ! empty( $_POST['subdomain_install'] ) : false;
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   101
	if ( ! network_domain_check() ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   102
		$result = populate_network( 1, get_clean_basedomain(), sanitize_email( $_POST['email'] ), wp_unslash( $_POST['sitename'] ), $base, $subdomain_install );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   103
		if ( is_wp_error( $result ) ) {
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
   104
			if ( 1 === count( $result->get_error_codes() ) && 'no_wildcard_dns' === $result->get_error_code() ) {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   105
				network_step2( $result );
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   106
			} else {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   107
				network_step1( $result );
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   108
			}
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   109
		} else {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   110
			network_step2();
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   111
		}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   112
	} else {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   113
		network_step2();
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   114
	}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   115
} elseif ( is_multisite() || network_domain_check() ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   116
	network_step2();
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   117
} else {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   118
	network_step1();
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   119
}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   120
?>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   121
</div>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   122
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
   123
<?php require_once ABSPATH . 'wp-admin/admin-footer.php'; ?>