network_step1

Prints step 1 for Network installation process.

Description

network_step1( (bool) $errors = false ); 

Parameters (1)

0. $errors — Optional. (bool) => false
The errors.

Usage

  1. if ( !function_exists( 'network_step1' ) ) { 
  2. require_once ABSPATH . '/wp-admin/includes/network.php'; 
  3.  
  4. // The errors. 
  5. $errors = false; 
  6.  
  7. // NOTICE! Understand what this does before running. 
  8. $result = network_step1($errors); 
  9.  

Defined (1)

The function is defined in the following location(s).

/wp-admin/includes/network.php  
  1. function network_step1( $errors = false ) { 
  2. global $is_apache; 
  3.  
  4. if ( defined('DO_NOT_UPGRADE_GLOBAL_TABLES') ) { 
  5. echo '<div class="error"><p><strong>' . __(ERROR') . '</strong> ' . __( 'The constant DO_NOT_UPGRADE_GLOBAL_TABLES cannot be defined when creating a network.' ) . '</p></div>'; 
  6. echo '</div>'; 
  7. include( ABSPATH . 'wp-admin/admin-footer.php' ); 
  8. die(); 
  9.  
  10. $active_plugins = get_option( 'active_plugins' ); 
  11. if ( ! empty( $active_plugins ) ) { 
  12. echo '<div class="updated"><p><strong>' . __('Warning:') . '</strong> ' . sprintf( __( 'Please <a href="%s">deactivate your plugins</a> before enabling the Network feature.' ), admin_url( 'plugins.php?plugin_status=active' ) ) . '</p></div><p>' . __( 'Once the network is created, you may reactivate your plugins.' ) . '</p>'; 
  13. echo '</div>'; 
  14. include( ABSPATH . 'wp-admin/admin-footer.php' ); 
  15. die(); 
  16.  
  17. $hostname = get_clean_basedomain(); 
  18. $has_ports = strstr( $hostname, ':' ); 
  19. if ( ( false !== $has_ports && ! in_array( $has_ports, array( ':80', ':443' ) ) ) ) { 
  20. echo '<div class="error"><p><strong>' . __( ERROR') . '</strong> ' . __( 'You cannot install a network of sites with your server address.' ) . '</p></div>'; 
  21. echo '<p>' . sprintf( 
  22. /** translators: %s: port number */ 
  23. __( 'You cannot use port numbers such as %s.' ),  
  24. '<code>' . $has_ports . '</code>' 
  25. ) . '</p>'; 
  26. echo '<a href="' . esc_url( admin_url() ) . '">' . __( 'Return to Dashboard' ) . '</a>'; 
  27. echo '</div>'; 
  28. include( ABSPATH . 'wp-admin/admin-footer.php' ); 
  29. die(); 
  30.  
  31. echo '<form method="post">'; 
  32.  
  33. wp_nonce_field( 'install-network-1' ); 
  34.  
  35. $error_codes = array(); 
  36. if ( is_wp_error( $errors ) ) { 
  37. echo '<div class="error"><p><strong>' . __( ERROR The network could not be created.' ) . '</strong></p>'; 
  38. foreach ( $errors->get_error_messages() as $error ) 
  39. echo "<p>$error</p>"; 
  40. echo '</div>'; 
  41. $error_codes = $errors->get_error_codes(); 
  42.  
  43. if ( ! empty( $_POST['sitename'] ) && ! in_array( 'empty_sitename', $error_codes ) ) { 
  44. $site_name = $_POST['sitename']; 
  45. } else { 
  46. /** translators: %s: Default network name */ 
  47. $site_name = sprintf( __( '%s Sites' ), get_option( 'blogname' ) ); 
  48.  
  49. if ( ! empty( $_POST['email'] ) && ! in_array( 'invalid_email', $error_codes ) ) { 
  50. $admin_email = $_POST['email']; 
  51. } else { 
  52. $admin_email = get_option( 'admin_email' ); 
  53. ?> 
  54. <p><?php _e( 'Welcome to the Network installation process!' ); ?></p> 
  55. <p><?php _e( 'Fill in the information below and you’ll be on your way to creating a network of WordPress sites. We will create configuration files in the next step.' ); ?></p> 
  56. <?php 
  57.  
  58. if ( isset( $_POST['subdomain_install'] ) ) { 
  59. $subdomain_install = (bool) $_POST['subdomain_install']; 
  60. } elseif ( apache_mod_loaded('mod_rewrite') ) { // assume nothing 
  61. $subdomain_install = true; 
  62. } elseif ( !allow_subdirectory_install() ) { 
  63. $subdomain_install = true; 
  64. } else { 
  65. $subdomain_install = false; 
  66. if ( $got_mod_rewrite = got_mod_rewrite() ) { // dangerous assumptions 
  67. echo '<div class="updated inline"><p><strong>' . __( 'Note:' ) . '</strong> '; 
  68. /** translators: %s: mod_rewrite */ 
  69. printf( __( 'Please make sure the Apache %s module is installed as it will be used at the end of this installation.' ),  
  70. '<code>mod_rewrite</code>' 
  71. ); 
  72. echo '</p>'; 
  73. } elseif ( $is_apache ) { 
  74. echo '<div class="error inline"><p><strong>' . __( 'Warning!' ) . '</strong> '; 
  75. /** translators: %s: mod_rewrite */ 
  76. printf( __( 'It looks like the Apache %s module is not installed.' ),  
  77. '<code>mod_rewrite</code>' 
  78. ); 
  79. echo '</p>'; 
  80.  
  81. if ( $got_mod_rewrite || $is_apache ) { // Protect against mod_rewrite mimicry (but ! Apache) 
  82. echo '<p>'; 
  83. /** translators: 1: mod_rewrite, 2: mod_rewrite documentation URL, 3: Google search for mod_rewrite */ 
  84. printf( __( '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.' ),  
  85. '<code>mod_rewrite</code>',  
  86. 'https://httpd.apache.org/docs/mod/mod_rewrite.html',  
  87. 'https://www.google.com/search?q=apache+mod_rewrite' 
  88. ); 
  89. echo '</p></div>'; 
  90.  
  91. <h3><?php esc_html_e( 'Addresses of Sites in your Network' ); ?></h3> 
  92. <p><?php _e( 'Please choose whether you would like sites in your WordPress network to use sub-domains or sub-directories.' ); ?> 
  93. <strong><?php _e( 'You cannot change this later.' ); ?></strong></p> 
  94. <p><?php _e( 'You will need a wildcard DNS record if you are going to use the virtual host (sub-domain) functionality.' ); ?></p> 
  95. <?php // @todo: Link to an MS readme? ?> 
  96. <table class="form-table"> 
  97. <tr> 
  98. <th><label><input type="radio" name="subdomain_install" value="1"<?php checked( $subdomain_install ); ?> /> <?php _e( 'Sub-domains' ); ?></label></th> 
  99. <td><?php printf( 
  100. /** translators: 1: hostname */ 
  101. _x( 'like <code>site1.%1$s</code> and <code>site2.%1$s</code>', 'subdomain examples' ),  
  102. $hostname 
  103. ); ?></td> 
  104. </tr> 
  105. <tr> 
  106. <th><label><input type="radio" name="subdomain_install" value="0"<?php checked( ! $subdomain_install ); ?> /> <?php _e( 'Sub-directories' ); ?></label></th> 
  107. <td><?php printf( 
  108. /** translators: 1: hostname */ 
  109. _x( 'like <code>%1$s/site1</code> and <code>%1$s/site2</code>', 'subdirectory examples' ),  
  110. $hostname 
  111. ); ?></td> 
  112. </tr> 
  113. </table> 
  114.  
  115. <?php 
  116. endif; 
  117.  
  118. if ( WP_CONTENT_DIR != ABSPATH . 'wp-content' && ( allow_subdirectory_install() || ! allow_subdomain_install() ) ) 
  119. echo '<div class="error inline"><p><strong>' . __('Warning!') . '</strong> ' . __( 'Subdirectory networks may not be fully compatible with custom wp-content directories.' ) . '</p></div>'; 
  120.  
  121. $is_www = ( 0 === strpos( $hostname, 'www.' ) ); 
  122. if ( $is_www ) : 
  123. ?> 
  124. <h3><?php esc_html_e( 'Server Address' ); ?></h3> 
  125. <p><?php printf( 
  126. /** translators: 1: site url 2: host name 3. www */ 
  127. __( '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.' ),  
  128. '<code>' . substr( $hostname, 4 ) . '</code>',  
  129. '<code>' . $hostname . '</code>',  
  130. '<code>www</code>' 
  131. ); ?></p> 
  132. <table class="form-table"> 
  133. <tr> 
  134. <th scope='row'><?php esc_html_e( 'Server Address' ); ?></th> 
  135. <td> 
  136. <?php printf( 
  137. /** translators: %s: host name */ 
  138. __( 'The internet address of your network will be %s.' ),  
  139. '<code>' . $hostname . '</code>' 
  140. ); ?> 
  141. </td> 
  142. </tr> 
  143. </table> 
  144. <?php endif; ?> 
  145.  
  146. <h3><?php esc_html_e( 'Network Details' ); ?></h3> 
  147. <table class="form-table"> 
  148. <?php if ( 'localhost' == $hostname ) : ?> 
  149. <tr> 
  150. <th scope="row"><?php esc_html_e( 'Sub-directory Install' ); ?></th> 
  151. <td><?php 
  152. printf( 
  153. /** translators: 1: localhost 2: localhost.localdomain */ 
  154. __( '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.' ),  
  155. '<code>localhost</code>',  
  156. '<code>localhost.localdomain</code>' 
  157. ); 
  158. // Uh oh: 
  159. if ( !allow_subdirectory_install() ) 
  160. echo ' <strong>' . __( 'Warning!' ) . ' ' . __( 'The main site in a sub-directory install will need to use a modified permalink structure, potentially breaking existing links.' ) . '</strong>'; 
  161. ?></td> 
  162. </tr> 
  163. <?php elseif ( !allow_subdomain_install() ) : ?> 
  164. <tr> 
  165. <th scope="row"><?php esc_html_e( 'Sub-directory Install' ); ?></th> 
  166. <td><?php 
  167. _e( 'Because your install is in a directory, the sites in your WordPress network must use sub-directories.' ); 
  168. // Uh oh: 
  169. if ( !allow_subdirectory_install() ) 
  170. echo ' <strong>' . __( 'Warning!' ) . ' ' . __( 'The main site in a sub-directory install will need to use a modified permalink structure, potentially breaking existing links.' ) . '</strong>'; 
  171. ?></td> 
  172. </tr> 
  173. <?php elseif ( !allow_subdirectory_install() ) : ?> 
  174. <tr> 
  175. <th scope="row"><?php esc_html_e( 'Sub-domain Install' ); ?></th> 
  176. <td><?php _e( 'Because your install is not new, the sites in your WordPress network must use sub-domains.' ); 
  177. echo ' <strong>' . __( 'The main site in a sub-directory install will need to use a modified permalink structure, potentially breaking existing links.' ) . '</strong>'; 
  178. ?></td> 
  179. </tr> 
  180. <?php endif; ?> 
  181. <?php if ( ! $is_www ) : ?> 
  182. <tr> 
  183. <th scope='row'><?php esc_html_e( 'Server Address' ); ?></th> 
  184. <td> 
  185. <?php printf( 
  186. /** translators: %s: host name */ 
  187. __( 'The internet address of your network will be %s.' ),  
  188. '<code>' . $hostname . '</code>' 
  189. ); ?> 
  190. </td> 
  191. </tr> 
  192. <?php endif; ?> 
  193. <tr> 
  194. <th scope='row'><?php esc_html_e( 'Network Title' ); ?></th> 
  195. <td> 
  196. <input name='sitename' type='text' size='45' value='<?php echo esc_attr( $site_name ); ?>' /> 
  197. <p class="description"> 
  198. <?php _e( 'What would you like to call your network?' ); ?> 
  199. </p> 
  200. </td> 
  201. </tr> 
  202. <tr> 
  203. <th scope='row'><?php esc_html_e( 'Network Admin Email' ); ?></th> 
  204. <td> 
  205. <input name='email' type='text' size='45' value='<?php echo esc_attr( $admin_email ); ?>' /> 
  206. <p class="description"> 
  207. <?php _e( 'Your email address.' ); ?> 
  208. </p> 
  209. </td> 
  210. </tr> 
  211. </table> 
  212. <?php submit_button( __( 'Install' ), 'primary', 'submit' ); ?> 
  213. </form> 
  214. <?php