2015-09-11 00:01:24 +02:00
< ? php
/**
* WordPress Network Administration API .
*
* @ package WordPress
* @ subpackage Administration
* @ since 4.4 . 0
*/
/**
* Check for an existing network .
*
* @ since 3.0 . 0
*
2015-10-15 01:44:25 +02:00
* @ global wpdb $wpdb WordPress database abstraction object .
2015-09-11 00:01:24 +02:00
*
2019-01-08 06:27:50 +01:00
* @ return string | false Base domain if network exists , otherwise false .
2015-09-11 00:01:24 +02:00
*/
function network_domain_check () {
global $wpdb ;
2017-12-01 00:11:00 +01:00
$sql = $wpdb -> prepare ( 'SHOW TABLES LIKE %s' , $wpdb -> esc_like ( $wpdb -> site ) );
2015-09-11 00:01:24 +02:00
if ( $wpdb -> get_var ( $sql ) ) {
return $wpdb -> get_var ( " SELECT domain FROM $wpdb->site ORDER BY id ASC LIMIT 1 " );
}
return false ;
}
/**
2017-08-22 13:52:48 +02:00
* Allow subdomain installation
2015-09-11 00:01:24 +02:00
*
* @ since 3.0 . 0
2017-08-22 13:52:48 +02:00
* @ return bool Whether subdomain installation is allowed
2015-09-11 00:01:24 +02:00
*/
function allow_subdomain_install () {
$domain = preg_replace ( '|https?://([^/]+)|' , '$1' , get_option ( 'home' ) );
2019-12-16 13:37:06 +01:00
if ( parse_url ( get_option ( 'home' ), PHP_URL_PATH ) || 'localhost' === $domain || preg_match ( '|^[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+$|' , $domain ) ) {
2015-09-11 00:01:24 +02:00
return false ;
2017-12-01 00:11:00 +01:00
}
2015-09-11 00:01:24 +02:00
return true ;
}
/**
2017-08-22 13:52:48 +02:00
* Allow subdirectory installation .
2015-09-11 00:01:24 +02:00
*
* @ since 3.0 . 0
*
2015-10-15 01:44:25 +02:00
* @ global wpdb $wpdb WordPress database abstraction object .
2015-09-11 00:01:24 +02:00
*
2017-08-22 13:52:48 +02:00
* @ return bool Whether subdirectory installation is allowed
2015-09-11 00:01:24 +02:00
*/
function allow_subdirectory_install () {
global $wpdb ;
2020-06-20 14:24:08 +02:00
/**
* Filters whether to enable the subdirectory installation feature in Multisite .
*
* @ since 3.0 . 0
*
* @ param bool $allow Whether to enable the subdirectory installation feature in Multisite .
* Default false .
*/
2017-12-01 00:11:00 +01:00
if ( apply_filters ( 'allow_subdirectory_install' , false ) ) {
2015-09-11 00:01:24 +02:00
return true ;
2017-12-01 00:11:00 +01:00
}
2015-09-11 00:01:24 +02:00
2017-12-01 00:11:00 +01:00
if ( defined ( 'ALLOW_SUBDIRECTORY_INSTALL' ) && ALLOW_SUBDIRECTORY_INSTALL ) {
2015-09-11 00:01:24 +02:00
return true ;
2017-12-01 00:11:00 +01:00
}
2015-09-11 00:01:24 +02:00
$post = $wpdb -> get_row ( " SELECT ID FROM $wpdb->posts WHERE post_date < DATE_SUB(NOW(), INTERVAL 1 MONTH) AND post_status = 'publish' " );
2017-12-01 00:11:00 +01:00
if ( empty ( $post ) ) {
2015-09-11 00:01:24 +02:00
return true ;
2017-12-01 00:11:00 +01:00
}
2015-09-11 00:01:24 +02:00
return false ;
}
/**
* Get base domain of network .
*
* @ since 3.0 . 0
* @ return string Base domain .
*/
function get_clean_basedomain () {
2019-07-01 14:52:01 +02:00
$existing_domain = network_domain_check ();
if ( $existing_domain ) {
2015-09-11 00:01:24 +02:00
return $existing_domain ;
2017-12-01 00:11:00 +01:00
}
2015-09-11 00:01:24 +02:00
$domain = preg_replace ( '|https?://|' , '' , get_option ( 'siteurl' ) );
2019-07-01 14:52:01 +02:00
$slash = strpos ( $domain , '/' );
if ( $slash ) {
2015-09-11 00:01:24 +02:00
$domain = substr ( $domain , 0 , $slash );
2017-12-01 00:11:00 +01:00
}
2015-09-11 00:01:24 +02:00
return $domain ;
}
/**
* Prints step 1 for Network installation process .
*
2020-06-20 14:24:08 +02:00
* @ todo Realistically , step 1 should be a welcome screen explaining what a Network is and such .
* Navigating to Tools > Network should not be a sudden " Welcome to a new install process!
* Fill this out and click here . " See also contextual help todo.
2015-09-11 00:01:24 +02:00
*
* @ since 3.0 . 0
*
* @ global bool $is_apache
*
2021-01-05 18:16:11 +01:00
* @ param false | WP_Error $errors Optional . Error object . Default false .
2015-09-11 00:01:24 +02:00
*/
function network_step1 ( $errors = false ) {
global $is_apache ;
2017-12-01 00:11:00 +01:00
if ( defined ( 'DO_NOT_UPGRADE_GLOBAL_TABLES' ) ) {
Administration: Use `wp_admin_notice()` more in `/wp-admin/includes/`.
Adds further usages of `wp_admin_notice()` in `/wp-admin/includes/` on `.notice-error`, `.notice-warning`, `.error`, and `.updated`.
Ongoing task to implement new function across core.
Follow-up to [56408], [56409], [56410], [56518], [56570], [56571], [56572], [56573], [56576], [56589], [56590], [56597].
Props joedolson, mukesh27, costdev.
See #57791.
Built from https://develop.svn.wordpress.org/trunk@56599
git-svn-id: http://core.svn.wordpress.org/trunk@56111 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2023-09-17 17:23:22 +02:00
$cannot_define_constant_message = '<strong>' . __ ( 'Error:' ) . '</strong> ' ;
$cannot_define_constant_message .= sprintf (
2017-10-18 22:02:50 +02:00
/* translators: %s: DO_NOT_UPGRADE_GLOBAL_TABLES */
__ ( 'The constant %s cannot be defined when creating a network.' ),
'<code>DO_NOT_UPGRADE_GLOBAL_TABLES</code>'
Administration: Use `wp_admin_notice()` more in `/wp-admin/includes/`.
Adds further usages of `wp_admin_notice()` in `/wp-admin/includes/` on `.notice-error`, `.notice-warning`, `.error`, and `.updated`.
Ongoing task to implement new function across core.
Follow-up to [56408], [56409], [56410], [56518], [56570], [56571], [56572], [56573], [56576], [56589], [56590], [56597].
Props joedolson, mukesh27, costdev.
See #57791.
Built from https://develop.svn.wordpress.org/trunk@56599
git-svn-id: http://core.svn.wordpress.org/trunk@56111 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2023-09-17 17:23:22 +02:00
);
wp_admin_notice (
$cannot_define_constant_message ,
array (
'additional_classes' => array ( 'error' ),
)
);
2015-09-11 00:01:24 +02:00
echo '</div>' ;
2020-02-06 07:33:11 +01:00
require_once ABSPATH . 'wp-admin/admin-footer.php' ;
2015-09-11 00:01:24 +02:00
die ();
}
$active_plugins = get_option ( 'active_plugins' );
if ( ! empty ( $active_plugins ) ) {
2023-08-17 23:03:19 +02:00
wp_admin_notice (
'<strong>' . __ ( 'Warning:' ) . '</strong> ' . sprintf (
/* translators: %s: URL to Plugins screen. */
__ ( 'Please <a href="%s">deactivate your plugins</a> before enabling the Network feature.' ),
admin_url ( 'plugins.php?plugin_status=active' )
),
array ( 'type' => 'warning' )
);
2017-10-18 22:51:48 +02:00
echo '<p>' . __ ( 'Once the network is created, you may reactivate your plugins.' ) . '</p>' ;
2015-09-11 00:01:24 +02:00
echo '</div>' ;
2020-02-06 07:33:11 +01:00
require_once ABSPATH . 'wp-admin/admin-footer.php' ;
2015-09-11 00:01:24 +02:00
die ();
}
Bootstrap/Load: Add support for custom ports in multisite site addresses.
This allows a Multisite network to use an address that includes a port name, such as `example.com:1234`, and adds support for this to the local development environment too. You can now run a Multisite installation on the local development environment, for example at `localhost:8889`.
This also fixes some bugs with running a single site installation on a port, and updates the testing infrastructure so that the whole test suite runs both with and without a port number.
Props djzone, scribu, nacin, ipstenu, F J Kaiser, jeremyfelt, johnjamesjacoby, spacedmonkey, PerS, Clorith, Blackbam, enrico.sorcinelli, Jules Colle, obliviousharmony, desrosj, johnbillion
Fixes #21077, #52088
Built from https://develop.svn.wordpress.org/trunk@58097
git-svn-id: http://core.svn.wordpress.org/trunk@57562 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2024-05-04 21:25:10 +02:00
// Strip standard port from hostname.
$hostname = preg_replace ( '/(?::80|:443)$/' , '' , get_clean_basedomain () );
2015-09-11 00:01:24 +02:00
echo '<form method="post">' ;
wp_nonce_field ( 'install-network-1' );
$error_codes = array ();
if ( is_wp_error ( $errors ) ) {
Administration: Use `wp_admin_notice()` more in `/wp-admin/includes/`.
Adds further usages of `wp_admin_notice()` in `/wp-admin/includes/` on `.notice-error`, `.notice-warning`, `.error`, and `.updated`.
Ongoing task to implement new function across core.
Follow-up to [56408], [56409], [56410], [56518], [56570], [56571], [56572], [56573], [56576], [56589], [56590], [56597].
Props joedolson, mukesh27, costdev.
See #57791.
Built from https://develop.svn.wordpress.org/trunk@56599
git-svn-id: http://core.svn.wordpress.org/trunk@56111 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2023-09-17 17:23:22 +02:00
$network_created_error_message = '<p><strong>' . __ ( 'Error: The network could not be created.' ) . '</strong></p>' ;
2017-12-01 00:11:00 +01:00
foreach ( $errors -> get_error_messages () as $error ) {
Administration: Use `wp_admin_notice()` more in `/wp-admin/includes/`.
Adds further usages of `wp_admin_notice()` in `/wp-admin/includes/` on `.notice-error`, `.notice-warning`, `.error`, and `.updated`.
Ongoing task to implement new function across core.
Follow-up to [56408], [56409], [56410], [56518], [56570], [56571], [56572], [56573], [56576], [56589], [56590], [56597].
Props joedolson, mukesh27, costdev.
See #57791.
Built from https://develop.svn.wordpress.org/trunk@56599
git-svn-id: http://core.svn.wordpress.org/trunk@56111 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2023-09-17 17:23:22 +02:00
$network_created_error_message .= " <p> $error </p> " ;
2017-12-01 00:11:00 +01:00
}
Administration: Use `wp_admin_notice()` more in `/wp-admin/includes/`.
Adds further usages of `wp_admin_notice()` in `/wp-admin/includes/` on `.notice-error`, `.notice-warning`, `.error`, and `.updated`.
Ongoing task to implement new function across core.
Follow-up to [56408], [56409], [56410], [56518], [56570], [56571], [56572], [56573], [56576], [56589], [56590], [56597].
Props joedolson, mukesh27, costdev.
See #57791.
Built from https://develop.svn.wordpress.org/trunk@56599
git-svn-id: http://core.svn.wordpress.org/trunk@56111 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2023-09-17 17:23:22 +02:00
wp_admin_notice (
$network_created_error_message ,
array (
'additional_classes' => array ( 'error' ),
'paragraph_wrap' => false ,
)
);
2015-09-11 00:01:24 +02:00
$error_codes = $errors -> get_error_codes ();
}
2020-04-05 05:02:11 +02:00
if ( ! empty ( $_POST [ 'sitename' ] ) && ! in_array ( 'empty_sitename' , $error_codes , true ) ) {
2016-08-23 02:17:27 +02:00
$site_name = $_POST [ 'sitename' ];
} else {
2019-09-03 02:41:05 +02:00
/* translators: %s: Default network title. */
2016-08-23 02:17:27 +02:00
$site_name = sprintf ( __ ( '%s Sites' ), get_option ( 'blogname' ) );
}
2020-04-05 05:02:11 +02:00
if ( ! empty ( $_POST [ 'email' ] ) && ! in_array ( 'invalid_email' , $error_codes , true ) ) {
2016-08-23 02:17:27 +02:00
$admin_email = $_POST [ 'email' ];
} else {
$admin_email = get_option ( 'admin_email' );
}
2015-09-11 00:01:24 +02:00
?>
< p >< ? php _e ( 'Welcome to the Network installation process!' ); ?> </p>
2021-11-02 18:37:57 +01:00
< p >< ? php _e ( 'Fill in the information below and you’ll be on your way to creating a network of WordPress sites. Configuration files will be created in the next step.' ); ?> </p>
2015-09-11 00:01:24 +02:00
< ? php
if ( isset ( $_POST [ 'subdomain_install' ] ) ) {
$subdomain_install = ( bool ) $_POST [ 'subdomain_install' ];
2020-01-29 01:35:08 +01:00
} elseif ( apache_mod_loaded ( 'mod_rewrite' ) ) { // Assume nothing.
2015-09-11 00:01:24 +02:00
$subdomain_install = true ;
2017-12-01 00:11:00 +01:00
} elseif ( ! allow_subdirectory_install () ) {
2015-09-11 00:01:24 +02:00
$subdomain_install = true ;
} else {
$subdomain_install = false ;
2019-07-01 14:52:01 +02:00
$got_mod_rewrite = got_mod_rewrite ();
2020-01-29 01:35:08 +01:00
if ( $got_mod_rewrite ) { // Dangerous assumptions.
Administration: Use `wp_admin_notice()` more in `/wp-admin/includes/`.
Adds further usages of `wp_admin_notice()` in `/wp-admin/includes/` on `.notice-error`, `.notice-warning`, `.error`, and `.updated`.
Ongoing task to implement new function across core.
Follow-up to [56408], [56409], [56410], [56518], [56570], [56571], [56572], [56573], [56576], [56589], [56590], [56597].
Props joedolson, mukesh27, costdev.
See #57791.
Built from https://develop.svn.wordpress.org/trunk@56599
git-svn-id: http://core.svn.wordpress.org/trunk@56111 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2023-09-17 17:23:22 +02:00
$message_class = 'updated' ;
$message = '<p><strong>' . __ ( 'Warning:' ) . '</strong> ' ;
$message .= '<p>' . sprintf (
I18N: Improve translator comments.
* Add missing translator comments.
* Fix placement of some translator comments. Translator comments should be on the line directly above the line containing the translation function call for optimal compatibility with various `.pot` file generation tools. The CS auto-fixing, which changed some inconsistent function calls to multi-line function calls, is part of the reason why this was no longer the case for a select group of translator comments.
Includes minor code layout fixes.
Polyglots, rejoice! All WordPress core files now have translator comments for all strings with placeholders!
Props jrf, subrataemfluence, GaryJ, webdados, Dency, swissspidy, alvarogois, marcomartins, mihaiiceyro, vladwtz, niq1982, flipkeijzer, michielatyoast, chandrapatel, thrijith, joshuanoyce, FesoVik, tessak22, bhaktirajdev, cleancoded, dhavalkasvala, garrett-eclipse, bibliofille, socalchristina, priyankkpatel, 5hel2l2y, adamsilverstein, JeffPaul, pierlo, SergeyBiryukov.
Fixes #44360.
Built from https://develop.svn.wordpress.org/trunk@45926
git-svn-id: http://core.svn.wordpress.org/trunk@45737 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2019-09-01 19:13:59 +02:00
/* translators: %s: mod_rewrite */
2017-12-01 00:11:00 +01:00
__ ( 'Please make sure the Apache %s module is installed as it will be used at the end of this installation.' ),
2015-11-06 01:59:25 +01:00
'<code>mod_rewrite</code>'
Administration: Use `wp_admin_notice()` more in `/wp-admin/includes/`.
Adds further usages of `wp_admin_notice()` in `/wp-admin/includes/` on `.notice-error`, `.notice-warning`, `.error`, and `.updated`.
Ongoing task to implement new function across core.
Follow-up to [56408], [56409], [56410], [56518], [56570], [56571], [56572], [56573], [56576], [56589], [56590], [56597].
Props joedolson, mukesh27, costdev.
See #57791.
Built from https://develop.svn.wordpress.org/trunk@56599
git-svn-id: http://core.svn.wordpress.org/trunk@56111 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2023-09-17 17:23:22 +02:00
) . '</p>' ;
2015-11-06 01:59:25 +01:00
} elseif ( $is_apache ) {
Administration: Use `wp_admin_notice()` more in `/wp-admin/includes/`.
Adds further usages of `wp_admin_notice()` in `/wp-admin/includes/` on `.notice-error`, `.notice-warning`, `.error`, and `.updated`.
Ongoing task to implement new function across core.
Follow-up to [56408], [56409], [56410], [56518], [56570], [56571], [56572], [56573], [56576], [56589], [56590], [56597].
Props joedolson, mukesh27, costdev.
See #57791.
Built from https://develop.svn.wordpress.org/trunk@56599
git-svn-id: http://core.svn.wordpress.org/trunk@56111 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2023-09-17 17:23:22 +02:00
$message_class = 'error' ;
$message = '<p><strong>' . __ ( 'Warning:' ) . '</strong> ' ;
$message .= sprintf (
I18N: Improve translator comments.
* Add missing translator comments.
* Fix placement of some translator comments. Translator comments should be on the line directly above the line containing the translation function call for optimal compatibility with various `.pot` file generation tools. The CS auto-fixing, which changed some inconsistent function calls to multi-line function calls, is part of the reason why this was no longer the case for a select group of translator comments.
Includes minor code layout fixes.
Polyglots, rejoice! All WordPress core files now have translator comments for all strings with placeholders!
Props jrf, subrataemfluence, GaryJ, webdados, Dency, swissspidy, alvarogois, marcomartins, mihaiiceyro, vladwtz, niq1982, flipkeijzer, michielatyoast, chandrapatel, thrijith, joshuanoyce, FesoVik, tessak22, bhaktirajdev, cleancoded, dhavalkasvala, garrett-eclipse, bibliofille, socalchristina, priyankkpatel, 5hel2l2y, adamsilverstein, JeffPaul, pierlo, SergeyBiryukov.
Fixes #44360.
Built from https://develop.svn.wordpress.org/trunk@45926
git-svn-id: http://core.svn.wordpress.org/trunk@45737 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2019-09-01 19:13:59 +02:00
/* translators: %s: mod_rewrite */
2017-12-01 00:11:00 +01:00
__ ( 'It looks like the Apache %s module is not installed.' ),
2015-11-06 01:59:25 +01:00
'<code>mod_rewrite</code>'
Administration: Use `wp_admin_notice()` more in `/wp-admin/includes/`.
Adds further usages of `wp_admin_notice()` in `/wp-admin/includes/` on `.notice-error`, `.notice-warning`, `.error`, and `.updated`.
Ongoing task to implement new function across core.
Follow-up to [56408], [56409], [56410], [56518], [56570], [56571], [56572], [56573], [56576], [56589], [56590], [56597].
Props joedolson, mukesh27, costdev.
See #57791.
Built from https://develop.svn.wordpress.org/trunk@56599
git-svn-id: http://core.svn.wordpress.org/trunk@56111 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2023-09-17 17:23:22 +02:00
) . '</p>' ;
2015-11-06 01:59:25 +01:00
}
2020-01-29 01:35:08 +01:00
if ( $got_mod_rewrite || $is_apache ) { // Protect against mod_rewrite mimicry (but ! Apache).
Administration: Use `wp_admin_notice()` more in `/wp-admin/includes/`.
Adds further usages of `wp_admin_notice()` in `/wp-admin/includes/` on `.notice-error`, `.notice-warning`, `.error`, and `.updated`.
Ongoing task to implement new function across core.
Follow-up to [56408], [56409], [56410], [56518], [56570], [56571], [56572], [56573], [56576], [56589], [56590], [56597].
Props joedolson, mukesh27, costdev.
See #57791.
Built from https://develop.svn.wordpress.org/trunk@56599
git-svn-id: http://core.svn.wordpress.org/trunk@56111 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2023-09-17 17:23:22 +02:00
$message .= '<p>' . sprintf (
2019-09-03 02:41:05 +02:00
/* translators: 1: mod_rewrite, 2: mod_rewrite documentation URL, 3: Google search for mod_rewrite. */
2017-12-01 00:11:00 +01:00
__ ( '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.' ),
2015-11-06 01:59:25 +01:00
'<code>mod_rewrite</code>' ,
2016-06-10 06:50:33 +02:00
'https://httpd.apache.org/docs/mod/mod_rewrite.html' ,
'https://www.google.com/search?q=apache+mod_rewrite'
Administration: Use `wp_admin_notice()` more in `/wp-admin/includes/`.
Adds further usages of `wp_admin_notice()` in `/wp-admin/includes/` on `.notice-error`, `.notice-warning`, `.error`, and `.updated`.
Ongoing task to implement new function across core.
Follow-up to [56408], [56409], [56410], [56518], [56570], [56571], [56572], [56573], [56576], [56589], [56590], [56597].
Props joedolson, mukesh27, costdev.
See #57791.
Built from https://develop.svn.wordpress.org/trunk@56599
git-svn-id: http://core.svn.wordpress.org/trunk@56111 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2023-09-17 17:23:22 +02:00
) . '</p>' ;
wp_admin_notice (
$message ,
array (
'additional_classes' => array ( $message_class , 'inline' ),
'paragraph_wrap' => false ,
)
2015-11-06 01:59:25 +01:00
);
}
2015-09-11 00:01:24 +02:00
}
2017-12-01 00:11:00 +01:00
if ( allow_subdomain_install () && allow_subdirectory_install () ) :
2018-08-17 03:51:36 +02:00
?>
2015-09-11 00:01:24 +02:00
< h3 >< ? php esc_html_e ( 'Addresses of Sites in your Network' ); ?> </h3>
2015-11-06 01:59:25 +01:00
< p >< ? php _e ( 'Please choose whether you would like sites in your WordPress network to use sub-domains or sub-directories.' ); ?>
< strong >< ? php _e ( 'You cannot change this later.' ); ?> </strong></p>
2015-09-11 00:01:24 +02:00
< p >< ? php _e ( 'You will need a wildcard DNS record if you are going to use the virtual host (sub-domain) functionality.' ); ?> </p>
2020-01-29 01:35:08 +01:00
< ? php // @todo Link to an MS readme? ?>
2019-05-24 23:56:54 +02:00
< table class = " form-table " role = " presentation " >
2015-09-11 00:01:24 +02:00
< tr >
< th >< label >< input type = " radio " name = " subdomain_install " value = " 1 " < ? php checked ( $subdomain_install ); ?> /> <?php _e( 'Sub-domains' ); ?></label></th>
2017-12-01 00:11:00 +01:00
< td >
< ? php
printf (
2019-09-03 02:41:05 +02:00
/* translators: 1: Host name. */
2015-09-11 00:01:24 +02:00
_x ( 'like <code>site1.%1$s</code> and <code>site2.%1$s</code>' , 'subdomain examples' ),
$hostname
2017-12-01 00:11:00 +01:00
);
?>
</ td >
2015-09-11 00:01:24 +02:00
</ tr >
< tr >
< th >< label >< input type = " radio " name = " subdomain_install " value = " 0 " < ? php checked ( ! $subdomain_install ); ?> /> <?php _e( 'Sub-directories' ); ?></label></th>
2017-12-01 00:11:00 +01:00
< td >
< ? php
printf (
2019-09-03 02:41:05 +02:00
/* translators: 1: Host name. */
2015-09-11 00:01:24 +02:00
_x ( 'like <code>%1$s/site1</code> and <code>%1$s/site2</code>' , 'subdirectory examples' ),
$hostname
2017-12-01 00:11:00 +01:00
);
?>
</ td >
2015-09-11 00:01:24 +02:00
</ tr >
</ table >
2018-08-17 03:51:36 +02:00
< ? php
2015-09-11 00:01:24 +02:00
endif ;
2019-12-16 13:37:06 +01:00
if ( WP_CONTENT_DIR !== ABSPATH . 'wp-content' && ( allow_subdirectory_install () || ! allow_subdomain_install () ) ) {
Administration: Use `wp_admin_notice()` more in `/wp-admin/includes/`.
Adds further usages of `wp_admin_notice()` in `/wp-admin/includes/` on `.notice-error`, `.notice-warning`, `.error`, and `.updated`.
Ongoing task to implement new function across core.
Follow-up to [56408], [56409], [56410], [56518], [56570], [56571], [56572], [56573], [56576], [56589], [56590], [56597].
Props joedolson, mukesh27, costdev.
See #57791.
Built from https://develop.svn.wordpress.org/trunk@56599
git-svn-id: http://core.svn.wordpress.org/trunk@56111 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2023-09-17 17:23:22 +02:00
$subdirectory_warning_message = '<strong>' . __ ( 'Warning:' ) . '</strong> ' ;
$subdirectory_warning_message .= __ ( 'Subdirectory networks may not be fully compatible with custom wp-content directories.' );
wp_admin_notice (
$subdirectory_warning_message ,
array (
'additional_classes' => array ( 'error' , 'inline' ),
)
);
2017-12-01 00:11:00 +01:00
}
2015-09-11 00:01:24 +02:00
Code Modernization: Replace usage of `strpos()` with `str_starts_with()`.
`str_starts_with()` was introduced in PHP 8.0 to perform a case-sensitive check indicating if the string to search in (haystack) begins with the given substring (needle).
WordPress core includes a polyfill for `str_starts_with()` on PHP < 8.0 as of WordPress 5.9.
This commit replaces `0 === strpos( ... )` with `str_starts_with()` in core files, making the code more readable and consistent, as well as improving performance.
While `strpos()` is slightly faster than the polyfill on PHP < 8.0, `str_starts_with()` is noticeably faster on PHP 8.0+, as it is optimized to avoid unnecessarily searching along the whole haystack if it does not find the needle.
Follow-up to [52039], [52040], [52326].
Props spacedmonkey, costdev, sabernhardt, mukesh27, desrosj, jorbin, TobiasBg, ayeshrajans, lgadzhev, SergeyBiryukov.
Fixes #58012.
Built from https://develop.svn.wordpress.org/trunk@55703
git-svn-id: http://core.svn.wordpress.org/trunk@55215 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2023-05-02 17:45:22 +02:00
$is_www = str_starts_with ( $hostname , 'www.' );
2017-12-01 00:11:00 +01:00
if ( $is_www ) :
2015-09-11 00:01:24 +02:00
?>
< h3 >< ? php esc_html_e ( 'Server Address' ); ?> </h3>
2017-12-01 00:11:00 +01:00
< p >
< ? php
printf (
2019-09-03 02:41:05 +02:00
/* translators: 1: Site URL, 2: Host name, 3: www. */
2021-11-02 18:37:57 +01:00
__ ( '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.' ),
2015-09-18 20:18:27 +02:00
'<code>' . substr ( $hostname , 4 ) . '</code>' ,
'<code>' . $hostname . '</code>' ,
'<code>www</code>'
2017-12-01 00:11:00 +01:00
);
?>
</ p >
2019-05-24 23:56:54 +02:00
< table class = " form-table " role = " presentation " >
2015-09-11 00:01:24 +02:00
< tr >
2017-12-01 00:11:00 +01:00
< th scope = 'row' >< ? php esc_html_e ( 'Server Address' ); ?> </th>
< td >
< ? php
printf (
2019-09-03 02:41:05 +02:00
/* translators: %s: Host name. */
2015-09-18 20:18:27 +02:00
__ ( 'The internet address of your network will be %s.' ),
'<code>' . $hostname . '</code>'
2017-12-01 00:11:00 +01:00
);
2018-08-17 03:51:36 +02:00
?>
2015-09-11 00:01:24 +02:00
</ td >
</ tr >
</ table >
< ? php endif ; ?>
< h3 >< ? php esc_html_e ( 'Network Details' ); ?> </h3>
2019-05-24 23:56:54 +02:00
< table class = " form-table " role = " presentation " >
2019-12-16 13:37:06 +01:00
< ? php if ( 'localhost' === $hostname ) : ?>
2015-09-11 00:01:24 +02:00
< tr >
2017-08-22 13:52:48 +02:00
< th scope = " row " >< ? php esc_html_e ( 'Sub-directory Installation' ); ?> </th>
2017-12-01 00:11:00 +01:00
< td >
< ? php
2015-11-06 01:59:25 +01:00
printf (
2018-03-11 17:44:34 +01:00
/* translators: 1: localhost, 2: localhost.localdomain */
2015-11-06 01:59:25 +01:00
__ ( '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.' ),
'<code>localhost</code>' ,
'<code>localhost.localdomain</code>'
);
2015-09-11 00:01:24 +02:00
// Uh oh:
2017-12-01 00:11:00 +01:00
if ( ! allow_subdirectory_install () ) {
echo ' <strong>' . __ ( 'Warning:' ) . ' ' . __ ( 'The main site in a sub-directory installation will need to use a modified permalink structure, potentially breaking existing links.' ) . '</strong>' ;
}
?>
</ td >
2015-09-11 00:01:24 +02:00
</ tr >
2017-12-01 00:11:00 +01:00
< ? php elseif ( ! allow_subdomain_install () ) : ?>
2015-09-11 00:01:24 +02:00
< tr >
2017-08-22 13:52:48 +02:00
< th scope = " row " >< ? php esc_html_e ( 'Sub-directory Installation' ); ?> </th>
2017-12-01 00:11:00 +01:00
< td >
< ? php
2017-08-22 13:52:48 +02:00
_e ( 'Because your installation is in a directory, the sites in your WordPress network must use sub-directories.' );
2015-09-11 00:01:24 +02:00
// Uh oh:
2017-12-01 00:11:00 +01:00
if ( ! allow_subdirectory_install () ) {
echo ' <strong>' . __ ( 'Warning:' ) . ' ' . __ ( 'The main site in a sub-directory installation will need to use a modified permalink structure, potentially breaking existing links.' ) . '</strong>' ;
}
?>
</ td >
2015-09-11 00:01:24 +02:00
</ tr >
2017-12-01 00:11:00 +01:00
< ? php elseif ( ! allow_subdirectory_install () ) : ?>
2015-09-11 00:01:24 +02:00
< tr >
2017-08-22 13:52:48 +02:00
< th scope = " row " >< ? php esc_html_e ( 'Sub-domain Installation' ); ?> </th>
2017-12-01 00:11:00 +01:00
< td >
< ? php
_e ( 'Because your installation is not new, the sites in your WordPress network must use sub-domains.' );
2017-08-22 13:52:48 +02:00
echo ' <strong>' . __ ( 'The main site in a sub-directory installation will need to use a modified permalink structure, potentially breaking existing links.' ) . '</strong>' ;
2017-12-01 00:11:00 +01:00
?>
</ td >
2015-09-11 00:01:24 +02:00
</ tr >
< ? php endif ; ?>
< ? php if ( ! $is_www ) : ?>
< tr >
< th scope = 'row' >< ? php esc_html_e ( 'Server Address' ); ?> </th>
< td >
2017-12-01 00:11:00 +01:00
< ? php
printf (
2019-09-03 02:41:05 +02:00
/* translators: %s: Host name. */
2015-09-18 20:18:27 +02:00
__ ( 'The internet address of your network will be %s.' ),
'<code>' . $hostname . '</code>'
2017-12-01 00:11:00 +01:00
);
?>
2015-09-11 00:01:24 +02:00
</ td >
</ tr >
< ? php endif ; ?>
< tr >
2019-05-25 17:19:53 +02:00
< th scope = 'row' >< label for = " sitename " >< ? php esc_html_e ( 'Network Title' ); ?> </label></th>
2015-09-11 00:01:24 +02:00
< td >
2019-05-25 17:19:53 +02:00
< input name = 'sitename' id = 'sitename' type = 'text' size = '45' value = '<?php echo esc_attr( $site_name ); ?>' />
2015-09-11 00:01:24 +02:00
< p class = " description " >
< ? php _e ( 'What would you like to call your network?' ); ?>
</ p >
</ td >
</ tr >
< tr >
2019-05-25 17:19:53 +02:00
< th scope = 'row' >< label for = " email " >< ? php esc_html_e ( 'Network Admin Email' ); ?> </label></th>
2015-09-11 00:01:24 +02:00
< td >
2019-05-25 17:19:53 +02:00
< input name = 'email' id = 'email' type = 'text' size = '45' value = '<?php echo esc_attr( $admin_email ); ?>' />
2015-09-11 00:01:24 +02:00
< p class = " description " >
< ? php _e ( 'Your email address.' ); ?>
</ p >
</ td >
</ tr >
</ table >
< ? php submit_button ( __ ( 'Install' ), 'primary' , 'submit' ); ?>
</ form >
< ? php
}
/**
* Prints step 2 for Network installation process .
*
* @ since 3.0 . 0
*
2020-04-29 16:43:09 +02:00
* @ global wpdb $wpdb WordPress database abstraction object .
* @ global bool $is_nginx Whether the server software is Nginx or something else .
2015-09-11 00:01:24 +02:00
*
2021-01-05 18:16:11 +01:00
* @ param false | WP_Error $errors Optional . Error object . Default false .
2015-09-11 00:01:24 +02:00
*/
function network_step2 ( $errors = false ) {
2020-04-29 16:43:09 +02:00
global $wpdb , $is_nginx ;
2015-09-11 00:01:24 +02:00
$hostname = get_clean_basedomain ();
$slashed_home = trailingslashit ( get_option ( 'home' ) );
$base = parse_url ( $slashed_home , PHP_URL_PATH );
$document_root_fix = str_replace ( '\\' , '/' , realpath ( $_SERVER [ 'DOCUMENT_ROOT' ] ) );
$abspath_fix = str_replace ( '\\' , '/' , ABSPATH );
Code Modernization: Replace usage of `strpos()` with `str_starts_with()`.
`str_starts_with()` was introduced in PHP 8.0 to perform a case-sensitive check indicating if the string to search in (haystack) begins with the given substring (needle).
WordPress core includes a polyfill for `str_starts_with()` on PHP < 8.0 as of WordPress 5.9.
This commit replaces `0 === strpos( ... )` with `str_starts_with()` in core files, making the code more readable and consistent, as well as improving performance.
While `strpos()` is slightly faster than the polyfill on PHP < 8.0, `str_starts_with()` is noticeably faster on PHP 8.0+, as it is optimized to avoid unnecessarily searching along the whole haystack if it does not find the needle.
Follow-up to [52039], [52040], [52326].
Props spacedmonkey, costdev, sabernhardt, mukesh27, desrosj, jorbin, TobiasBg, ayeshrajans, lgadzhev, SergeyBiryukov.
Fixes #58012.
Built from https://develop.svn.wordpress.org/trunk@55703
git-svn-id: http://core.svn.wordpress.org/trunk@55215 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2023-05-02 17:45:22 +02:00
$home_path = str_starts_with ( $abspath_fix , $document_root_fix ) ? $document_root_fix . $base : get_home_path ();
2015-09-11 00:01:24 +02:00
$wp_siteurl_subdir = preg_replace ( '#^' . preg_quote ( $home_path , '#' ) . '#' , '' , $abspath_fix );
$rewrite_base = ! empty ( $wp_siteurl_subdir ) ? ltrim ( trailingslashit ( $wp_siteurl_subdir ), '/' ) : '' ;
$location_of_wp_config = $abspath_fix ;
if ( ! file_exists ( ABSPATH . 'wp-config.php' ) && file_exists ( dirname ( ABSPATH ) . '/wp-config.php' ) ) {
$location_of_wp_config = dirname ( $abspath_fix );
}
$location_of_wp_config = trailingslashit ( $location_of_wp_config );
// Wildcard DNS message.
2017-12-01 00:11:00 +01:00
if ( is_wp_error ( $errors ) ) {
Administration: Use `wp_admin_notice()` more in `/wp-admin/includes/`.
Adds further usages of `wp_admin_notice()` in `/wp-admin/includes/` on `.notice-error`, `.notice-warning`, `.error`, and `.updated`.
Ongoing task to implement new function across core.
Follow-up to [56408], [56409], [56410], [56518], [56570], [56571], [56572], [56573], [56576], [56589], [56590], [56597].
Props joedolson, mukesh27, costdev.
See #57791.
Built from https://develop.svn.wordpress.org/trunk@56599
git-svn-id: http://core.svn.wordpress.org/trunk@56111 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2023-09-17 17:23:22 +02:00
wp_admin_notice (
$errors -> get_error_message (),
array (
'additional_classes' => array ( 'error' ),
)
);
2017-12-01 00:11:00 +01:00
}
2015-09-11 00:01:24 +02:00
if ( $_POST ) {
2017-12-01 00:11:00 +01:00
if ( allow_subdomain_install () ) {
2015-09-11 00:01:24 +02:00
$subdomain_install = allow_subdirectory_install () ? ! empty ( $_POST [ 'subdomain_install' ] ) : true ;
2017-12-01 00:11:00 +01:00
} else {
2015-09-11 00:01:24 +02:00
$subdomain_install = false ;
2017-12-01 00:11:00 +01:00
}
2015-09-11 00:01:24 +02:00
} else {
if ( is_multisite () ) {
$subdomain_install = is_subdomain_install ();
2018-08-17 03:51:36 +02:00
?>
2015-09-11 00:01:24 +02:00
< p >< ? php _e ( 'The original configuration steps are shown here for reference.' ); ?> </p>
2018-08-17 03:51:36 +02:00
< ? php
2015-09-11 00:01:24 +02:00
} else {
$subdomain_install = ( bool ) $wpdb -> get_var ( " SELECT meta_value FROM $wpdb->sitemeta WHERE site_id = 1 AND meta_key = 'subdomain_install' " );
Administration: Use `wp_admin_notice()` more in `/wp-admin/includes/`.
Adds further usages of `wp_admin_notice()` in `/wp-admin/includes/` on `.notice-error`, `.notice-warning`, `.error`, and `.updated`.
Ongoing task to implement new function across core.
Follow-up to [56408], [56409], [56410], [56518], [56570], [56571], [56572], [56573], [56576], [56589], [56590], [56597].
Props joedolson, mukesh27, costdev.
See #57791.
Built from https://develop.svn.wordpress.org/trunk@56599
git-svn-id: http://core.svn.wordpress.org/trunk@56111 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2023-09-17 17:23:22 +02:00
wp_admin_notice (
'<strong>' . __ ( 'Warning:' ) . '</strong> ' . __ ( 'An existing WordPress network was detected.' ),
array (
'additional_classes' => array ( 'error' ),
)
);
2018-08-17 03:51:36 +02:00
?>
2015-09-11 00:01:24 +02:00
< 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>
2018-08-17 03:51:36 +02:00
< ? php
2015-09-11 00:01:24 +02:00
}
}
$subdir_match = $subdomain_install ? '' : '([_0-9a-zA-Z-]+/)?' ;
$subdir_replacement_01 = $subdomain_install ? '' : '$1' ;
$subdir_replacement_12 = $subdomain_install ? '$1' : '$2' ;
if ( $_POST || ! is_multisite () ) {
2018-08-17 03:51:36 +02:00
?>
2015-09-11 00:01:24 +02:00
< h3 >< ? php esc_html_e ( 'Enabling the Network' ); ?> </h3>
< p >< ? php _e ( 'Complete the following steps to enable the features for creating a network of sites.' ); ?> </p>
2017-12-01 00:11:00 +01:00
< ? php
2023-08-17 23:03:19 +02:00
$notice_message = '<strong>' . __ ( 'Caution:' ) . '</strong> ' ;
$notice_args = array (
'type' => 'warning' ,
2023-08-17 23:36:21 +02:00
'additional_classes' => array ( 'inline' ),
2023-08-17 23:03:19 +02:00
);
2017-12-01 00:11:00 +01:00
if ( file_exists ( $home_path . '.htaccess' ) ) {
2023-08-17 23:03:19 +02:00
$notice_message .= sprintf (
2018-03-11 17:44:34 +01:00
/* translators: 1: wp-config.php, 2: .htaccess */
2021-11-02 18:37:57 +01:00
__ ( 'You should back up your existing %1$s and %2$s files.' ),
2017-12-01 00:11:00 +01:00
'<code>wp-config.php</code>' ,
'<code>.htaccess</code>'
);
} elseif ( file_exists ( $home_path . 'web.config' ) ) {
2023-08-17 23:03:19 +02:00
$notice_message .= sprintf (
2018-03-11 17:44:34 +01:00
/* translators: 1: wp-config.php, 2: web.config */
2021-11-02 18:37:57 +01:00
__ ( 'You should back up your existing %1$s and %2$s files.' ),
2017-12-01 00:11:00 +01:00
'<code>wp-config.php</code>' ,
'<code>web.config</code>'
);
} else {
2023-08-17 23:03:19 +02:00
$notice_message .= sprintf (
2018-03-11 17:44:34 +01:00
/* translators: %s: wp-config.php */
2021-11-02 18:37:57 +01:00
__ ( 'You should back up your existing %s file.' ),
2017-12-01 00:11:00 +01:00
'<code>wp-config.php</code>'
);
}
2023-08-17 23:03:19 +02:00
wp_admin_notice ( $notice_message , $notice_args );
2015-09-11 00:01:24 +02:00
}
2018-08-17 03:51:36 +02:00
?>
2019-05-24 01:35:52 +02:00
< ol >
2022-07-21 11:04:14 +02:00
< li >< p id = " network-wpconfig-rules-description " >
2019-05-24 01:35:52 +02:00
< ? php
printf (
2019-09-03 02:41:05 +02:00
/* translators: 1: wp-config.php, 2: Location of wp-config file, 3: Translated version of "That's all, stop editing! Happy publishing." */
2019-05-24 01:35:52 +02:00
__ ( 'Add the following to your %1$s file in %2$s <strong>above</strong> the line reading %3$s:' ),
'<code>wp-config.php</code>' ,
'<code>' . $location_of_wp_config . '</code>' ,
/*
* translators : This string should only be translated if wp - config - sample . php is localized .
* You can check the localized release package or
* https :// i18n . svn . wordpress . org /< locale code >/ branches /< wp version >/ dist / wp - config - sample . php
*/
'<code>/* ' . __ ( 'That’s all, stop editing! Happy publishing.' ) . ' */</code>'
);
?>
</ p >
2022-07-21 11:04:14 +02:00
< p class = " configuration-rules-label " >< label for = " network-wpconfig-rules " >
< ? php
printf (
/* translators: %s: File name (wp-config.php, .htaccess or web.config). */
__ ( 'Network configuration rules for %s' ),
'<code>wp-config.php</code>'
);
?>
</ label ></ p >
< textarea id = " network-wpconfig-rules " class = " code " readonly = " readonly " cols = " 100 " rows = " 7 " aria - describedby = " network-wpconfig-rules-description " >
2021-05-11 19:10:02 +02:00
define ( 'MULTISITE' , true );
define ( 'SUBDOMAIN_INSTALL' , < ? php echo $subdomain_install ? 'true' : 'false' ; ?> );
define ( 'DOMAIN_CURRENT_SITE' , '<?php echo $hostname; ?>' );
define ( 'PATH_CURRENT_SITE' , '<?php echo $base; ?>' );
define ( 'SITE_ID_CURRENT_SITE' , 1 );
define ( 'BLOG_ID_CURRENT_SITE' , 1 );
2015-09-11 00:01:24 +02:00
</ textarea >
2019-05-24 01:35:52 +02:00
< ? php
$keys_salts = array (
'AUTH_KEY' => '' ,
'SECURE_AUTH_KEY' => '' ,
'LOGGED_IN_KEY' => '' ,
'NONCE_KEY' => '' ,
'AUTH_SALT' => '' ,
'SECURE_AUTH_SALT' => '' ,
'LOGGED_IN_SALT' => '' ,
'NONCE_SALT' => '' ,
);
foreach ( $keys_salts as $c => $v ) {
if ( defined ( $c ) ) {
unset ( $keys_salts [ $c ] );
}
2018-08-17 03:51:36 +02:00
}
2015-09-11 00:01:24 +02:00
2019-05-24 01:35:52 +02:00
if ( ! empty ( $keys_salts ) ) {
$keys_salts_str = '' ;
$from_api = wp_remote_get ( 'https://api.wordpress.org/secret-key/1.1/salt/' );
if ( is_wp_error ( $from_api ) ) {
foreach ( $keys_salts as $c => $v ) {
$keys_salts_str .= " \n define( ' $c ', ' " . wp_generate_password ( 64 , true , true ) . " ' ); " ;
}
} else {
$from_api = explode ( " \n " , wp_remote_retrieve_body ( $from_api ) );
foreach ( $keys_salts as $c => $v ) {
$keys_salts_str .= " \n define( ' $c ', ' " . substr ( array_shift ( $from_api ), 28 , 64 ) . " ' ); " ;
}
2018-08-17 03:51:36 +02:00
}
2019-05-24 01:35:52 +02:00
$num_keys_salts = count ( $keys_salts );
?>
2022-07-21 11:04:14 +02:00
< p id = " network-wpconfig-authentication-description " >
2019-05-24 01:35:52 +02:00
< ? php
2019-12-16 13:37:06 +01:00
if ( 1 === $num_keys_salts ) {
2019-05-24 01:35:52 +02:00
printf (
/* translators: %s: wp-config.php */
__ ( 'This unique authentication key is also missing from your %s file.' ),
'<code>wp-config.php</code>'
);
} else {
printf (
/* translators: %s: wp-config.php */
__ ( 'These unique authentication keys are also missing from your %s file.' ),
'<code>wp-config.php</code>'
);
2018-08-17 03:51:36 +02:00
}
2019-05-24 01:35:52 +02:00
?>
< ? php _e ( 'To make your installation more secure, you should also add:' ); ?>
</ p >
2022-07-21 11:04:14 +02:00
< p class = " configuration-rules-label " >< label for = " network-wpconfig-authentication " >< ? php _e ( 'Network configuration authentication keys' ); ?> </label></p>
< textarea id = " network-wpconfig-authentication " class = " code " readonly = " readonly " cols = " 100 " rows = " <?php echo $num_keys_salts ; ?> " aria - describedby = " network-wpconfig-authentication-description " >< ? php echo esc_textarea ( $keys_salts_str ); ?> </textarea>
2019-05-24 01:35:52 +02:00
< ? php
2018-08-17 03:51:36 +02:00
}
2015-09-11 00:01:24 +02:00
?>
2019-05-24 01:35:52 +02:00
</ li >
2018-08-17 03:51:36 +02:00
< ? php
if ( iis7_supports_permalinks () ) :
2020-01-29 01:35:08 +01:00
// IIS doesn't support RewriteBase, all your RewriteBase are belong to us.
2018-08-17 03:51:36 +02:00
$iis_subdir_match = ltrim ( $base , '/' ) . $subdir_match ;
$iis_rewrite_base = ltrim ( $base , '/' ) . $rewrite_base ;
$iis_subdir_replacement = $subdomain_install ? '' : '{R:1}' ;
2015-09-11 00:01:24 +02:00
2018-08-17 03:51:36 +02:00
$web_config_file = ' < ? xml version = " 1.0 " encoding = " UTF-8 " ?>
2015-09-11 00:01:24 +02:00
< configuration >
< system . webServer >
< rewrite >
< rules >
< rule name = " WordPress Rule 1 " stopProcessing = " true " >
< match url = " ^index \ .php $ " ignoreCase = " false " />
< action type = " None " />
</ rule > ' ;
2018-08-17 03:51:36 +02:00
if ( is_multisite () && get_site_option ( 'ms_files_rewriting' ) ) {
$web_config_file .= '
2015-09-11 00:01:24 +02:00
< rule name = " WordPress Rule for Files " stopProcessing = " true " >
< match url = " ^' . $iis_subdir_match . 'files/(.+) " ignoreCase = " false " />
< action type = " Rewrite " url = " ' . $iis_rewrite_base . WPINC . '/ms-files.php?file= { R:1} " appendQueryString = " false " />
</ rule > ' ;
2018-08-17 03:51:36 +02:00
}
2017-12-01 00:11:00 +01:00
$web_config_file .= '
2015-09-11 00:01:24 +02:00
< rule name = " WordPress Rule 2 " stopProcessing = " true " >
< match url = " ^' . $iis_subdir_match . 'wp-admin $ " ignoreCase = " false " />
< action type = " Redirect " url = " ' . $iis_subdir_replacement . 'wp-admin/ " redirectType = " Permanent " />
</ rule >
< rule name = " WordPress Rule 3 " stopProcessing = " true " >
< match url = " ^ " ignoreCase = " false " />
< conditions logicalGrouping = " MatchAny " >
< add input = " { REQUEST_FILENAME} " matchType = " IsFile " ignoreCase = " false " />
< add input = " { REQUEST_FILENAME} " matchType = " IsDirectory " ignoreCase = " false " />
</ conditions >
< action type = " None " />
</ rule >
< rule name = " WordPress Rule 4 " stopProcessing = " true " >
< match url = " ^' . $iis_subdir_match . '(wp-(content|admin|includes).*) " ignoreCase = " false " />
< action type = " Rewrite " url = " ' . $iis_rewrite_base . ' { R:1} " />
</ rule >
< rule name = " WordPress Rule 5 " stopProcessing = " true " >
< match url = " ^' . $iis_subdir_match . '([_0-9a-zA-Z-]+/)?(.* \ .php) $ " ignoreCase = " false " />
< action type = " Rewrite " url = " ' . $iis_rewrite_base . ' { R:2} " />
</ rule >
< rule name = " WordPress Rule 6 " stopProcessing = " true " >
< match url = " . " ignoreCase = " false " />
< action type = " Rewrite " url = " index.php " />
</ rule >
</ rules >
</ rewrite >
</ system . webServer >
</ configuration >
' ;
2022-07-21 11:04:14 +02:00
echo '<li><p id="network-webconfig-rules-description">' ;
2017-12-01 00:11:00 +01:00
printf (
2019-09-03 02:41:05 +02:00
/* translators: 1: File name (.htaccess or web.config), 2: File path. */
2017-12-01 00:11:00 +01:00
__ ( 'Add the following to your %1$s file in %2$s, <strong>replacing</strong> other WordPress rules:' ),
'<code>web.config</code>' ,
'<code>' . $home_path . '</code>'
);
2018-08-17 03:51:36 +02:00
echo '</p>' ;
2019-12-16 13:37:06 +01:00
if ( ! $subdomain_install && WP_CONTENT_DIR !== ABSPATH . 'wp-content' ) {
2018-08-17 03:51:36 +02:00
echo '<p><strong>' . __ ( 'Warning:' ) . ' ' . __ ( 'Subdirectory networks may not be fully compatible with custom wp-content directories.' ) . '</strong></p>' ;
}
?>
2022-07-21 11:04:14 +02:00
< p class = " configuration-rules-label " >< label for = " network-webconfig-rules " >
< ? php
printf (
/* translators: %s: File name (wp-config.php, .htaccess or web.config). */
__ ( 'Network configuration rules for %s' ),
'<code>web.config</code>'
);
?>
</ label ></ p >
< textarea id = " network-webconfig-rules " class = " code " readonly = " readonly " cols = " 100 " rows = " 20 " aria - describedby = " network-webconfig-rules-description " >< ? php echo esc_textarea ( $web_config_file ); ?> </textarea>
2019-05-24 01:28:53 +02:00
</ li >
</ ol >
2015-09-11 00:01:24 +02:00
2018-08-17 03:51:36 +02:00
< ? php
2020-04-29 16:43:09 +02:00
elseif ( $is_nginx ) : // End iis7_supports_permalinks(). Link to Nginx documentation instead:
echo '<li><p>' ;
printf (
/* translators: %s: Documentation URL. */
__ ( 'It seems your network is running with Nginx web server. <a href="%s">Learn more about further configuration</a>.' ),
2024-03-08 23:38:08 +01:00
__ ( 'https://developer.wordpress.org/advanced-administration/server/web-server/nginx/' )
2020-04-29 16:43:09 +02:00
);
echo '</p></li>' ;
else : // End $is_nginx. Construct an .htaccess file instead:
2015-09-11 00:01:24 +02:00
$ms_files_rewriting = '' ;
2015-10-07 19:11:25 +02:00
if ( is_multisite () && get_site_option ( 'ms_files_rewriting' ) ) {
2017-12-01 00:11:00 +01:00
$ms_files_rewriting = " \n # uploaded files \n RewriteRule ^ " ;
2015-09-11 00:01:24 +02:00
$ms_files_rewriting .= $subdir_match . " files/(.+) { $rewrite_base } " . WPINC . " /ms-files.php?file= { $subdir_replacement_12 } [L] " . " \n " ;
}
$htaccess_file = <<< EOF
RewriteEngine On
2020-11-15 18:46:06 +01:00
RewriteRule .* - [ E = HTTP_AUTHORIZATION :% { HTTP : Authorization }]
2015-09-11 00:01:24 +02:00
RewriteBase { $base }
RewriteRule ^ index\ . php $ - [ L ]
{ $ms_files_rewriting }
# add a trailing slash to /wp-admin
RewriteRule ^ { $subdir_match } wp - admin $ { $subdir_replacement_01 } wp - admin / [ R = 301 , L ]
RewriteCond % { REQUEST_FILENAME } - f [ OR ]
RewriteCond % { REQUEST_FILENAME } - d
RewriteRule ^ - [ L ]
RewriteRule ^ { $subdir_match }( wp - ( content | admin | includes ) .* ) { $rewrite_base }{ $subdir_replacement_12 } [ L ]
RewriteRule ^ { $subdir_match }( .* \ . php ) $ { $rewrite_base } $subdir_replacement_12 [ L ]
RewriteRule . index . php [ L ]
EOF ;
2022-07-21 11:04:14 +02:00
echo '<li><p id="network-htaccess-rules-description">' ;
2015-09-18 20:18:27 +02:00
printf (
2019-09-03 02:41:05 +02:00
/* translators: 1: File name (.htaccess or web.config), 2: File path. */
2015-09-18 20:18:27 +02:00
__ ( 'Add the following to your %1$s file in %2$s, <strong>replacing</strong> other WordPress rules:' ),
'<code>.htaccess</code>' ,
'<code>' . $home_path . '</code>'
);
2015-09-11 00:01:24 +02:00
echo '</p>' ;
2019-12-16 13:37:06 +01:00
if ( ! $subdomain_install && WP_CONTENT_DIR !== ABSPATH . 'wp-content' ) {
2017-10-18 21:50:47 +02:00
echo '<p><strong>' . __ ( 'Warning:' ) . ' ' . __ ( 'Subdirectory networks may not be fully compatible with custom wp-content directories.' ) . '</strong></p>' ;
2017-12-01 00:11:00 +01:00
}
2015-09-11 00:01:24 +02:00
?>
2022-07-21 11:04:14 +02:00
< p class = " configuration-rules-label " >< label for = " network-htaccess-rules " >
< ? php
printf (
/* translators: %s: File name (wp-config.php, .htaccess or web.config). */
__ ( 'Network configuration rules for %s' ),
'<code>.htaccess</code>'
);
?>
</ label ></ p >
< textarea id = " network-htaccess-rules " class = " code " readonly = " readonly " cols = " 100 " rows = " <?php echo substr_count( $htaccess_file , " \n " ) + 1; ?> " aria - describedby = " network-htaccess-rules-description " >< ? php echo esc_textarea ( $htaccess_file ); ?> </textarea>
2019-05-24 01:28:53 +02:00
</ li >
</ ol >
2015-09-11 00:01:24 +02:00
2018-08-17 03:51:36 +02:00
< ? php
2020-04-29 16:43:09 +02:00
endif ; // End IIS/Nginx/Apache code branches.
2015-09-11 00:01:24 +02:00
2017-12-01 00:11:00 +01:00
if ( ! is_multisite () ) {
?>
2015-09-15 19:11:35 +02:00
< 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( wp_login_url() ); ?>"><?php _e( 'Log In' ); ?></a></p>
2018-08-17 03:51:36 +02:00
< ? php
2015-09-11 00:01:24 +02:00
}
2016-06-29 01:24:27 +02:00
}