prepare( 'SHOW TABLES LIKE %s', $wpdb->esc_like( $wpdb->site ) ); if ( $wpdb->get_var( $sql ) ) { // phpcs:ignore WordPress.DB.PreparedSQL.NotPrepared return $wpdb->get_var( "SELECT domain FROM $wpdb->site ORDER BY id ASC LIMIT 1" ); } return false; } /** * Allow subdomain installation * * @since 3.0.0 * @return bool Whether subdomain installation is allowed */ function allow_subdomain_install() { $domain = preg_replace( '|https?://([^/]+)|', '$1', get_option( 'home' ) ); if ( parse_url( get_option( 'home' ), PHP_URL_PATH ) || 'localhost' === $domain || preg_match( '|^[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+$|', $domain ) ) { return false; } return true; } /** * Allow subdirectory installation. * * @since 3.0.0 * * @global wpdb $wpdb WordPress database abstraction object. * * @return bool Whether subdirectory installation is allowed */ function allow_subdirectory_install() { global $wpdb; /** * 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. */ if ( apply_filters( 'allow_subdirectory_install', false ) ) { return true; } if ( defined( 'ALLOW_SUBDIRECTORY_INSTALL' ) && ALLOW_SUBDIRECTORY_INSTALL ) { return true; } $post = $wpdb->get_row( "SELECT ID FROM $wpdb->posts WHERE post_date < DATE_SUB(NOW(), INTERVAL 1 MONTH) AND post_status = 'publish'" ); if ( empty( $post ) ) { return true; } return false; } /** * Get base domain of network. * * @since 3.0.0 * @return string Base domain. */ function get_clean_basedomain() { $existing_domain = network_domain_check(); if ( $existing_domain ) { return $existing_domain; } $domain = preg_replace( '|https?://|', '', get_option( 'siteurl' ) ); $slash = strpos( $domain, '/' ); if ( $slash ) { $domain = substr( $domain, 0, $slash ); } return $domain; } /** * Prints step 1 for Network installation process. * * @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. * * @since 3.0.0 * * @global bool $is_apache * * @param false|WP_Error $errors Optional. Error object. Default false. */ function network_step1( $errors = false ) { if ( defined( 'DO_NOT_UPGRADE_GLOBAL_TABLES' ) ) { echo '
' . esc_html__( 'Error:' ) . ' ' . sprintf(
/* translators: %s: DO_NOT_UPGRADE_GLOBAL_TABLES */
esc_html__( 'The constant %s cannot be defined when creating a network.' ),
'DO_NOT_UPGRADE_GLOBAL_TABLES'
) . '
' . esc_html__( 'Warning:' ) . ' ' . sprintf( /* translators: %s: URL to Plugins screen. */ wp_kses_post( __( 'Please deactivate your plugins before enabling the Network feature.' ) ), esc_url_raw( admin_url( 'plugins.php?plugin_status=active' ) ) ) . '
' . esc_html__( 'Once the network is created, you may reactivate your plugins.' ) . '
'; echo ''; require_once ABSPATH . 'wp-admin/admin-footer.php'; die(); } $hostname = get_clean_basedomain(); $has_ports = strstr( $hostname, ':' ); if ( ( false !== $has_ports && ! in_array( $has_ports, [ ':80', ':443' ], true ) ) ) { echo '' . esc_html__( 'Error:' ) . ' ' . esc_html__( 'You cannot install a network of sites with your server address.' ) . '
' . sprintf(
/* translators: %s: Port number. */
esc_html__( 'You cannot use port numbers such as %s.' ),
'' . $has_ports . '' // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
) . '
' . esc_html__( 'Caution:' ) . ' ';
printf(
/* translators: 1: wp-config.php, 2: web.config */
esc_html__( 'You should back up your existing %1$s and %2$s files.' ),
'' . $config_filename . '', // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
'web.config'
);
} else {
echo '' . esc_html__( 'Caution:' ) . ' ';
printf(
/* translators: %s: wp-config.php */
esc_html__( 'You should back up your existing %s file.' ),
'' . $config_filename . '', // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
);
}
?>
above the line reading %3$s:' ),
'' . $config_filename . '', // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
'' . $location_of_wp_config . '', // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
// 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//* ' . esc_html__( 'That’s all, stop editing! Happy publishing.' ) . ' */'
);
?>
' . $config_filename . '', // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
);
} else {
printf(
/* translators: %s: wp-config.php */
esc_html__( 'These unique authentication keys are also missing from your %s file.' ),
'' . $config_filename . '', // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
);
}
?>
';
printf(
/* translators: 1: File name (.htaccess or web.config), 2: File path. */
wp_kses_post( __( 'Add the following to your %1$s file in %2$s, replacing other WordPress rules:' ) ),
'web.config',
'' . $home_path . '' // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
);
echo '
' . esc_html__( 'Warning:' ) . ' ' . esc_html__( 'Subdirectory networks may not be fully compatible with custom wp-content directories.' ) . '
'; } ?>'; printf( /* translators: %s: Documentation URL. */ wp_kses_post( __( 'It seems your network is running with Nginx web server. Learn more about further configuration.' ) ), 'https://wordpress.org/support/article/nginx/' ); echo '
'; else : // End $is_nginx. Construct an .htaccess file instead. $ms_files_rewriting = ''; if ( is_multisite() && get_site_option( 'ms_files_rewriting' ) ) { $ms_files_rewriting = "\n# uploaded files\nRewriteRule ^"; $ms_files_rewriting .= $subdir_match . "files/(.+) {$rewrite_base}" . WPINC . "/ms-files.php?file={$subdir_replacement_12} [L]" . "\n"; // phpcs:ignore Generic.Strings.UnnecessaryStringConcat.Found } $htaccess_file = <<';
printf(
/* translators: 1: File name (.htaccess or web.config), 2: File path. */
wp_kses_post( __( 'Add the following to your %1$s file in %2$s, replacing other WordPress rules:' ) ),
'.htaccess',
'' . $home_path . '' // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
);
echo '
' . esc_html__( 'Warning:' ) . ' ' . esc_html__( 'Subdirectory networks may not be fully compatible with custom wp-content directories.' ) . '
'; } ?>