Changeset 13655 for trunk/wp-admin/network.php
- Timestamp:
- 03/11/2010 01:51:24 AM (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/wp-admin/network.php
r13644 r13655 63 63 <h2><?php echo esc_html( $title ); ?></h2> 64 64 65 <form method="post" action="network.php">65 <form method="post"> 66 66 <?php 67 67 /** … … 73 73 * @since 3.0.0 74 74 */ 75 function network_step1( ) {75 function network_step1( $errors = false ) { 76 76 77 77 $active_plugins = get_option( 'active_plugins' ); … … 96 96 } 97 97 98 wp_nonce_field( 'install-network-1' ); 99 100 $error_codes = array(); 101 if ( is_wp_error( $errors ) ) { 102 echo '<div class="error"><p><strong>' . __( 'ERROR: The network could not be created.' ) . '</strong></p>'; 103 foreach ( $errors->get_error_messages() as $error ) 104 echo "<p>$error</p>"; 105 echo '</div>'; 106 $error_codes = $errors->get_error_codes(); 107 } 108 109 $site_name = ( ! empty( $_POST['sitename'] ) && ! in_array( 'empty_sitename', $error_codes ) ) ? $_POST['sitename'] : sprintf( _x('%s Sites', 'Default network name' ), get_option( 'blogname' ) ); 110 $admin_email = ( ! empty( $_POST['email'] ) && ! in_array( 'invalid_email', $error_codes ) ) ? $_POST['email'] : get_option( 'admin_email' ); 98 111 ?> 99 112 <p><?php _e( 'Welcome to the Network installation process!' ); ?></p> … … 102 115 103 116 // @todo IIS... 104 if ( apache_mod_loaded('mod_rewrite') ) { // assume nothing 105 $rewrite_enabled = true; 117 if ( ! empty( $_POST['subdomain_install'] ) ) { 118 $subdomain_install = (bool) $_POST['subdomain_install']; 119 } elseif ( apache_mod_loaded('mod_rewrite') ) { // assume nothing 120 $subdomain_install = true; 106 121 } else { 107 $ rewrite_enabled= false;122 $subdomain_install = false; 108 123 if ( got_mod_rewrite() ) // dangerous assumptions 109 124 echo '<p>' . __( 'Please make sure the Apache <code>mod_rewrite</code> module is installed as it will be used at the end of this install.' ) . '</p>'; … … 113 128 } 114 129 115 wp_nonce_field( 'install-network-1' );116 117 130 if ( 'localhost' != $hostname ) : ?> 118 131 <h3><?php esc_html_e( 'Addresses of Sites in your Network' ); ?></h3> … … 120 133 <p><?php _e( "You will need a wildcard DNS record if you're going to use the virtual host (sub-domain) functionality." ); ?></p> 121 134 <?php /* @todo: Link to an MS readme? */ ?> 122 <?php if ( ! $ rewrite_enabled) { ?>135 <?php if ( ! $subdomain_install ) { ?> 123 136 <p><?php _e( '<strong>Note</strong> It looks like <code>mod_rewrite</code> is not installed.' ); ?></p> 124 137 <?php } ?> 125 138 <table class="form-table"> 126 139 <tr> 127 <th><label><input type='radio' name='subdomain_install' value='1'<?php checked( $ rewrite_enabled); ?> /> Sub-domains</label></th>140 <th><label><input type='radio' name='subdomain_install' value='1'<?php checked( $subdomain_install ); ?> /> Sub-domains</label></th> 128 141 <td><?php _e('like <code>site1.example.com</code> and <code>site2.example.com</code>'); ?></td> 129 142 </tr> 130 143 <tr> 131 <th><label><input type='radio' name='subdomain_install' value='0'<?php checked( ! $ rewrite_enabled); ?> /> Sub-directories</label></th>144 <th><label><input type='radio' name='subdomain_install' value='0'<?php checked( ! $subdomain_install ); ?> /> Sub-directories</label></th> 132 145 <td><?php _e('like <code>example.com/site1</code> and <code>example.com/site2</code>'); ?></td> 133 146 </tr> … … 137 150 endif; 138 151 139 $is_www = ( substr( $hostname, 0, 4 ) == 'www.');152 $is_www = ( 0 === strpos( $hostname, 'www.' ) ); 140 153 if ( $is_www ) : 141 154 ?> … … 147 160 <td> 148 161 <?php printf( __( 'The Internet address of your network will be <code>%s</code>.' ), $hostname ); ?> 149 <input type='hidden' name='basedomain' value='<?php echo esc_attr( $hostname ); ?>' />150 162 </td> 151 163 </tr> … … 172 184 <th scope='row'><?php esc_html_e( 'Network Title' ); ?></th> 173 185 <td> 174 <input name=' weblog_title' type='text' size='45' value='<?php echo esc_attr( sprintf( __('%s Sites'), get_option( 'blogname' ) )); ?>' />186 <input name='sitename' type='text' size='45' value='<?php echo esc_attr( $site_name ); ?>' /> 175 187 <br /><?php _e( 'What would you like to call your network?' ); ?> 176 188 </td> … … 179 191 <th scope='row'><?php esc_html_e( 'Admin E-mail Address' ); ?></th> 180 192 <td> 181 <input name='email' type='text' size='45' value='<?php echo esc_attr( get_option( 'admin_email' )); ?>' />193 <input name='email' type='text' size='45' value='<?php echo esc_attr( $admin_email ); ?>' /> 182 194 <br /><?php _e( 'Your email address.' ); ?> 183 195 </td> … … 193 205 * @since 3.0.0 194 206 */ 195 function network_step2( ) {207 function network_step2( $errors = false ) { 196 208 global $base, $wpdb; 197 209 $hostname = get_clean_basedomain(); 210 211 // Wildcard DNS message. 212 if ( is_wp_error( $errors ) ) 213 echo '<div class="error">' . $errors->get_error_message() . '</div>'; 214 198 215 if ( $_POST ) { 199 216 $vhost = 'localhost' == $hostname ? false : (bool) $_POST['subdomain_install']; … … 264 281 <?php 265 282 266 // remove ending slash from $base and $url 267 $htaccess = ''; 268 $base = rtrim( $base, '/' ); 269 270 $htaccess_file = 'RewriteEngine On 271 RewriteBase ' . $base . '/ 272 273 #uploaded files 283 // @todo custom content dir 284 $htaccess_file = 'RewriteEngine On 285 RewriteBase ' . $base . ' 286 287 # uploaded files 274 288 RewriteRule ^(.*/)?files/$ index.php [L] 275 289 RewriteCond %{REQUEST_URI} !.*wp-content/plugins.* … … 308 322 $hostname = get_clean_basedomain(); 309 323 $subdomain_install = 'localhost' == $hostname ? false : (bool) $_POST['subdomain_install']; 310 if ( ! network_domain_check() ) 311 populate_network( 1, get_clean_basedomain(), sanitize_email( $_POST['email'] ), $_POST['weblog_title'], $base, $subdomain_install ); 312 // create wp-config.php / htaccess 313 network_step2(); 324 if ( ! network_domain_check() ) { 325 $result = populate_network( 1, get_clean_basedomain(), sanitize_email( $_POST['email'] ), $_POST['sitename'], $base, $subdomain_install ); 326 if ( is_wp_error( $result ) ) { 327 if ( 1 == count( $result->get_error_codes() ) && 'no_wildcard_dns' == $result->get_error_code() ) 328 network_step2( $result ); 329 else 330 network_step1( $result ); 331 } else { 332 network_step2(); 333 } 334 } else { 335 network_step2(); 336 } 314 337 } elseif ( is_multisite() || network_domain_check() ) { 315 338 network_step2();
Note: See TracChangeset
for help on using the changeset viewer.