wp/wp-admin/network.php
author ymh <ymh.work@gmail.com>
Tue, 09 Jun 2015 11:14:17 +0000
changeset 6 490d5cc509ed
parent 5 5e2f62d02dcd
child 7 cf61fcea0001
permissions -rw-r--r--
update portfolio
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 */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    16
require_once( dirname( __FILE__ ) . '/admin.php' );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    17
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    18
if ( ! is_super_admin() )
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    19
	wp_die( __( 'You do not have sufficient permissions to manage options for this site.' ) );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    20
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    21
if ( is_multisite() ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    22
	if ( ! is_network_admin() ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    23
		wp_redirect( network_admin_url( 'setup.php' ) );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    24
		exit;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    25
	}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    26
	if ( ! defined( 'MULTISITE' ) )
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    27
		wp_die( __( 'The Network creation panel is not for WordPress MU networks.' ) );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    28
}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    29
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    30
// We need to create references to ms global tables to enable Network.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    31
foreach ( $wpdb->tables( 'ms_global' ) as $table => $prefixed_table )
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    32
	$wpdb->$table = $prefixed_table;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    33
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    34
/**
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    35
 * Check for an existing network.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    36
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    37
 * @since 3.0.0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    38
 * @return Whether a network exists.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    39
 */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    40
function network_domain_check() {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    41
	global $wpdb;
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
    42
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
    43
	$sql = $wpdb->prepare( "SHOW TABLES LIKE %s", $wpdb->esc_like( $wpdb->site ) );
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
    44
	if ( $wpdb->get_var( $sql ) ) {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    45
		return $wpdb->get_var( "SELECT domain FROM $wpdb->site ORDER BY id ASC LIMIT 1" );
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
    46
	}
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    47
	return false;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    48
}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    49
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    50
/**
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    51
 * Allow subdomain install
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    52
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    53
 * @since 3.0.0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    54
 * @return bool Whether subdomain install is allowed
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    55
 */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    56
function allow_subdomain_install() {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    57
	$domain = preg_replace( '|https?://([^/]+)|', '$1', get_option( 'home' ) );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    58
	if( parse_url( get_option( 'home' ), PHP_URL_PATH ) || 'localhost' == $domain || preg_match( '|^[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+$|', $domain ) )
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    59
		return false;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    60
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    61
	return true;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    62
}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    63
/**
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    64
 * Allow subdirectory install.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    65
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    66
 * @since 3.0.0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    67
 * @return bool Whether subdirectory install is allowed
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    68
 */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    69
function allow_subdirectory_install() {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    70
	global $wpdb;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    71
        /**
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    72
         * Filter whether to enable the subdirectory install feature in Multisite.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    73
         *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    74
         * @since 3.0.0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    75
         *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    76
         * @param bool true Whether to enable the subdirectory install feature in Multisite. Default is false.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    77
         */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    78
	if ( apply_filters( 'allow_subdirectory_install', false ) )
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    79
		return true;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    80
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    81
	if ( defined( 'ALLOW_SUBDIRECTORY_INSTALL' ) && ALLOW_SUBDIRECTORY_INSTALL )
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    82
		return true;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    83
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    84
	$post = $wpdb->get_row( "SELECT ID FROM $wpdb->posts WHERE post_date < DATE_SUB(NOW(), INTERVAL 1 MONTH) AND post_status = 'publish'" );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    85
	if ( empty( $post ) )
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    86
		return true;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    87
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    88
	return false;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    89
}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    90
/**
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    91
 * Get base domain of network.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    92
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    93
 * @since 3.0.0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    94
 * @return string Base domain.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    95
 */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    96
function get_clean_basedomain() {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    97
	if ( $existing_domain = network_domain_check() )
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    98
		return $existing_domain;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    99
	$domain = preg_replace( '|https?://|', '', get_option( 'siteurl' ) );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   100
	if ( $slash = strpos( $domain, '/' ) )
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   101
		$domain = substr( $domain, 0, $slash );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   102
	return $domain;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   103
}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   104
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   105
if ( ! network_domain_check() && ( ! defined( 'WP_ALLOW_MULTISITE' ) || ! WP_ALLOW_MULTISITE ) )
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   106
	wp_die( __( 'You must define the <code>WP_ALLOW_MULTISITE</code> constant as true in your wp-config.php file to allow creation of a Network.' ) );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   107
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   108
if ( is_network_admin() ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   109
	$title = __( 'Network Setup' );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   110
	$parent_file = 'settings.php';
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   111
} else {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   112
	$title = __( 'Create a Network of WordPress Sites' );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   113
	$parent_file = 'tools.php';
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   114
}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   115
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   116
$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>' .
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   117
	'<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>' .
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   118
	'<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>' .
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   119
	'<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>' .
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   120
	'<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>' .
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   121
	'<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>' .
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   122
	'<p><strong>' . __('For more information:') . '</strong></p>' .
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   123
	'<p>' . __('<a href="https://codex.wordpress.org/Create_A_Network" target="_blank">Documentation on Creating a Network</a>') . '</p>' .
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   124
	'<p>' . __('<a href="https://codex.wordpress.org/Tools_Network_Screen" target="_blank">Documentation on the Network Screen</a>') . '</p>';
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   125
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   126
get_current_screen()->add_help_tab( array(
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   127
	'id'      => 'network',
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   128
	'title'   => __('Network'),
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   129
	'content' => $network_help,
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   130
) );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   131
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   132
get_current_screen()->set_help_sidebar(
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   133
	'<p><strong>' . __('For more information:') . '</strong></p>' .
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   134
	'<p>' . __('<a href="https://codex.wordpress.org/Create_A_Network" target="_blank">Documentation on Creating a Network</a>') . '</p>' .
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   135
	'<p>' . __('<a href="https://codex.wordpress.org/Tools_Network_Screen" target="_blank">Documentation on the Network Screen</a>') . '</p>' .
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   136
	'<p>' . __('<a href="https://wordpress.org/support/" target="_blank">Support Forums</a>') . '</p>'
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   137
);
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   138
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   139
include( ABSPATH . 'wp-admin/admin-header.php' );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   140
?>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   141
<div class="wrap">
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   142
<h2><?php echo esc_html( $title ); ?></h2>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   143
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   144
<?php
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   145
/**
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   146
 * Prints step 1 for Network installation process.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   147
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   148
 * @todo Realistically, step 1 should be a welcome screen explaining what a Network is and such. Navigating to Tools > Network
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   149
 * 	should not be a sudden "Welcome to a new install process! Fill this out and click here." See also contextual help todo.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   150
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   151
 * @since 3.0.0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   152
 */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   153
function network_step1( $errors = false ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   154
	global $is_apache;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   155
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   156
	if ( defined('DO_NOT_UPGRADE_GLOBAL_TABLES') ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   157
		echo '<div class="error"><p><strong>' . __('ERROR:') . '</strong> ' . __( 'The constant DO_NOT_UPGRADE_GLOBAL_TABLES cannot be defined when creating a network.' ) . '</p></div>';
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   158
		echo '</div>';
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   159
		include( ABSPATH . 'wp-admin/admin-footer.php' );
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   160
		die();
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   161
	}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   162
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   163
	$active_plugins = get_option( 'active_plugins' );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   164
	if ( ! empty( $active_plugins ) ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   165
		echo '<div class="updated"><p><strong>' . __('Warning:') . '</strong> ' . sprintf( __( 'Please <a href="%s">deactivate your plugins</a> before enabling the Network feature.' ), admin_url( 'plugins.php?plugin_status=active' ) ) . '</p></div><p>' . __( 'Once the network is created, you may reactivate your plugins.' ) . '</p>';
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   166
		echo '</div>';
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   167
		include( ABSPATH . 'wp-admin/admin-footer.php' );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   168
		die();
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   169
	}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   170
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   171
	$hostname = get_clean_basedomain();
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   172
	$has_ports = strstr( $hostname, ':' );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   173
	if ( ( false !== $has_ports && ! in_array( $has_ports, array( ':80', ':443' ) ) ) ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   174
		echo '<div class="error"><p><strong>' . __( 'ERROR:') . '</strong> ' . __( 'You cannot install a network of sites with your server address.' ) . '</p></div>';
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   175
		echo '<p>' . sprintf( __( 'You cannot use port numbers such as <code>%s</code>.' ), $has_ports ) . '</p>';
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   176
		echo '<a href="' . esc_url( admin_url() ) . '">' . __( 'Return to Dashboard' ) . '</a>';
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   177
		echo '</div>';
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   178
		include( ABSPATH . 'wp-admin/admin-footer.php' );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   179
		die();
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   180
	}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   181
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   182
	echo '<form method="post">';
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   183
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   184
	wp_nonce_field( 'install-network-1' );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   185
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   186
	$error_codes = array();
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   187
	if ( is_wp_error( $errors ) ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   188
		echo '<div class="error"><p><strong>' . __( 'ERROR: The network could not be created.' ) . '</strong></p>';
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   189
		foreach ( $errors->get_error_messages() as $error )
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   190
			echo "<p>$error</p>";
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   191
		echo '</div>';
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   192
		$error_codes = $errors->get_error_codes();
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   193
	}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   194
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   195
	$site_name = ( ! empty( $_POST['sitename'] ) && ! in_array( 'empty_sitename', $error_codes ) ) ? $_POST['sitename'] : sprintf( _x('%s Sites', 'Default network name' ), get_option( 'blogname' ) );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   196
	$admin_email = ( ! empty( $_POST['email'] ) && ! in_array( 'invalid_email', $error_codes ) ) ? $_POST['email'] : get_option( 'admin_email' );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   197
	?>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   198
	<p><?php _e( 'Welcome to the Network installation process!' ); ?></p>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   199
	<p><?php _e( 'Fill in the information below and you&#8217;ll be on your way to creating a network of WordPress sites. We will create configuration files in the next step.' ); ?></p>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   200
	<?php
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   201
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   202
	if ( isset( $_POST['subdomain_install'] ) ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   203
		$subdomain_install = (bool) $_POST['subdomain_install'];
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   204
	} elseif ( apache_mod_loaded('mod_rewrite') ) { // assume nothing
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   205
		$subdomain_install = true;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   206
	} elseif ( !allow_subdirectory_install() ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   207
		$subdomain_install = true;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   208
	} else {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   209
		$subdomain_install = false;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   210
		if ( $got_mod_rewrite = got_mod_rewrite() ) // dangerous assumptions
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   211
			echo '<div class="updated inline"><p><strong>' . __( 'Note:' ) . '</strong> ' . __( 'Please make sure the Apache <code>mod_rewrite</code> module is installed as it will be used at the end of this installation.' ) . '</p>';
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   212
		elseif ( $is_apache )
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   213
			echo '<div class="error inline"><p><strong>' . __( 'Warning!' ) . '</strong> ' . __( 'It looks like the Apache <code>mod_rewrite</code> module is not installed.' ) . '</p>';
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   214
		if ( $got_mod_rewrite || $is_apache ) // Protect against mod_rewrite mimicry (but ! Apache)
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   215
			echo '<p>' . __( 'If <code>mod_rewrite</code> is disabled, ask your administrator to enable that module, or look at the <a href="http://httpd.apache.org/docs/mod/mod_rewrite.html">Apache documentation</a> or <a href="http://www.google.com/search?q=apache+mod_rewrite">elsewhere</a> for help setting it up.' ) . '</p></div>';
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   216
	}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   217
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   218
	if ( allow_subdomain_install() && allow_subdirectory_install() ) : ?>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   219
		<h3><?php esc_html_e( 'Addresses of Sites in your Network' ); ?></h3>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   220
		<p><?php _e( 'Please choose whether you would like sites in your WordPress network to use sub-domains or sub-directories. <strong>You cannot change this later.</strong>' ); ?></p>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   221
		<p><?php _e( 'You will need a wildcard DNS record if you are going to use the virtual host (sub-domain) functionality.' ); ?></p>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   222
		<?php // @todo: Link to an MS readme? ?>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   223
		<table class="form-table">
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   224
			<tr>
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   225
				<th><label><input type="radio" name="subdomain_install" value="1"<?php checked( $subdomain_install ); ?> /> <?php _e( 'Sub-domains' ); ?></label></th>
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   226
				<td><?php printf(
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   227
					/* translators: 1: hostname */
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   228
					_x( 'like <code>site1.%1$s</code> and <code>site2.%1$s</code>', 'subdomain examples' ),
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   229
					$hostname
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   230
				); ?></td>
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   231
			</tr>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   232
			<tr>
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   233
				<th><label><input type="radio" name="subdomain_install" value="0"<?php checked( ! $subdomain_install ); ?> /> <?php _e( 'Sub-directories' ); ?></label></th>
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   234
				<td><?php printf(
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   235
					/* translators: 1: hostname */
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   236
					_x( 'like <code>%1$s/site1</code> and <code>%1$s/site2</code>', 'subdirectory examples' ),
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   237
					$hostname
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   238
				); ?></td>
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   239
			</tr>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   240
		</table>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   241
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   242
<?php
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   243
	endif;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   244
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   245
		if ( WP_CONTENT_DIR != ABSPATH . 'wp-content' && ( allow_subdirectory_install() || ! allow_subdomain_install() ) )
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   246
			echo '<div class="error inline"><p><strong>' . __('Warning!') . '</strong> ' . __( 'Subdirectory networks may not be fully compatible with custom wp-content directories.' ) . '</p></div>';
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   247
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   248
		$is_www = ( 0 === strpos( $hostname, 'www.' ) );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   249
		if ( $is_www ) :
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   250
		?>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   251
		<h3><?php esc_html_e( 'Server Address' ); ?></h3>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   252
		<p><?php printf( __( 'We recommend you change your siteurl to <code>%1$s</code> before enabling the network feature. It will still be possible to visit your site using the <code>www</code> prefix with an address like <code>%2$s</code> but any links will not have the <code>www</code> prefix.' ), substr( $hostname, 4 ), $hostname ); ?></p>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   253
		<table class="form-table">
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   254
			<tr>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   255
				<th scope='row'><?php esc_html_e( 'Server Address' ); ?></th>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   256
				<td>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   257
					<?php printf( __( 'The internet address of your network will be <code>%s</code>.' ), $hostname ); ?>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   258
				</td>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   259
			</tr>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   260
		</table>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   261
		<?php endif; ?>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   262
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   263
		<h3><?php esc_html_e( 'Network Details' ); ?></h3>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   264
		<table class="form-table">
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   265
		<?php if ( 'localhost' == $hostname ) : ?>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   266
			<tr>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   267
				<th scope="row"><?php esc_html_e( 'Sub-directory Install' ); ?></th>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   268
				<td><?php
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   269
					_e( 'Because you are using <code>localhost</code>, the sites in your WordPress network must use sub-directories. Consider using <code>localhost.localdomain</code> if you wish to use sub-domains.' );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   270
					// Uh oh:
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   271
					if ( !allow_subdirectory_install() )
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   272
						echo ' <strong>' . __( 'Warning!' ) . ' ' . __( 'The main site in a sub-directory install will need to use a modified permalink structure, potentially breaking existing links.' ) . '</strong>';
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   273
				?></td>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   274
			</tr>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   275
		<?php elseif ( !allow_subdomain_install() ) : ?>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   276
			<tr>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   277
				<th scope="row"><?php esc_html_e( 'Sub-directory Install' ); ?></th>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   278
				<td><?php
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   279
					_e( 'Because your install is in a directory, the sites in your WordPress network must use sub-directories.' );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   280
					// Uh oh:
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   281
					if ( !allow_subdirectory_install() )
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   282
						echo ' <strong>' . __( 'Warning!' ) . ' ' . __( 'The main site in a sub-directory install will need to use a modified permalink structure, potentially breaking existing links.' ) . '</strong>';
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   283
				?></td>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   284
			</tr>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   285
		<?php elseif ( !allow_subdirectory_install() ) : ?>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   286
			<tr>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   287
				<th scope="row"><?php esc_html_e( 'Sub-domain Install' ); ?></th>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   288
				<td><?php _e( 'Because your install is not new, the sites in your WordPress network must use sub-domains.' );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   289
					echo ' <strong>' . __( 'The main site in a sub-directory install will need to use a modified permalink structure, potentially breaking existing links.' ) . '</strong>';
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   290
				?></td>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   291
			</tr>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   292
		<?php endif; ?>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   293
		<?php if ( ! $is_www ) : ?>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   294
			<tr>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   295
				<th scope='row'><?php esc_html_e( 'Server Address' ); ?></th>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   296
				<td>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   297
					<?php printf( __( 'The internet address of your network will be <code>%s</code>.' ), $hostname ); ?>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   298
				</td>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   299
			</tr>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   300
		<?php endif; ?>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   301
			<tr>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   302
				<th scope='row'><?php esc_html_e( 'Network Title' ); ?></th>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   303
				<td>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   304
					<input name='sitename' type='text' size='45' value='<?php echo esc_attr( $site_name ); ?>' />
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   305
					<p class="description">
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   306
						<?php _e( 'What would you like to call your network?' ); ?>
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   307
					</p>
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   308
				</td>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   309
			</tr>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   310
			<tr>
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   311
				<th scope='row'><?php esc_html_e( 'Network Admin Email' ); ?></th>
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   312
				<td>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   313
					<input name='email' type='text' size='45' value='<?php echo esc_attr( $admin_email ); ?>' />
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   314
					<p class="description">
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   315
						<?php _e( 'Your email address.' ); ?>
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   316
					</p>
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   317
				</td>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   318
			</tr>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   319
		</table>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   320
		<?php submit_button( __( 'Install' ), 'primary', 'submit' ); ?>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   321
	</form>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   322
	<?php
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   323
}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   324
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   325
/**
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   326
 * Prints step 2 for Network installation process.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   327
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   328
 * @since 3.0.0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   329
 */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   330
function network_step2( $errors = false ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   331
	global $wpdb;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   332
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   333
	$hostname          = get_clean_basedomain();
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   334
	$slashed_home      = trailingslashit( get_option( 'home' ) );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   335
	$base              = parse_url( $slashed_home, PHP_URL_PATH );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   336
	$document_root_fix = str_replace( '\\', '/', realpath( $_SERVER['DOCUMENT_ROOT'] ) );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   337
	$abspath_fix       = str_replace( '\\', '/', ABSPATH );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   338
	$home_path         = 0 === strpos( $abspath_fix, $document_root_fix ) ? $document_root_fix . $base : get_home_path();
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   339
	$wp_siteurl_subdir = preg_replace( '#^' . preg_quote( $home_path, '#' ) . '#', '', $abspath_fix );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   340
	$rewrite_base      = ! empty( $wp_siteurl_subdir ) ? ltrim( trailingslashit( $wp_siteurl_subdir ), '/' ) : '';
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   341
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   342
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   343
	$location_of_wp_config = $abspath_fix;
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   344
	if ( ! file_exists( ABSPATH . 'wp-config.php' ) && file_exists( dirname( ABSPATH ) . '/wp-config.php' ) ) {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   345
		$location_of_wp_config = dirname( $abspath_fix );
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   346
	}
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   347
	$location_of_wp_config = trailingslashit( $location_of_wp_config );
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   348
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   349
	// Wildcard DNS message.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   350
	if ( is_wp_error( $errors ) )
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   351
		echo '<div class="error">' . $errors->get_error_message() . '</div>';
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   352
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   353
	if ( $_POST ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   354
		if ( allow_subdomain_install() )
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   355
			$subdomain_install = allow_subdirectory_install() ? ! empty( $_POST['subdomain_install'] ) : true;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   356
		else
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   357
			$subdomain_install = false;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   358
	} else {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   359
		if ( is_multisite() ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   360
			$subdomain_install = is_subdomain_install();
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   361
?>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   362
	<p><?php _e( 'The original configuration steps are shown here for reference.' ); ?></p>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   363
<?php
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   364
		} else {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   365
			$subdomain_install = (bool) $wpdb->get_var( "SELECT meta_value FROM $wpdb->sitemeta WHERE site_id = 1 AND meta_key = 'subdomain_install'" );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   366
?>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   367
	<div class="error"><p><strong><?php _e('Warning:'); ?></strong> <?php _e( 'An existing WordPress network was detected.' ); ?></p></div>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   368
	<p><?php _e( 'Please complete the configuration steps. To create a new network, you will need to empty or remove the network database tables.' ); ?></p>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   369
<?php
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   370
		}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   371
	}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   372
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   373
	$subdir_match          = $subdomain_install ? '' : '([_0-9a-zA-Z-]+/)?';
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   374
	$subdir_replacement_01 = $subdomain_install ? '' : '$1';
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   375
	$subdir_replacement_12 = $subdomain_install ? '$1' : '$2';
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   376
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   377
	if ( $_POST || ! is_multisite() ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   378
?>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   379
		<h3><?php esc_html_e( 'Enabling the Network' ); ?></h3>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   380
		<p><?php _e( 'Complete the following steps to enable the features for creating a network of sites.' ); ?></p>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   381
		<div class="updated inline"><p><?php
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   382
			if ( file_exists( $home_path . '.htaccess' ) )
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   383
				printf( __( '<strong>Caution:</strong> We recommend you back up your existing <code>wp-config.php</code> and <code>%s</code> files.' ), '.htaccess' );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   384
			elseif ( file_exists( $home_path . 'web.config' ) )
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   385
				printf( __( '<strong>Caution:</strong> We recommend you back up your existing <code>wp-config.php</code> and <code>%s</code> files.' ), 'web.config' );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   386
			else
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   387
				_e( '<strong>Caution:</strong> We recommend you back up your existing <code>wp-config.php</code> file.' );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   388
		?></p></div>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   389
<?php
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   390
	}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   391
?>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   392
		<ol>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   393
			<li><p><?php printf( __( 'Add the following to your <code>wp-config.php</code> file in <code>%s</code> <strong>above</strong> the line reading <code>/* That&#8217;s all, stop editing! Happy blogging. */</code>:' ), $location_of_wp_config ); ?></p>
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   394
				<textarea class="code" readonly="readonly" cols="100" rows="7">
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   395
define('MULTISITE', true);
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   396
define('SUBDOMAIN_INSTALL', <?php echo $subdomain_install ? 'true' : 'false'; ?>);
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   397
define('DOMAIN_CURRENT_SITE', '<?php echo $hostname; ?>');
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   398
define('PATH_CURRENT_SITE', '<?php echo $base; ?>');
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   399
define('SITE_ID_CURRENT_SITE', 1);
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   400
define('BLOG_ID_CURRENT_SITE', 1);
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   401
</textarea>
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   402
<?php
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   403
	$keys_salts = array( 'AUTH_KEY' => '', 'SECURE_AUTH_KEY' => '', 'LOGGED_IN_KEY' => '', 'NONCE_KEY' => '', 'AUTH_SALT' => '', 'SECURE_AUTH_SALT' => '', 'LOGGED_IN_SALT' => '', 'NONCE_SALT' => '' );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   404
	foreach ( $keys_salts as $c => $v ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   405
		if ( defined( $c ) )
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   406
			unset( $keys_salts[ $c ] );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   407
	}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   408
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   409
	if ( ! empty( $keys_salts ) ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   410
		$keys_salts_str = '';
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   411
		$from_api = wp_remote_get( 'https://api.wordpress.org/secret-key/1.1/salt/' );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   412
		if ( is_wp_error( $from_api ) ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   413
			foreach ( $keys_salts as $c => $v ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   414
				$keys_salts_str .= "\ndefine( '$c', '" . wp_generate_password( 64, true, true ) . "' );";
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   415
			}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   416
		} else {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   417
			$from_api = explode( "\n", wp_remote_retrieve_body( $from_api ) );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   418
			foreach ( $keys_salts as $c => $v ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   419
				$keys_salts_str .= "\ndefine( '$c', '" . substr( array_shift( $from_api ), 28, 64 ) . "' );";
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   420
			}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   421
		}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   422
		$num_keys_salts = count( $keys_salts );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   423
?>
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   424
	<p>
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   425
		<?php
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   426
			if ( 1 == $num_keys_salts ) {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   427
				_e( 'This unique authentication key is also missing from your <code>wp-config.php</code> file.' );
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   428
			} else {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   429
				_e( 'These unique authentication keys are also missing from your <code>wp-config.php</code> file.' );
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   430
			}
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   431
		?>
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   432
		<?php _e( 'To make your installation more secure, you should also add:' ); ?>
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   433
	</p>
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   434
	<textarea class="code" readonly="readonly" cols="100" rows="<?php echo $num_keys_salts; ?>"><?php echo esc_textarea( $keys_salts_str ); ?></textarea>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   435
<?php
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   436
	}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   437
?>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   438
</li>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   439
<?php
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   440
	if ( iis7_supports_permalinks() ) :
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   441
		// IIS doesn't support RewriteBase, all your RewriteBase are belong to us
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   442
		$iis_subdir_match = ltrim( $base, '/' ) . $subdir_match;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   443
		$iis_rewrite_base = ltrim( $base, '/' ) . $rewrite_base;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   444
		$iis_subdir_replacement = $subdomain_install ? '' : '{R:1}';
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   445
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   446
		$web_config_file = '<?xml version="1.0" encoding="UTF-8"?>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   447
<configuration>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   448
    <system.webServer>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   449
        <rewrite>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   450
            <rules>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   451
                <rule name="WordPress Rule 1" stopProcessing="true">
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   452
                    <match url="^index\.php$" ignoreCase="false" />
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   453
                    <action type="None" />
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   454
                </rule>';
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   455
				if ( is_multisite() && get_site_option( 'ms_files_rewriting' ) ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   456
					$web_config_file .= '
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   457
                <rule name="WordPress Rule for Files" stopProcessing="true">
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   458
                    <match url="^' . $iis_subdir_match . 'files/(.+)" ignoreCase="false" />
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   459
                    <action type="Rewrite" url="' . $iis_rewrite_base . WPINC . '/ms-files.php?file={R:1}" appendQueryString="false" />
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   460
                </rule>';
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   461
                }
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   462
                $web_config_file .= '
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   463
                <rule name="WordPress Rule 2" stopProcessing="true">
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   464
                    <match url="^' . $iis_subdir_match . 'wp-admin$" ignoreCase="false" />
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   465
                    <action type="Redirect" url="' . $iis_subdir_replacement . 'wp-admin/" redirectType="Permanent" />
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   466
                </rule>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   467
                <rule name="WordPress Rule 3" stopProcessing="true">
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   468
                    <match url="^" ignoreCase="false" />
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   469
                    <conditions logicalGrouping="MatchAny">
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   470
                        <add input="{REQUEST_FILENAME}" matchType="IsFile" ignoreCase="false" />
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   471
                        <add input="{REQUEST_FILENAME}" matchType="IsDirectory" ignoreCase="false" />
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   472
                    </conditions>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   473
                    <action type="None" />
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   474
                </rule>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   475
                <rule name="WordPress Rule 4" stopProcessing="true">
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   476
                    <match url="^' . $iis_subdir_match . '(wp-(content|admin|includes).*)" ignoreCase="false" />
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   477
                    <action type="Rewrite" url="' . $iis_rewrite_base . '{R:1}" />
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   478
                </rule>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   479
                <rule name="WordPress Rule 5" stopProcessing="true">
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   480
                    <match url="^' . $iis_subdir_match . '([_0-9a-zA-Z-]+/)?(.*\.php)$" ignoreCase="false" />
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   481
                    <action type="Rewrite" url="' . $iis_rewrite_base . '{R:2}" />
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   482
                </rule>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   483
                <rule name="WordPress Rule 6" stopProcessing="true">
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   484
                    <match url="." ignoreCase="false" />
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   485
                    <action type="Rewrite" url="index.php" />
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   486
                </rule>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   487
            </rules>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   488
        </rewrite>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   489
    </system.webServer>
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   490
</configuration>
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   491
';
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   492
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   493
		echo '<li><p>';
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   494
		/* translators: 1: a filename like .htaccess. 2: a file path. */
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   495
		printf( __( 'Add the following to your %1$s file in %2$s, <strong>replacing</strong> other WordPress rules:' ),
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   496
			'<code>web.config</code>', '<code>' . $home_path . '</code>' );
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   497
		echo '</p>';
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   498
		if ( ! $subdomain_install && WP_CONTENT_DIR != ABSPATH . 'wp-content' )
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   499
			echo '<p><strong>' . __('Warning:') . ' ' . __( 'Subdirectory networks may not be fully compatible with custom wp-content directories.' ) . '</strong></p>';
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   500
		?>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   501
		<textarea class="code" readonly="readonly" cols="100" rows="20"><?php echo esc_textarea( $web_config_file ); ?>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   502
		</textarea></li>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   503
		</ol>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   504
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   505
	<?php else : // end iis7_supports_permalinks(). construct an htaccess file instead:
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   506
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   507
		$ms_files_rewriting = '';
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   508
		if ( is_multisite() && get_site_option( 'ms_files_rewriting' ) ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   509
			$ms_files_rewriting = "\n# uploaded files\nRewriteRule ^";
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   510
			$ms_files_rewriting .= $subdir_match . "files/(.+) {$rewrite_base}" . WPINC . "/ms-files.php?file={$subdir_replacement_12} [L]" . "\n";
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   511
		}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   512
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   513
		$htaccess_file = <<<EOF
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   514
RewriteEngine On
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   515
RewriteBase {$base}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   516
RewriteRule ^index\.php$ - [L]
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   517
{$ms_files_rewriting}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   518
# add a trailing slash to /wp-admin
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   519
RewriteRule ^{$subdir_match}wp-admin$ {$subdir_replacement_01}wp-admin/ [R=301,L]
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   520
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   521
RewriteCond %{REQUEST_FILENAME} -f [OR]
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   522
RewriteCond %{REQUEST_FILENAME} -d
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   523
RewriteRule ^ - [L]
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   524
RewriteRule ^{$subdir_match}(wp-(content|admin|includes).*) {$rewrite_base}{$subdir_replacement_12} [L]
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   525
RewriteRule ^{$subdir_match}(.*\.php)$ {$rewrite_base}$subdir_replacement_12 [L]
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   526
RewriteRule . index.php [L]
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   527
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   528
EOF;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   529
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   530
		echo '<li><p>';
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   531
		/* translators: 1: a filename like .htaccess. 2: a file path. */
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   532
		printf( __( 'Add the following to your %1$s file in %2$s, <strong>replacing</strong> other WordPress rules:' ),
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   533
			'<code>.htaccess</code>', '<code>' . $home_path . '</code>' );
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   534
		echo '</p>';
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   535
		if ( ! $subdomain_install && WP_CONTENT_DIR != ABSPATH . 'wp-content' )
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   536
			echo '<p><strong>' . __('Warning:') . ' ' . __( 'Subdirectory networks may not be fully compatible with custom wp-content directories.' ) . '</strong></p>';
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   537
		?>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   538
		<textarea class="code" readonly="readonly" cols="100" rows="<?php echo substr_count( $htaccess_file, "\n" ) + 1; ?>">
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   539
<?php echo esc_textarea( $htaccess_file ); ?></textarea></li>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   540
		</ol>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   541
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   542
	<?php endif; // end IIS/Apache code branches.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   543
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   544
	if ( !is_multisite() ) { ?>
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   545
		<p><?php _e( 'Once you complete these steps, your network is enabled and configured. You will have to log in again.' ); ?> <a href="<?php echo esc_url( site_url( 'wp-login.php' ) ); ?>"><?php _e( 'Log In' ); ?></a></p>
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   546
<?php
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   547
	}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   548
}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   549
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   550
if ( $_POST ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   551
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   552
	check_admin_referer( 'install-network-1' );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   553
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   554
	require_once( ABSPATH . 'wp-admin/includes/upgrade.php' );
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   555
	// Create network tables.
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   556
	install_network();
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   557
	$base              = parse_url( trailingslashit( get_option( 'home' ) ), PHP_URL_PATH );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   558
	$subdomain_install = allow_subdomain_install() ? !empty( $_POST['subdomain_install'] ) : false;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   559
	if ( ! network_domain_check() ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   560
		$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
   561
		if ( is_wp_error( $result ) ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   562
			if ( 1 == count( $result->get_error_codes() ) && 'no_wildcard_dns' == $result->get_error_code() )
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   563
				network_step2( $result );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   564
			else
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   565
				network_step1( $result );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   566
		} else {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   567
			network_step2();
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   568
		}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   569
	} else {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   570
		network_step2();
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   571
	}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   572
} elseif ( is_multisite() || network_domain_check() ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   573
	network_step2();
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   574
} else {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   575
	network_step1();
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   576
}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   577
?>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   578
</div>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   579
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   580
<?php include( ABSPATH . 'wp-admin/admin-footer.php' ); ?>