Edit File by line
/home/zeestwma/richards.../wp-admin.../includes
File: network.php
<?php
[0] Fix | Delete
/**
[1] Fix | Delete
* WordPress Network Administration API.
[2] Fix | Delete
*
[3] Fix | Delete
* @package WordPress
[4] Fix | Delete
* @subpackage Administration
[5] Fix | Delete
* @since 4.4.0
[6] Fix | Delete
*/
[7] Fix | Delete
[8] Fix | Delete
/**
[9] Fix | Delete
* Check for an existing network.
[10] Fix | Delete
*
[11] Fix | Delete
* @since 3.0.0
[12] Fix | Delete
*
[13] Fix | Delete
* @global wpdb $wpdb WordPress database abstraction object.
[14] Fix | Delete
*
[15] Fix | Delete
* @return string|false Base domain if network exists, otherwise false.
[16] Fix | Delete
*/
[17] Fix | Delete
function network_domain_check() {
[18] Fix | Delete
global $wpdb;
[19] Fix | Delete
[20] Fix | Delete
$sql = $wpdb->prepare( 'SHOW TABLES LIKE %s', $wpdb->esc_like( $wpdb->site ) );
[21] Fix | Delete
if ( $wpdb->get_var( $sql ) ) {
[22] Fix | Delete
return $wpdb->get_var( "SELECT domain FROM $wpdb->site ORDER BY id ASC LIMIT 1" );
[23] Fix | Delete
}
[24] Fix | Delete
return false;
[25] Fix | Delete
}
[26] Fix | Delete
[27] Fix | Delete
/**
[28] Fix | Delete
* Allow subdomain installation
[29] Fix | Delete
*
[30] Fix | Delete
* @since 3.0.0
[31] Fix | Delete
* @return bool Whether subdomain installation is allowed
[32] Fix | Delete
*/
[33] Fix | Delete
function allow_subdomain_install() {
[34] Fix | Delete
$home = get_option( 'home' );
[35] Fix | Delete
$domain = parse_url( $home, PHP_URL_HOST );
[36] Fix | Delete
if ( parse_url( $home, PHP_URL_PATH ) || 'localhost' === $domain || preg_match( '|^[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+$|', $domain ) ) {
[37] Fix | Delete
return false;
[38] Fix | Delete
}
[39] Fix | Delete
[40] Fix | Delete
return true;
[41] Fix | Delete
}
[42] Fix | Delete
[43] Fix | Delete
/**
[44] Fix | Delete
* Allow subdirectory installation.
[45] Fix | Delete
*
[46] Fix | Delete
* @since 3.0.0
[47] Fix | Delete
*
[48] Fix | Delete
* @global wpdb $wpdb WordPress database abstraction object.
[49] Fix | Delete
*
[50] Fix | Delete
* @return bool Whether subdirectory installation is allowed
[51] Fix | Delete
*/
[52] Fix | Delete
function allow_subdirectory_install() {
[53] Fix | Delete
global $wpdb;
[54] Fix | Delete
[55] Fix | Delete
/**
[56] Fix | Delete
* Filters whether to enable the subdirectory installation feature in Multisite.
[57] Fix | Delete
*
[58] Fix | Delete
* @since 3.0.0
[59] Fix | Delete
*
[60] Fix | Delete
* @param bool $allow Whether to enable the subdirectory installation feature in Multisite.
[61] Fix | Delete
* Default false.
[62] Fix | Delete
*/
[63] Fix | Delete
if ( apply_filters( 'allow_subdirectory_install', false ) ) {
[64] Fix | Delete
return true;
[65] Fix | Delete
}
[66] Fix | Delete
[67] Fix | Delete
if ( defined( 'ALLOW_SUBDIRECTORY_INSTALL' ) && ALLOW_SUBDIRECTORY_INSTALL ) {
[68] Fix | Delete
return true;
[69] Fix | Delete
}
[70] Fix | Delete
[71] Fix | Delete
$post = $wpdb->get_row( "SELECT ID FROM $wpdb->posts WHERE post_date < DATE_SUB(NOW(), INTERVAL 1 MONTH) AND post_status = 'publish'" );
[72] Fix | Delete
if ( empty( $post ) ) {
[73] Fix | Delete
return true;
[74] Fix | Delete
}
[75] Fix | Delete
[76] Fix | Delete
return false;
[77] Fix | Delete
}
[78] Fix | Delete
[79] Fix | Delete
/**
[80] Fix | Delete
* Get base domain of network.
[81] Fix | Delete
*
[82] Fix | Delete
* @since 3.0.0
[83] Fix | Delete
* @return string Base domain.
[84] Fix | Delete
*/
[85] Fix | Delete
function get_clean_basedomain() {
[86] Fix | Delete
$existing_domain = network_domain_check();
[87] Fix | Delete
if ( $existing_domain ) {
[88] Fix | Delete
return $existing_domain;
[89] Fix | Delete
}
[90] Fix | Delete
$domain = preg_replace( '|https?://|', '', get_option( 'siteurl' ) );
[91] Fix | Delete
$slash = strpos( $domain, '/' );
[92] Fix | Delete
if ( $slash ) {
[93] Fix | Delete
$domain = substr( $domain, 0, $slash );
[94] Fix | Delete
}
[95] Fix | Delete
return $domain;
[96] Fix | Delete
}
[97] Fix | Delete
[98] Fix | Delete
/**
[99] Fix | Delete
* Prints step 1 for Network installation process.
[100] Fix | Delete
*
[101] Fix | Delete
* @todo Realistically, step 1 should be a welcome screen explaining what a Network is and such.
[102] Fix | Delete
* Navigating to Tools > Network should not be a sudden "Welcome to a new install process!
[103] Fix | Delete
* Fill this out and click here." See also contextual help todo.
[104] Fix | Delete
*
[105] Fix | Delete
* @since 3.0.0
[106] Fix | Delete
*
[107] Fix | Delete
* @global bool $is_apache
[108] Fix | Delete
*
[109] Fix | Delete
* @param false|WP_Error $errors Optional. Error object. Default false.
[110] Fix | Delete
*/
[111] Fix | Delete
function network_step1( $errors = false ) {
[112] Fix | Delete
global $is_apache;
[113] Fix | Delete
[114] Fix | Delete
if ( defined( 'DO_NOT_UPGRADE_GLOBAL_TABLES' ) ) {
[115] Fix | Delete
$cannot_define_constant_message = '<strong>' . __( 'Error:' ) . '</strong> ';
[116] Fix | Delete
$cannot_define_constant_message .= sprintf(
[117] Fix | Delete
/* translators: %s: DO_NOT_UPGRADE_GLOBAL_TABLES */
[118] Fix | Delete
__( 'The constant %s cannot be defined when creating a network.' ),
[119] Fix | Delete
'<code>DO_NOT_UPGRADE_GLOBAL_TABLES</code>'
[120] Fix | Delete
);
[121] Fix | Delete
[122] Fix | Delete
wp_admin_notice(
[123] Fix | Delete
$cannot_define_constant_message,
[124] Fix | Delete
array(
[125] Fix | Delete
'additional_classes' => array( 'error' ),
[126] Fix | Delete
)
[127] Fix | Delete
);
[128] Fix | Delete
[129] Fix | Delete
echo '</div>';
[130] Fix | Delete
require_once ABSPATH . 'wp-admin/admin-footer.php';
[131] Fix | Delete
die();
[132] Fix | Delete
}
[133] Fix | Delete
[134] Fix | Delete
$active_plugins = get_option( 'active_plugins' );
[135] Fix | Delete
if ( ! empty( $active_plugins ) ) {
[136] Fix | Delete
wp_admin_notice(
[137] Fix | Delete
'<strong>' . __( 'Warning:' ) . '</strong> ' . sprintf(
[138] Fix | Delete
/* translators: %s: URL to Plugins screen. */
[139] Fix | Delete
__( 'Please <a href="%s">deactivate your plugins</a> before enabling the Network feature.' ),
[140] Fix | Delete
admin_url( 'plugins.php?plugin_status=active' )
[141] Fix | Delete
),
[142] Fix | Delete
array( 'type' => 'warning' )
[143] Fix | Delete
);
[144] Fix | Delete
echo '<p>' . __( 'Once the network is created, you may reactivate your plugins.' ) . '</p>';
[145] Fix | Delete
echo '</div>';
[146] Fix | Delete
require_once ABSPATH . 'wp-admin/admin-footer.php';
[147] Fix | Delete
die();
[148] Fix | Delete
}
[149] Fix | Delete
[150] Fix | Delete
// Strip standard port from hostname.
[151] Fix | Delete
$hostname = preg_replace( '/(?::80|:443)$/', '', get_clean_basedomain() );
[152] Fix | Delete
[153] Fix | Delete
echo '<form method="post">';
[154] Fix | Delete
[155] Fix | Delete
wp_nonce_field( 'install-network-1' );
[156] Fix | Delete
[157] Fix | Delete
$error_codes = array();
[158] Fix | Delete
if ( is_wp_error( $errors ) ) {
[159] Fix | Delete
$network_created_error_message = '<p><strong>' . __( 'Error: The network could not be created.' ) . '</strong></p>';
[160] Fix | Delete
foreach ( $errors->get_error_messages() as $error ) {
[161] Fix | Delete
$network_created_error_message .= "<p>$error</p>";
[162] Fix | Delete
}
[163] Fix | Delete
wp_admin_notice(
[164] Fix | Delete
$network_created_error_message,
[165] Fix | Delete
array(
[166] Fix | Delete
'additional_classes' => array( 'error' ),
[167] Fix | Delete
'paragraph_wrap' => false,
[168] Fix | Delete
)
[169] Fix | Delete
);
[170] Fix | Delete
$error_codes = $errors->get_error_codes();
[171] Fix | Delete
}
[172] Fix | Delete
[173] Fix | Delete
if ( ! empty( $_POST['sitename'] ) && ! in_array( 'empty_sitename', $error_codes, true ) ) {
[174] Fix | Delete
$site_name = $_POST['sitename'];
[175] Fix | Delete
} else {
[176] Fix | Delete
/* translators: %s: Default network title. */
[177] Fix | Delete
$site_name = sprintf( __( '%s Sites' ), get_option( 'blogname' ) );
[178] Fix | Delete
}
[179] Fix | Delete
[180] Fix | Delete
if ( ! empty( $_POST['email'] ) && ! in_array( 'invalid_email', $error_codes, true ) ) {
[181] Fix | Delete
$admin_email = $_POST['email'];
[182] Fix | Delete
} else {
[183] Fix | Delete
$admin_email = get_option( 'admin_email' );
[184] Fix | Delete
}
[185] Fix | Delete
?>
[186] Fix | Delete
<p><?php _e( 'Welcome to the Network installation process!' ); ?></p>
[187] Fix | Delete
<p><?php _e( 'Fill in the information below and you&#8217;ll be on your way to creating a network of WordPress sites. Configuration files will be created in the next step.' ); ?></p>
[188] Fix | Delete
<?php
[189] Fix | Delete
[190] Fix | Delete
if ( isset( $_POST['subdomain_install'] ) ) {
[191] Fix | Delete
$subdomain_install = (bool) $_POST['subdomain_install'];
[192] Fix | Delete
} elseif ( apache_mod_loaded( 'mod_rewrite' ) ) { // Assume nothing.
[193] Fix | Delete
$subdomain_install = true;
[194] Fix | Delete
} elseif ( ! allow_subdirectory_install() ) {
[195] Fix | Delete
$subdomain_install = true;
[196] Fix | Delete
} else {
[197] Fix | Delete
$subdomain_install = false;
[198] Fix | Delete
$got_mod_rewrite = got_mod_rewrite();
[199] Fix | Delete
if ( $got_mod_rewrite ) { // Dangerous assumptions.
[200] Fix | Delete
$message_class = 'updated';
[201] Fix | Delete
$message = '<p><strong>' . __( 'Warning:' ) . '</strong> ';
[202] Fix | Delete
$message .= '<p>' . sprintf(
[203] Fix | Delete
/* translators: %s: mod_rewrite */
[204] Fix | Delete
__( 'Please make sure the Apache %s module is installed as it will be used at the end of this installation.' ),
[205] Fix | Delete
'<code>mod_rewrite</code>'
[206] Fix | Delete
) . '</p>';
[207] Fix | Delete
} elseif ( $is_apache ) {
[208] Fix | Delete
$message_class = 'error';
[209] Fix | Delete
$message = '<p><strong>' . __( 'Warning:' ) . '</strong> ';
[210] Fix | Delete
$message .= sprintf(
[211] Fix | Delete
/* translators: %s: mod_rewrite */
[212] Fix | Delete
__( 'It looks like the Apache %s module is not installed.' ),
[213] Fix | Delete
'<code>mod_rewrite</code>'
[214] Fix | Delete
) . '</p>';
[215] Fix | Delete
}
[216] Fix | Delete
[217] Fix | Delete
if ( $got_mod_rewrite || $is_apache ) { // Protect against mod_rewrite mimicry (but ! Apache).
[218] Fix | Delete
$message .= '<p>' . sprintf(
[219] Fix | Delete
/* translators: 1: mod_rewrite, 2: mod_rewrite documentation URL, 3: Google search for mod_rewrite. */
[220] Fix | Delete
__( 'If %1$s is disabled, ask your administrator to enable that module, or look at the <a href="%2$s">Apache documentation</a> or <a href="%3$s">elsewhere</a> for help setting it up.' ),
[221] Fix | Delete
'<code>mod_rewrite</code>',
[222] Fix | Delete
'https://httpd.apache.org/docs/mod/mod_rewrite.html',
[223] Fix | Delete
'https://www.google.com/search?q=apache+mod_rewrite'
[224] Fix | Delete
) . '</p>';
[225] Fix | Delete
[226] Fix | Delete
wp_admin_notice(
[227] Fix | Delete
$message,
[228] Fix | Delete
array(
[229] Fix | Delete
'additional_classes' => array( $message_class, 'inline' ),
[230] Fix | Delete
'paragraph_wrap' => false,
[231] Fix | Delete
)
[232] Fix | Delete
);
[233] Fix | Delete
}
[234] Fix | Delete
}
[235] Fix | Delete
[236] Fix | Delete
if ( allow_subdomain_install() && allow_subdirectory_install() ) :
[237] Fix | Delete
?>
[238] Fix | Delete
<h3><?php esc_html_e( 'Addresses of Sites in your Network' ); ?></h3>
[239] Fix | Delete
<p><?php _e( 'Please choose whether you would like sites in your WordPress network to use sub-domains or sub-directories.' ); ?>
[240] Fix | Delete
<strong><?php _e( 'You cannot change this later.' ); ?></strong></p>
[241] Fix | Delete
<p><?php _e( 'You will need a wildcard DNS record if you are going to use the virtual host (sub-domain) functionality.' ); ?></p>
[242] Fix | Delete
<?php // @todo Link to an MS readme? ?>
[243] Fix | Delete
<table class="form-table" role="presentation">
[244] Fix | Delete
<tr>
[245] Fix | Delete
<th><label><input type="radio" name="subdomain_install" value="1"<?php checked( $subdomain_install ); ?> /> <?php _e( 'Sub-domains' ); ?></label></th>
[246] Fix | Delete
<td>
[247] Fix | Delete
<?php
[248] Fix | Delete
printf(
[249] Fix | Delete
/* translators: 1: Host name. */
[250] Fix | Delete
_x( 'like <code>site1.%1$s</code> and <code>site2.%1$s</code>', 'subdomain examples' ),
[251] Fix | Delete
$hostname
[252] Fix | Delete
);
[253] Fix | Delete
?>
[254] Fix | Delete
</td>
[255] Fix | Delete
</tr>
[256] Fix | Delete
<tr>
[257] Fix | Delete
<th><label><input type="radio" name="subdomain_install" value="0"<?php checked( ! $subdomain_install ); ?> /> <?php _e( 'Sub-directories' ); ?></label></th>
[258] Fix | Delete
<td>
[259] Fix | Delete
<?php
[260] Fix | Delete
printf(
[261] Fix | Delete
/* translators: 1: Host name. */
[262] Fix | Delete
_x( 'like <code>%1$s/site1</code> and <code>%1$s/site2</code>', 'subdirectory examples' ),
[263] Fix | Delete
$hostname
[264] Fix | Delete
);
[265] Fix | Delete
?>
[266] Fix | Delete
</td>
[267] Fix | Delete
</tr>
[268] Fix | Delete
</table>
[269] Fix | Delete
[270] Fix | Delete
<?php
[271] Fix | Delete
endif;
[272] Fix | Delete
[273] Fix | Delete
if ( WP_CONTENT_DIR !== ABSPATH . 'wp-content' && ( allow_subdirectory_install() || ! allow_subdomain_install() ) ) {
[274] Fix | Delete
$subdirectory_warning_message = '<strong>' . __( 'Warning:' ) . '</strong> ';
[275] Fix | Delete
$subdirectory_warning_message .= __( 'Subdirectory networks may not be fully compatible with custom wp-content directories.' );
[276] Fix | Delete
wp_admin_notice(
[277] Fix | Delete
$subdirectory_warning_message,
[278] Fix | Delete
array(
[279] Fix | Delete
'additional_classes' => array( 'error', 'inline' ),
[280] Fix | Delete
)
[281] Fix | Delete
);
[282] Fix | Delete
}
[283] Fix | Delete
[284] Fix | Delete
$is_www = str_starts_with( $hostname, 'www.' );
[285] Fix | Delete
if ( $is_www ) :
[286] Fix | Delete
?>
[287] Fix | Delete
<h3><?php esc_html_e( 'Server Address' ); ?></h3>
[288] Fix | Delete
<p>
[289] Fix | Delete
<?php
[290] Fix | Delete
printf(
[291] Fix | Delete
/* translators: 1: Site URL, 2: Host name, 3: www. */
[292] Fix | Delete
__( 'You should consider changing your site domain to %1$s before enabling the network feature. It will still be possible to visit your site using the %3$s prefix with an address like %2$s but any links will not have the %3$s prefix.' ),
[293] Fix | Delete
'<code>' . substr( $hostname, 4 ) . '</code>',
[294] Fix | Delete
'<code>' . $hostname . '</code>',
[295] Fix | Delete
'<code>www</code>'
[296] Fix | Delete
);
[297] Fix | Delete
?>
[298] Fix | Delete
</p>
[299] Fix | Delete
<table class="form-table" role="presentation">
[300] Fix | Delete
<tr>
[301] Fix | Delete
<th scope='row'><?php esc_html_e( 'Server Address' ); ?></th>
[302] Fix | Delete
<td>
[303] Fix | Delete
<?php
[304] Fix | Delete
printf(
[305] Fix | Delete
/* translators: %s: Host name. */
[306] Fix | Delete
__( 'The internet address of your network will be %s.' ),
[307] Fix | Delete
'<code>' . $hostname . '</code>'
[308] Fix | Delete
);
[309] Fix | Delete
?>
[310] Fix | Delete
</td>
[311] Fix | Delete
</tr>
[312] Fix | Delete
</table>
[313] Fix | Delete
<?php endif; ?>
[314] Fix | Delete
[315] Fix | Delete
<h3><?php esc_html_e( 'Network Details' ); ?></h3>
[316] Fix | Delete
<table class="form-table" role="presentation">
[317] Fix | Delete
<?php if ( 'localhost' === $hostname ) : ?>
[318] Fix | Delete
<tr>
[319] Fix | Delete
<th scope="row"><?php esc_html_e( 'Sub-directory Installation' ); ?></th>
[320] Fix | Delete
<td>
[321] Fix | Delete
<?php
[322] Fix | Delete
printf(
[323] Fix | Delete
/* translators: 1: localhost, 2: localhost.localdomain */
[324] Fix | Delete
__( 'Because you are using %1$s, the sites in your WordPress network must use sub-directories. Consider using %2$s if you wish to use sub-domains.' ),
[325] Fix | Delete
'<code>localhost</code>',
[326] Fix | Delete
'<code>localhost.localdomain</code>'
[327] Fix | Delete
);
[328] Fix | Delete
// Uh oh:
[329] Fix | Delete
if ( ! allow_subdirectory_install() ) {
[330] Fix | Delete
echo ' <strong>' . __( 'Warning:' ) . ' ' . __( 'The main site in a sub-directory installation will need to use a modified permalink structure, potentially breaking existing links.' ) . '</strong>';
[331] Fix | Delete
}
[332] Fix | Delete
?>
[333] Fix | Delete
</td>
[334] Fix | Delete
</tr>
[335] Fix | Delete
<?php elseif ( ! allow_subdomain_install() ) : ?>
[336] Fix | Delete
<tr>
[337] Fix | Delete
<th scope="row"><?php esc_html_e( 'Sub-directory Installation' ); ?></th>
[338] Fix | Delete
<td>
[339] Fix | Delete
<?php
[340] Fix | Delete
_e( 'Because your installation is in a directory, the sites in your WordPress network must use sub-directories.' );
[341] Fix | Delete
// Uh oh:
[342] Fix | Delete
if ( ! allow_subdirectory_install() ) {
[343] Fix | Delete
echo ' <strong>' . __( 'Warning:' ) . ' ' . __( 'The main site in a sub-directory installation will need to use a modified permalink structure, potentially breaking existing links.' ) . '</strong>';
[344] Fix | Delete
}
[345] Fix | Delete
?>
[346] Fix | Delete
</td>
[347] Fix | Delete
</tr>
[348] Fix | Delete
<?php elseif ( ! allow_subdirectory_install() ) : ?>
[349] Fix | Delete
<tr>
[350] Fix | Delete
<th scope="row"><?php esc_html_e( 'Sub-domain Installation' ); ?></th>
[351] Fix | Delete
<td>
[352] Fix | Delete
<?php
[353] Fix | Delete
_e( 'Because your installation is not new, the sites in your WordPress network must use sub-domains.' );
[354] Fix | Delete
echo ' <strong>' . __( 'The main site in a sub-directory installation will need to use a modified permalink structure, potentially breaking existing links.' ) . '</strong>';
[355] Fix | Delete
?>
[356] Fix | Delete
</td>
[357] Fix | Delete
</tr>
[358] Fix | Delete
<?php endif; ?>
[359] Fix | Delete
<?php if ( ! $is_www ) : ?>
[360] Fix | Delete
<tr>
[361] Fix | Delete
<th scope='row'><?php esc_html_e( 'Server Address' ); ?></th>
[362] Fix | Delete
<td>
[363] Fix | Delete
<?php
[364] Fix | Delete
printf(
[365] Fix | Delete
/* translators: %s: Host name. */
[366] Fix | Delete
__( 'The internet address of your network will be %s.' ),
[367] Fix | Delete
'<code>' . $hostname . '</code>'
[368] Fix | Delete
);
[369] Fix | Delete
?>
[370] Fix | Delete
</td>
[371] Fix | Delete
</tr>
[372] Fix | Delete
<?php endif; ?>
[373] Fix | Delete
<tr>
[374] Fix | Delete
<th scope='row'><label for="sitename"><?php esc_html_e( 'Network Title' ); ?></label></th>
[375] Fix | Delete
<td>
[376] Fix | Delete
<input name='sitename' id='sitename' type='text' size='45' value='<?php echo esc_attr( $site_name ); ?>' />
[377] Fix | Delete
<p class="description">
[378] Fix | Delete
<?php _e( 'What would you like to call your network?' ); ?>
[379] Fix | Delete
</p>
[380] Fix | Delete
</td>
[381] Fix | Delete
</tr>
[382] Fix | Delete
<tr>
[383] Fix | Delete
<th scope='row'><label for="email"><?php esc_html_e( 'Network Admin Email' ); ?></label></th>
[384] Fix | Delete
<td>
[385] Fix | Delete
<input name='email' id='email' type='text' size='45' value='<?php echo esc_attr( $admin_email ); ?>' />
[386] Fix | Delete
<p class="description">
[387] Fix | Delete
<?php _e( 'Your email address.' ); ?>
[388] Fix | Delete
</p>
[389] Fix | Delete
</td>
[390] Fix | Delete
</tr>
[391] Fix | Delete
</table>
[392] Fix | Delete
<?php submit_button( __( 'Install' ), 'primary', 'submit' ); ?>
[393] Fix | Delete
</form>
[394] Fix | Delete
<?php
[395] Fix | Delete
}
[396] Fix | Delete
[397] Fix | Delete
/**
[398] Fix | Delete
* Prints step 2 for Network installation process.
[399] Fix | Delete
*
[400] Fix | Delete
* @since 3.0.0
[401] Fix | Delete
*
[402] Fix | Delete
* @global wpdb $wpdb WordPress database abstraction object.
[403] Fix | Delete
* @global bool $is_nginx Whether the server software is Nginx or something else.
[404] Fix | Delete
*
[405] Fix | Delete
* @param false|WP_Error $errors Optional. Error object. Default false.
[406] Fix | Delete
*/
[407] Fix | Delete
function network_step2( $errors = false ) {
[408] Fix | Delete
global $wpdb, $is_nginx;
[409] Fix | Delete
[410] Fix | Delete
$hostname = get_clean_basedomain();
[411] Fix | Delete
$slashed_home = trailingslashit( get_option( 'home' ) );
[412] Fix | Delete
$base = parse_url( $slashed_home, PHP_URL_PATH );
[413] Fix | Delete
$document_root_fix = str_replace( '\\', '/', realpath( $_SERVER['DOCUMENT_ROOT'] ) );
[414] Fix | Delete
$abspath_fix = str_replace( '\\', '/', ABSPATH );
[415] Fix | Delete
$home_path = str_starts_with( $abspath_fix, $document_root_fix ) ? $document_root_fix . $base : get_home_path();
[416] Fix | Delete
$wp_siteurl_subdir = preg_replace( '#^' . preg_quote( $home_path, '#' ) . '#', '', $abspath_fix );
[417] Fix | Delete
$rewrite_base = ! empty( $wp_siteurl_subdir ) ? ltrim( trailingslashit( $wp_siteurl_subdir ), '/' ) : '';
[418] Fix | Delete
[419] Fix | Delete
$location_of_wp_config = $abspath_fix;
[420] Fix | Delete
if ( ! file_exists( ABSPATH . 'wp-config.php' ) && file_exists( dirname( ABSPATH ) . '/wp-config.php' ) ) {
[421] Fix | Delete
$location_of_wp_config = dirname( $abspath_fix );
[422] Fix | Delete
}
[423] Fix | Delete
$location_of_wp_config = trailingslashit( $location_of_wp_config );
[424] Fix | Delete
[425] Fix | Delete
// Wildcard DNS message.
[426] Fix | Delete
if ( is_wp_error( $errors ) ) {
[427] Fix | Delete
wp_admin_notice(
[428] Fix | Delete
$errors->get_error_message(),
[429] Fix | Delete
array(
[430] Fix | Delete
'additional_classes' => array( 'error' ),
[431] Fix | Delete
)
[432] Fix | Delete
);
[433] Fix | Delete
}
[434] Fix | Delete
[435] Fix | Delete
if ( $_POST ) {
[436] Fix | Delete
if ( allow_subdomain_install() ) {
[437] Fix | Delete
$subdomain_install = allow_subdirectory_install() ? ! empty( $_POST['subdomain_install'] ) : true;
[438] Fix | Delete
} else {
[439] Fix | Delete
$subdomain_install = false;
[440] Fix | Delete
}
[441] Fix | Delete
} else {
[442] Fix | Delete
if ( is_multisite() ) {
[443] Fix | Delete
$subdomain_install = is_subdomain_install();
[444] Fix | Delete
?>
[445] Fix | Delete
<p><?php _e( 'The original configuration steps are shown here for reference.' ); ?></p>
[446] Fix | Delete
<?php
[447] Fix | Delete
} else {
[448] Fix | Delete
$subdomain_install = (bool) $wpdb->get_var( "SELECT meta_value FROM $wpdb->sitemeta WHERE site_id = 1 AND meta_key = 'subdomain_install'" );
[449] Fix | Delete
[450] Fix | Delete
wp_admin_notice(
[451] Fix | Delete
'<strong>' . __( 'Warning:' ) . '</strong> ' . __( 'An existing WordPress network was detected.' ),
[452] Fix | Delete
array(
[453] Fix | Delete
'additional_classes' => array( 'error' ),
[454] Fix | Delete
)
[455] Fix | Delete
);
[456] Fix | Delete
?>
[457] Fix | Delete
<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>
[458] Fix | Delete
<?php
[459] Fix | Delete
}
[460] Fix | Delete
}
[461] Fix | Delete
[462] Fix | Delete
$subdir_match = $subdomain_install ? '' : '([_0-9a-zA-Z-]+/)?';
[463] Fix | Delete
$subdir_replacement_01 = $subdomain_install ? '' : '$1';
[464] Fix | Delete
$subdir_replacement_12 = $subdomain_install ? '$1' : '$2';
[465] Fix | Delete
[466] Fix | Delete
if ( $_POST || ! is_multisite() ) {
[467] Fix | Delete
?>
[468] Fix | Delete
<h3><?php esc_html_e( 'Enabling the Network' ); ?></h3>
[469] Fix | Delete
<p><?php _e( 'Complete the following steps to enable the features for creating a network of sites.' ); ?></p>
[470] Fix | Delete
<?php
[471] Fix | Delete
$notice_message = '<strong>' . __( 'Caution:' ) . '</strong> ';
[472] Fix | Delete
$notice_args = array(
[473] Fix | Delete
'type' => 'warning',
[474] Fix | Delete
'additional_classes' => array( 'inline' ),
[475] Fix | Delete
);
[476] Fix | Delete
[477] Fix | Delete
if ( file_exists( $home_path . '.htaccess' ) ) {
[478] Fix | Delete
$notice_message .= sprintf(
[479] Fix | Delete
/* translators: 1: wp-config.php, 2: .htaccess */
[480] Fix | Delete
__( 'You should back up your existing %1$s and %2$s files.' ),
[481] Fix | Delete
'<code>wp-config.php</code>',
[482] Fix | Delete
'<code>.htaccess</code>'
[483] Fix | Delete
);
[484] Fix | Delete
} elseif ( file_exists( $home_path . 'web.config' ) ) {
[485] Fix | Delete
$notice_message .= sprintf(
[486] Fix | Delete
/* translators: 1: wp-config.php, 2: web.config */
[487] Fix | Delete
__( 'You should back up your existing %1$s and %2$s files.' ),
[488] Fix | Delete
'<code>wp-config.php</code>',
[489] Fix | Delete
'<code>web.config</code>'
[490] Fix | Delete
);
[491] Fix | Delete
} else {
[492] Fix | Delete
$notice_message .= sprintf(
[493] Fix | Delete
/* translators: %s: wp-config.php */
[494] Fix | Delete
__( 'You should back up your existing %s file.' ),
[495] Fix | Delete
'<code>wp-config.php</code>'
[496] Fix | Delete
);
[497] Fix | Delete
}
[498] Fix | Delete
[499] Fix | Delete
12
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function