network_step2

函数


network_step2 ( $errors = false )
参数
  • (false|WP_Error)
    $errors
    Optional. Error object. Default false.
    Required:
    Default: false
定义位置
  • wp-admin/includes/network.php
    , line 389
引入
3.0.0
弃用

打印网络安装过程的步骤2。

function network_step2( $errors = false ) {
	global $wpdb, $is_nginx;

	$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 );
	$home_path         = 0 === strpos( $abspath_fix, $document_root_fix ) ? $document_root_fix . $base : get_home_path();
	$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.
	if ( is_wp_error( $errors ) ) {
		echo '
' . $errors->get_error_message() . '
'; } if ( $_POST ) { if ( allow_subdomain_install() ) { $subdomain_install = allow_subdirectory_install() ? ! empty( $_POST['subdomain_install'] ) : true; } else { $subdomain_install = false; } } else { if ( is_multisite() ) { $subdomain_install = is_subdomain_install(); ?>

get_var( "SELECT meta_value FROM $wpdb->sitemeta WHERE site_id = 1 AND meta_key = 'subdomain_install'" ); ?>

<?php if ( file_exists( $home_path . '.htaccess' ) ) { echo '' . __( 'Caution:' ) . ' '; printf( /* translators: 1: wp-config.php, 2: .htaccess */ __( 'You should back up your existing %1$s and %2$s files.' ), 'wp-config.php', '.htaccess' ); } elseif ( file_exists( $home_path . 'web.config' ) ) { echo '' . __( 'Caution:' ) . ' '; printf( /* translators: 1: wp-config.php, 2: web.config */ __( 'You should back up your existing %1$s and %2$s files.' ), 'wp-config.php', 'web.config' ); } else { echo '' . __( 'Caution:' ) . ' '; printf( /* translators: %s: wp-config.php */ __( 'You should back up your existing %s file.' ), 'wp-config.php' ); } ?>

  1. <?php printf( /* translators: 1: wp-config.php, 2: Location of wp-config file, 3: Translated version of "That's all, stop editing! Happy publishing." */ __( 'Add the following to your %1$s file in %2$s above the line reading %3$s:' ), 'wp-config.php', '' . $location_of_wp_config . '', /* * 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//branches//dist/wp-config-sample.php */ '/* ' . __( 'That’s all, stop editing! Happy publishing.' ) . ' */' ); ?>

    '', '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 ] ); } } 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 .= "ndefine( '$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 .= "ndefine( '$c', '" . substr( array_shift( $from_api ), 28, 64 ) . "' );"; } } $num_keys_salts = count( $keys_salts ); ?>

    <?php if ( 1 === $num_keys_salts ) { printf( /* translators: %s: wp-config.php */ __( 'This unique authentication key is also missing from your %s file.' ), 'wp-config.php' ); } else { printf( /* translators: %s: wp-config.php */ __( 'These unique authentication keys are also missing from your %s file.' ), 'wp-config.php' ); } ?>

  2. <?php if ( iis7_supports_permalinks() ) : // IIS doesn't support RewriteBase, all your RewriteBase are belong to us. $iis_subdir_match = ltrim( $base, '/' ) . $subdir_match; $iis_rewrite_base = ltrim( $base, '/' ) . $rewrite_base; $iis_subdir_replacement = $subdomain_install ? '' : '{R:1}'; $web_config_file = ''; if ( is_multisite() && get_site_option( 'ms_files_rewriting' ) ) { $web_config_file .= ' '; } $web_config_file .= ' '; echo '
  3. '; printf( /* translators: 1: File name (.htaccess or web.config), 2: File path. */ __( 'Add the following to your %1$s file in %2$s, replacing other WordPress rules:' ), 'web.config', '' . $home_path . '' ); echo '

    '; if ( ! $subdomain_install && WP_CONTENT_DIR !== ABSPATH . 'wp-content' ) { echo '

    ' . __( 'Warning:' ) . ' ' . __( 'Subdirectory networks may not be fully compatible with custom wp-content directories.' ) . '

    '; } ?>

<?php elseif ( $is_nginx ) : // End iis7_supports_permalinks(). Link to Nginx documentation instead: echo '
  • '; printf( /* translators: %s: Documentation URL. */ __( '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 filesnRewriteRule ^"; $ms_files_rewriting .= $subdir_match . "files/(.+) {$rewrite_base}" . WPINC . "/ms-files.php?file={$subdir_replacement_12} [L]" . "n"; } $htaccess_file =

    '; printf( /* translators: 1: File name (.htaccess or web.config), 2: File path. */ __( 'Add the following to your %1$s file in %2$s, replacing other WordPress rules:' ), '.htaccess', '' . $home_path . '' ); echo '

    '; if ( ! $subdomain_install && WP_CONTENT_DIR !== ABSPATH . 'wp-content' ) { echo '

    ' . __( 'Warning:' ) . ' ' . __( 'Subdirectory networks may not be fully compatible with custom wp-content directories.' ) . '

    '; } ?>

    <?php } }