104 } |
104 } |
105 |
105 |
106 $network_help = '<p>' . __('This screen allows you to configure a network as having subdomains (<code>site1.example.com</code>) or subdirectories (<code>example.com/site1</code>). Subdomains require wildcard subdomains to be enabled in Apache and DNS records, if your host allows it.') . '</p>' . |
106 $network_help = '<p>' . __('This screen allows you to configure a network as having subdomains (<code>site1.example.com</code>) or subdirectories (<code>example.com/site1</code>). Subdomains require wildcard subdomains to be enabled in Apache and DNS records, if your host allows it.') . '</p>' . |
107 '<p>' . __('Choose subdomains or subdirectories; this can only be switched afterwards by reconfiguring your install. Fill out the network details, and click install. If this does not work, you may have to add a wildcard DNS record (for subdomains) or change to another setting in Permalinks (for subdirectories).') . '</p>' . |
107 '<p>' . __('Choose subdomains or subdirectories; this can only be switched afterwards by reconfiguring your install. Fill out the network details, and click install. If this does not work, you may have to add a wildcard DNS record (for subdomains) or change to another setting in Permalinks (for subdirectories).') . '</p>' . |
108 '<p>' . __('The next screen for Network Setup will give you individually-generated lines of code to add to your wp-config.php and .htaccess files. Make sure the settings of your FTP client make files starting with a dot visible, so that you can find .htaccess; you may have to create this file if it really is not there. Make backup copies of those two files.') . '</p>' . |
108 '<p>' . __('The next screen for Network Setup will give you individually-generated lines of code to add to your wp-config.php and .htaccess files. Make sure the settings of your FTP client make files starting with a dot visible, so that you can find .htaccess; you may have to create this file if it really is not there. Make backup copies of those two files.') . '</p>' . |
109 '<p>' . __('Add a <code>blogs.dir</code> directory under <code>/wp-content</code> and add the designated lines of code to wp-config.php (just before <code>/*...stop editing...*/</code>) and <code>.htaccess</code> (replacing the existing WordPress rules).') . '</p>' . |
109 '<p>' . __('Add the designated lines of code to wp-config.php (just before <code>/*...stop editing...*/</code>) and <code>.htaccess</code> (replacing the existing WordPress rules).') . '</p>' . |
110 '<p>' . __('Once you add this code and refresh your browser, multisite should be enabled. This screen, now in the Network Admin navigation menu, will keep an archive of the added code. You can toggle between Network Admin and Site Admin by clicking on the Network Admin or an individual site name under the My Sites dropdown in the Toolbar.') . '</p>' . |
110 '<p>' . __('Once you add this code and refresh your browser, multisite should be enabled. This screen, now in the Network Admin navigation menu, will keep an archive of the added code. You can toggle between Network Admin and Site Admin by clicking on the Network Admin or an individual site name under the My Sites dropdown in the Toolbar.') . '</p>' . |
111 '<p>' . __('The choice of subdirectory sites is disabled if this setup is more than a month old because of permalink problems with “/blog/” from the main site. This disabling will be addressed in a future version.') . '</p>' . |
111 '<p>' . __('The choice of subdirectory sites is disabled if this setup is more than a month old because of permalink problems with “/blog/” from the main site. This disabling will be addressed in a future version.') . '</p>' . |
112 '<p><strong>' . __('For more information:') . '</strong></p>' . |
112 '<p><strong>' . __('For more information:') . '</strong></p>' . |
113 '<p>' . __('<a href="http://codex.wordpress.org/Create_A_Network" target="_blank">Documentation on Creating a Network</a>') . '</p>' . |
113 '<p>' . __('<a href="http://codex.wordpress.org/Create_A_Network" target="_blank">Documentation on Creating a Network</a>') . '</p>' . |
114 '<p>' . __('<a href="http://codex.wordpress.org/Tools_Network_Screen" target="_blank">Documentation on the Network Screen</a>') . '</p>'; |
114 '<p>' . __('<a href="http://codex.wordpress.org/Tools_Network_Screen" target="_blank">Documentation on the Network Screen</a>') . '</p>'; |
342 <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> |
344 <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> |
343 <?php |
345 <?php |
344 } |
346 } |
345 } |
347 } |
346 |
348 |
|
349 $subdir_match = $subdomain_install ? '' : '([_0-9a-zA-Z-]+/)?'; |
|
350 $subdir_replacement_01 = $subdomain_install ? '' : '$1'; |
|
351 $subdir_replacement_12 = $subdomain_install ? '$1' : '$2'; |
|
352 |
347 if ( $_POST || ! is_multisite() ) { |
353 if ( $_POST || ! is_multisite() ) { |
348 ?> |
354 ?> |
349 <h3><?php esc_html_e( 'Enabling the Network' ); ?></h3> |
355 <h3><?php esc_html_e( 'Enabling the Network' ); ?></h3> |
350 <p><?php _e( 'Complete the following steps to enable the features for creating a network of sites.' ); ?></p> |
356 <p><?php _e( 'Complete the following steps to enable the features for creating a network of sites.' ); ?></p> |
351 <div class="updated inline"><p><?php |
357 <div class="updated inline"><p><?php |
352 if ( file_exists( ABSPATH . '.htaccess' ) ) |
358 if ( file_exists( $home_path . '.htaccess' ) ) |
353 printf( __( '<strong>Caution:</strong> We recommend you back up your existing <code>wp-config.php</code> and <code>%s</code> files.' ), '.htaccess' ); |
359 printf( __( '<strong>Caution:</strong> We recommend you back up your existing <code>wp-config.php</code> and <code>%s</code> files.' ), '.htaccess' ); |
354 elseif ( file_exists( ABSPATH . 'web.config' ) ) |
360 elseif ( file_exists( $home_path . 'web.config' ) ) |
355 printf( __( '<strong>Caution:</strong> We recommend you back up your existing <code>wp-config.php</code> and <code>%s</code> files.' ), 'web.config' ); |
361 printf( __( '<strong>Caution:</strong> We recommend you back up your existing <code>wp-config.php</code> and <code>%s</code> files.' ), 'web.config' ); |
356 else |
362 else |
357 _e( '<strong>Caution:</strong> We recommend you back up your existing <code>wp-config.php</code> file.' ); |
363 _e( '<strong>Caution:</strong> We recommend you back up your existing <code>wp-config.php</code> file.' ); |
358 ?></p></div> |
364 ?></p></div> |
359 <?php |
365 <?php |
360 } |
366 } |
361 ?> |
367 ?> |
362 <ol> |
368 <ol> |
363 <li><p><?php |
369 <li><p><?php printf( __( 'Add the following to your <code>wp-config.php</code> file in <code>%s</code> <strong>above</strong> the line reading <code>/* That’s all, stop editing! Happy blogging. */</code>:' ), $location_of_wp_config ); ?></p> |
364 printf( __( 'Create a <code>blogs.dir</code> directory at <code>%s/blogs.dir</code>. This directory is used to store uploaded media for your additional sites and must be writeable by the web server.' ), WP_CONTENT_DIR ); |
370 <textarea class="code" readonly="readonly" cols="100" rows="6"> |
365 if ( WP_CONTENT_DIR != ABSPATH . 'wp-content' ) |
|
366 echo ' <strong>' . __('Warning:') . ' ' . __( 'Networks may not be fully compatible with custom wp-content directories.' ) . '</strong>'; |
|
367 ?></p></li> |
|
368 <li><p><?php printf( __( 'Add the following to your <code>wp-config.php</code> file in <code>%s</code> <strong>above</strong> the line reading <code>/* That’s all, stop editing! Happy blogging. */</code>:' ), ABSPATH ); ?></p> |
|
369 <textarea class="code" readonly="readonly" cols="100" rows="7"> |
|
370 define('MULTISITE', true); |
371 define('MULTISITE', true); |
371 define('SUBDOMAIN_INSTALL', <?php echo $subdomain_install ? 'true' : 'false'; ?>); |
372 define('SUBDOMAIN_INSTALL', <?php echo $subdomain_install ? 'true' : 'false'; ?>); |
372 $base = '<?php echo $base; ?>'; |
|
373 define('DOMAIN_CURRENT_SITE', '<?php echo $hostname; ?>'); |
373 define('DOMAIN_CURRENT_SITE', '<?php echo $hostname; ?>'); |
374 define('PATH_CURRENT_SITE', '<?php echo $base; ?>'); |
374 define('PATH_CURRENT_SITE', '<?php echo $base; ?>'); |
375 define('SITE_ID_CURRENT_SITE', 1); |
375 define('SITE_ID_CURRENT_SITE', 1); |
376 define('BLOG_ID_CURRENT_SITE', 1);</textarea> |
376 define('BLOG_ID_CURRENT_SITE', 1); |
|
377 </textarea> |
377 <?php |
378 <?php |
378 $keys_salts = array( 'AUTH_KEY' => '', 'SECURE_AUTH_KEY' => '', 'LOGGED_IN_KEY' => '', 'NONCE_KEY' => '', 'AUTH_SALT' => '', 'SECURE_AUTH_SALT' => '', 'LOGGED_IN_SALT' => '', 'NONCE_SALT' => '' ); |
379 $keys_salts = array( 'AUTH_KEY' => '', 'SECURE_AUTH_KEY' => '', 'LOGGED_IN_KEY' => '', 'NONCE_KEY' => '', 'AUTH_SALT' => '', 'SECURE_AUTH_SALT' => '', 'LOGGED_IN_SALT' => '', 'NONCE_SALT' => '' ); |
379 foreach ( $keys_salts as $c => $v ) { |
380 foreach ( $keys_salts as $c => $v ) { |
380 if ( defined( $c ) ) |
381 if ( defined( $c ) ) |
381 unset( $keys_salts[ $c ] ); |
382 unset( $keys_salts[ $c ] ); |
382 } |
383 } |
|
384 |
383 if ( ! empty( $keys_salts ) ) { |
385 if ( ! empty( $keys_salts ) ) { |
384 $keys_salts_str = ''; |
386 $keys_salts_str = ''; |
385 $from_api = wp_remote_get( 'https://api.wordpress.org/secret-key/1.1/salt/' ); |
387 $from_api = wp_remote_get( 'https://api.wordpress.org/secret-key/1.1/salt/' ); |
386 if ( is_wp_error( $from_api ) ) { |
388 if ( is_wp_error( $from_api ) ) { |
387 foreach ( $keys_salts as $c => $v ) { |
389 foreach ( $keys_salts as $c => $v ) { |
402 } |
404 } |
403 ?> |
405 ?> |
404 </li> |
406 </li> |
405 <?php |
407 <?php |
406 if ( iis7_supports_permalinks() ) : |
408 if ( iis7_supports_permalinks() ) : |
407 |
409 // IIS doesn't support RewriteBase, all your RewriteBase are belong to us |
408 if ( $subdomain_install ) { |
410 $iis_subdir_match = ltrim( $base, '/' ) . $subdir_match; |
409 $web_config_file = |
411 $iis_rewrite_base = ltrim( $base, '/' ) . $rewrite_base; |
410 '<?xml version="1.0" encoding="UTF-8"?> |
412 $iis_subdir_replacement = $subdomain_install ? '' : '{R:1}'; |
|
413 |
|
414 $web_config_file = <<<EOF |
|
415 <?xml version="1.0" encoding="UTF-8"?> |
411 <configuration> |
416 <configuration> |
412 <system.webServer> |
417 <system.webServer> |
413 <rewrite> |
418 <rewrite> |
414 <rules> |
419 <rules> |
415 <rule name="WordPress Rule 1" stopProcessing="true"> |
420 <rule name="WordPress Rule 1" stopProcessing="true"> |
416 <match url="^index\.php$" ignoreCase="false" /> |
421 <match url="^index\.php$" ignoreCase="false" /> |
417 <action type="None" /> |
422 <action type="None" /> |
418 </rule> |
423 </rule>'; |
|
424 if ( is_multisite() && get_site_option( 'ms_files_rewriting' ) ) { |
|
425 $web_config_file .= ' |
|
426 <rule name="WordPress Rule for Files" stopProcessing="true"> |
|
427 <match url="^{$iis_subdir_match}files/(.+)" ignoreCase="false" /> |
|
428 <action type="Rewrite" url="{$iis_rewrite_base}wp-includes/ms-files.php?file={R:1}" appendQueryString="false" /> |
|
429 </rule>'; |
|
430 } |
|
431 $web_config_file .= ' |
419 <rule name="WordPress Rule 2" stopProcessing="true"> |
432 <rule name="WordPress Rule 2" stopProcessing="true"> |
420 <match url="^files/(.+)" ignoreCase="false" /> |
433 <match url="^{$iis_subdir_match}wp-admin$" ignoreCase="false" /> |
421 <action type="Rewrite" url="wp-includes/ms-files.php?file={R:1}" appendQueryString="false" /> |
434 <action type="Redirect" url="{$iis_subdir_replacement}wp-admin/" redirectType="Permanent" /> |
422 </rule> |
435 </rule> |
423 <rule name="WordPress Rule 3" stopProcessing="true"> |
436 <rule name="WordPress Rule 3" stopProcessing="true"> |
424 <match url="^" ignoreCase="false" /> |
437 <match url="^" ignoreCase="false" /> |
425 <conditions logicalGrouping="MatchAny"> |
438 <conditions logicalGrouping="MatchAny"> |
426 <add input="{REQUEST_FILENAME}" matchType="IsFile" ignoreCase="false" /> |
439 <add input="{REQUEST_FILENAME}" matchType="IsFile" ignoreCase="false" /> |
427 <add input="{REQUEST_FILENAME}" matchType="IsDirectory" ignoreCase="false" /> |
440 <add input="{REQUEST_FILENAME}" matchType="IsDirectory" ignoreCase="false" /> |
428 </conditions> |
441 </conditions> |
429 <action type="None" /> |
442 <action type="None" /> |
430 </rule> |
443 </rule> |
431 <rule name="WordPress Rule 4" stopProcessing="true"> |
444 <rule name="WordPress Rule 4" stopProcessing="true"> |
|
445 <match url="^{$iis_subdir_match}(wp-(content|admin|includes).*)" ignoreCase="false" /> |
|
446 <action type="Rewrite" url="{$iis_rewrite_base}{R:1}" /> |
|
447 </rule> |
|
448 <rule name="WordPress Rule 5" stopProcessing="true"> |
|
449 <match url="^{$iis_subdir_match}([_0-9a-zA-Z-]+/)?(.*\.php)$" ignoreCase="false" /> |
|
450 <action type="Rewrite" url="{$iis_rewrite_base}{R:2}" /> |
|
451 </rule> |
|
452 <rule name="WordPress Rule 6" stopProcessing="true"> |
432 <match url="." ignoreCase="false" /> |
453 <match url="." ignoreCase="false" /> |
433 <action type="Rewrite" url="index.php" /> |
454 <action type="Rewrite" url="index.php" /> |
434 </rule> |
455 </rule> |
435 </rules> |
456 </rules> |
436 </rewrite> |
457 </rewrite> |
437 </system.webServer> |
458 </system.webServer> |
438 </configuration>'; |
459 </configuration> |
439 } else { |
460 EOF; |
440 $web_config_file = |
461 |
441 '<?xml version="1.0" encoding="UTF-8"?> |
|
442 <configuration> |
|
443 <system.webServer> |
|
444 <rewrite> |
|
445 <rules> |
|
446 <rule name="WordPress Rule 1" stopProcessing="true"> |
|
447 <match url="^index\.php$" ignoreCase="false" /> |
|
448 <action type="None" /> |
|
449 </rule> |
|
450 <rule name="WordPress Rule 2" stopProcessing="true"> |
|
451 <match url="^([_0-9a-zA-Z-]+/)?files/(.+)" ignoreCase="false" /> |
|
452 <action type="Rewrite" url="wp-includes/ms-files.php?file={R:2}" appendQueryString="false" /> |
|
453 </rule> |
|
454 <rule name="WordPress Rule 3" stopProcessing="true"> |
|
455 <match url="^([_0-9a-zA-Z-]+/)?wp-admin$" ignoreCase="false" /> |
|
456 <action type="Redirect" url="{R:1}wp-admin/" redirectType="Permanent" /> |
|
457 </rule> |
|
458 <rule name="WordPress Rule 4" stopProcessing="true"> |
|
459 <match url="^" ignoreCase="false" /> |
|
460 <conditions logicalGrouping="MatchAny"> |
|
461 <add input="{REQUEST_FILENAME}" matchType="IsFile" ignoreCase="false" /> |
|
462 <add input="{REQUEST_FILENAME}" matchType="IsDirectory" ignoreCase="false" /> |
|
463 </conditions> |
|
464 <action type="None" /> |
|
465 </rule> |
|
466 <rule name="WordPress Rule 5" stopProcessing="true"> |
|
467 <match url="^[_0-9a-zA-Z-]+/(wp-(content|admin|includes).*)" ignoreCase="false" /> |
|
468 <action type="Rewrite" url="{R:1}" /> |
|
469 </rule> |
|
470 <rule name="WordPress Rule 6" stopProcessing="true"> |
|
471 <match url="^([_0-9a-zA-Z-]+/)?(.*\.php)$" ignoreCase="false" /> |
|
472 <action type="Rewrite" url="{R:2}" /> |
|
473 </rule> |
|
474 <rule name="WordPress Rule 7" stopProcessing="true"> |
|
475 <match url="." ignoreCase="false" /> |
|
476 <action type="Rewrite" url="index.php" /> |
|
477 </rule> |
|
478 </rules> |
|
479 </rewrite> |
|
480 </system.webServer> |
|
481 </configuration>'; |
|
482 } |
|
483 ?> |
462 ?> |
484 <li><p><?php printf( __( 'Add the following to your <code>web.config</code> file in <code>%s</code>, replacing other WordPress rules:' ), ABSPATH ); ?></p> |
463 <li><p><?php printf( __( 'Add the following to your <code>web.config</code> file in <code>%s</code>, replacing other WordPress rules:' ), $home_path ); ?></p> |
485 <textarea class="code" readonly="readonly" cols="100" rows="20"> |
464 <?php |
486 <?php echo esc_textarea( $web_config_file ); ?> |
465 if ( ! $subdomain_install && WP_CONTENT_DIR != ABSPATH . 'wp-content' ) |
|
466 echo '<p><strong>' . __('Warning:') . ' ' . __( 'Subdirectory networks may not be fully compatible with custom wp-content directories.' ) . '</strong></p>'; |
|
467 ?> |
|
468 <textarea class="code" readonly="readonly" cols="100" rows="20"><?php echo esc_textarea( $web_config_file ); ?> |
487 </textarea></li> |
469 </textarea></li> |
488 </ol> |
470 </ol> |
489 |
471 |
490 <?php else : // end iis7_supports_permalinks(). construct an htaccess file instead: |
472 <?php else : // end iis7_supports_permalinks(). construct an htaccess file instead: |
491 |
473 |
492 $htaccess_file = 'RewriteEngine On |
474 $ms_files_rewriting = ''; |
493 RewriteBase ' . $base . ' |
475 if ( is_multisite() && get_site_option( 'ms_files_rewriting' ) ) { |
|
476 $ms_files_rewriting = "\n# uploaded files\nRewriteRule ^"; |
|
477 $ms_files_rewriting .= $subdir_match . "files/(.+) {$rewrite_base}wp-includes/ms-files.php?file={$subdir_replacement_12} [L]" . "\n"; |
|
478 } |
|
479 |
|
480 $htaccess_file = <<<EOF |
|
481 RewriteEngine On |
|
482 RewriteBase {$base} |
494 RewriteRule ^index\.php$ - [L] |
483 RewriteRule ^index\.php$ - [L] |
495 |
484 {$ms_files_rewriting} |
496 # uploaded files |
485 # add a trailing slash to /wp-admin |
497 RewriteRule ^' . ( $subdomain_install ? '' : '([_0-9a-zA-Z-]+/)?' ) . 'files/(.+) wp-includes/ms-files.php?file=$' . ( $subdomain_install ? 1 : 2 ) . ' [L]' . "\n"; |
486 RewriteRule ^{$subdir_match}wp-admin$ {$subdir_replacement_01}wp-admin/ [R=301,L] |
498 |
487 |
499 if ( ! $subdomain_install ) |
488 RewriteCond %{REQUEST_FILENAME} -f [OR] |
500 $htaccess_file .= "\n# add a trailing slash to /wp-admin\n" . 'RewriteRule ^([_0-9a-zA-Z-]+/)?wp-admin$ $1wp-admin/ [R=301,L]' . "\n"; |
|
501 |
|
502 $htaccess_file .= "\n" . 'RewriteCond %{REQUEST_FILENAME} -f [OR] |
|
503 RewriteCond %{REQUEST_FILENAME} -d |
489 RewriteCond %{REQUEST_FILENAME} -d |
504 RewriteRule ^ - [L]'; |
490 RewriteRule ^ - [L] |
505 |
491 RewriteRule ^{$subdir_match}(wp-(content|admin|includes).*) {$rewrite_base}{$subdir_replacement_12} [L] |
506 // @todo custom content dir. |
492 RewriteRule ^{$subdir_match}(.*\.php)$ {$rewrite_base}$subdir_replacement_12 [L] |
507 if ( ! $subdomain_install ) |
493 RewriteRule . index.php [L] |
508 $htaccess_file .= "\nRewriteRule ^[_0-9a-zA-Z-]+/(wp-(content|admin|includes).*) $1 [L]\nRewriteRule ^[_0-9a-zA-Z-]+/(.*\.php)$ $1 [L]"; |
494 EOF; |
509 |
|
510 $htaccess_file .= "\nRewriteRule . index.php [L]"; |
|
511 |
495 |
512 ?> |
496 ?> |
513 <li><p><?php printf( __( 'Add the following to your <code>.htaccess</code> file in <code>%s</code>, replacing other WordPress rules:' ), ABSPATH ); ?></p> |
497 <li><p><?php printf( __( 'Add the following to your <code>.htaccess</code> file in <code>%s</code>, replacing other WordPress rules:' ), $home_path ); ?></p> |
514 <textarea class="code" readonly="readonly" cols="100" rows="<?php echo $subdomain_install ? 11 : 16; ?>"> |
498 <?php |
|
499 if ( ! $subdomain_install && WP_CONTENT_DIR != ABSPATH . 'wp-content' ) |
|
500 echo '<p><strong>' . __('Warning:') . ' ' . __( 'Subdirectory networks may not be fully compatible with custom wp-content directories.' ) . '</strong></p>'; |
|
501 ?> |
|
502 <textarea class="code" readonly="readonly" cols="100" rows="<?php echo substr_count( $htaccess_file, "\n" ) + 1; ?>"> |
515 <?php echo esc_textarea( $htaccess_file ); ?></textarea></li> |
503 <?php echo esc_textarea( $htaccess_file ); ?></textarea></li> |
516 </ol> |
504 </ol> |
517 |
505 |
518 <?php endif; // end IIS/Apache code branches. |
506 <?php endif; // end IIS/Apache code branches. |
519 |
507 |