[ Index ]

PHP Cross Reference of WordPress Trunk (Updated Daily)

title

Body

[close]

/wp-admin/includes/ -> network.php (source)

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


Generated: Fri Oct 25 08:20:01 2019 Cross-referenced by PHPXref 0.7