Changeset 13571
- Timestamp:
- 03/03/2010 07:43:32 AM (15 years ago)
- Location:
- trunk/wp-admin
- Files:
-
- 1 added
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/wp-admin/admin-footer.php
r11768 r13571 30 30 do_action('admin_footer', ''); 31 31 do_action('admin_print_footer_scripts'); 32 do_action("admin_footer- $hook_suffix");32 do_action("admin_footer-" . $GLOBALS['hook_suffix']); 33 33 34 34 // get_site_option() won't exist when auto upgrading from <= 2.7 -
trunk/wp-admin/comment.php
r13268 r13571 36 36 */ 37 37 function comment_footer_die( $msg ) { 38 global $hook_suffix;39 38 echo "<div class='wrap'><p>$msg</p></div>"; 40 39 include('admin-footer.php'); -
trunk/wp-admin/network.php
r13466 r13571 1 1 <?php 2 2 /** 3 * Network settingsadministration panel.3 * Network installation administration panel. 4 4 * 5 5 * A multi-step process allowing the user to enable a network of WordPress sites. … … 15 15 16 16 if ( ! is_super_admin() ) 17 wp_die( __( 'You do not have sufficient permissions to manage options for this blog.' ) ); 17 wp_die( __( 'You do not have sufficient permissions to manage options for this site.' ) ); 18 19 if ( is_multisite() ) 20 wp_die( __( 'The Network feature is already enabled.' ) ); 21 22 include( ABSPATH . 'wp-admin/includes/network.php' ); 18 23 19 24 // We need to create references to ms global tables to enable Network. … … 21 26 $wpdb->$table = $prefixed_table; 22 27 23 $title = __( ' Network Settings' );28 $title = __( 'Create a Network of WordPress Sites' ); 24 29 $parent_file = 'tools.php'; 25 30 … … 37 42 <?php 38 43 /** 39 * Prints summary of server statistics in preparation for setting up a network. 44 * Prints step 1 for Network installation process. 45 * 46 * @todo Realistically, step 1 should be a welcome screen explaining what a Network is and such. Navigating to Tools > Network 47 * should not be a sudden "Welcome to a new install process! Fill this out and click here." 40 48 * 41 49 * @since 3.0.0 42 50 */ 43 function filestats( $err ) { 44 ?> 45 <h2><?php esc_html_e( 'Server Summary' ); ?></h2> 46 <p><?php _e( 'If you post a message to the WordPress support forum at <a target="_blank" href="http://wordpress.org/support/">http://wordpress.org/support/</a> then copy and paste the following information into your message:' ); ?></p> 47 <blockquote style="background: #eee; border: 1px solid #333; padding: 5px;"> 48 <br /><strong><?php printf( __( 'ERROR: %s' ), $err ); ?></strong><br /> 49 <?php 50 clearstatcache(); 51 $files = array( 'htaccess.dist', '.htaccess' ); 52 53 $indent = ' '; 54 foreach ( (array) $files as $val ) { 55 $stats = @stat( $val ); 56 if ( $stats ) { 57 ?> 58 <h2><?php echo esc_html( $val ); ?></h2> 59 <?php echo $indent . sprintf( __( 'uid/gid: %1$s/%2$s' ), $stats['uid'], $stats['gid'] ); ?><br /> 60 <?php echo $indent . sprintf( __( 'size: %s' ), $stats['size'] ); ?><br/> 61 <?php echo $indent . sprintf( __( 'perms: %s' ), substr( sprintf( '%o', fileperms( $val ) ), -4 ) ); ?><br/> 62 <?php echo $indent . sprintf( __( 'readable: %s' ), is_readable( $val ) ? __( 'yes' ) : __( 'no' ) ); ?><br/> 63 <?php echo $indent . sprintf( __( 'writeable: %s' ), is_writeable( $val ) ? __( 'yes' ) : __( 'no' ) ); ?><br/> 64 <?php 65 } elseif ( ! file_exists( $val ) ) { 66 ?> 67 <h2><?php echo esc_html( $val ); ?></h2> 68 <?php echo $indent . sprintf( __( 'FILE NOT FOUND: %s' ), $val ); ?><br/> 69 <?php 70 } 71 } 72 echo "</blockquote>"; 73 } 74 75 /** 76 * Prints .htaccess component of step 2 for network settings. 77 * 78 * @since 3.0.0 79 */ 80 function step2_htaccess() { 81 global $base; 82 83 // remove ending slash from $base and $url 84 $htaccess = ''; 85 if ( substr( $base, -1 ) == '/' ) 86 $base = substr( $base, 0, -1 ); 87 88 $htaccess_sample = ABSPATH . 'wp-admin/includes/htaccess.ms'; 89 if ( ! file_exists( $htaccess_sample ) ) 90 wp_die( sprintf( __( 'Sorry, I need a %s to work from. Please re-upload this file to your WordPress installation.' ), $htaccess_sample ) ); 91 92 $htaccess_file = file( $htaccess_sample ); 93 $fp = @fopen( $htaccess_sample, "r" ); 94 if ( $fp ) { 95 while ( ! feof( $fp ) ) { 96 $htaccess .= fgets( $fp, 4096 ); 97 } 98 fclose( $fp ); 99 $htaccess_file = str_replace( "BASE", $base, $htaccess ); 51 function ms_network_step1() { 52 53 $active_plugins = get_option( 'active_plugins' ); 54 if ( ! empty( $active_plugins ) ) { 55 printf( '<p>' . __( 'Please <a href="%s">deactivate</a> your plugins before enabling the Network feature. Once the network is created, you may reactivate your plugins.' ) . '</p>', admin_url( 'plugins.php' ) ); 56 include( './admin-footer.php' ); 57 die(); 58 } 59 60 $hostname = get_clean_basedomain(); 61 if ( 'localhost' == $hostname || preg_match( '|[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+|', $hostname ) ) { 62 echo '<p><strong>' . __('You cannot install a network of sites with your server address.' ) . '</strong></p>'; 63 echo '<p>' . __('You cannot use an IP address such as <code>127.0.0.1</code> or a single-word hostname like <code>localhost</code>.' ) . '</p>'; 64 if ( 'localhost' == $hostname ) 65 echo '<p>' . __('Consider using <code>localhost.localdomain</code>.') . '</p>'; 66 include( './admin-footer.php' ); 67 die(); 68 } 69 70 ?> 71 <p><?php _e( 'Welcome to the Network installation process!' ); ?></p> 72 <p><?php _e( "Fill in the information below and you’ll be on your way to creating a network of WordPress sites. We'll create configuration files in the next step." ); ?></p> 73 <?php 74 75 if ( apache_mod_loaded('mod_rewrite') ) { // assume nothing 76 $rewrite_enabled = true; 100 77 } else { 101 wp_die( sprintf( __( 'Sorry, I need to be able to read %s. Please check the permissions on this file.' ), $htaccess_sample ) ); 102 } 103 ?> 104 <li><p><?php printf( __( 'Replace the contents of your <code>%s.htaccess</code> with the following:' ), ABSPATH ); ?></p> 105 <textarea name="htaccess" cols="120" rows="20"> 106 <?php echo wp_htmledit_pre( $htaccess_file ); ?> 107 </textarea> 108 </li> 109 <?php 110 } 111 112 /** 113 * Prints part of step 1 for network settings and checks for mod_rewrite. 114 * 115 * @since 3.0.0 116 * @return bool Whether mod_rewrite is enabled. 117 */ 118 function step1() { 119 $rewrite_enabled = false; 120 ?> 121 <h2><?php esc_html_e( 'Installing Network of WordPress Sites' ); ?></h2> 122 <p><?php _e( 'I will help you enable the features for creating a network of sites by asking you a few questions so that you can create configuration files and make a directory to store all your uploaded files.' ); ?></p> 123 124 <h2><?php esc_html_e( 'What do I need?' ); ?></h2> 125 <ul> 126 <li><?php _e( 'Access to your server to change directory permissions. This can be done through ssh or ftp for example.' ); ?></li> 127 <li><?php _e( 'A valid email where your password and administrative emails will be sent.' ); ?></li> 128 <li><?php _e( "Wildcard dns records if you're going to use the virtual host (sub-domain) functionality. Check the <a href='http://trac.mu.wordpress.org/browser/trunk/README.txt'>README</a> for further details." ); ?></li> 129 </ul> 130 <?php 131 $mod_rewrite_msg = "\n<p>" . __( 'If the <code>mod_rewrite</code> module is disabled ask your administrator to enable that module, or look at the <a href="http://httpd.apache.org/docs/mod/mod_rewrite.html">Apache documentation</a> or <a href="http://www.google.com/search?q=apache+mod_rewrite">elsewhere</a> for help setting it up.' ) . '</p>'; 132 133 if ( function_exists( 'apache_get_modules' ) ) { 134 $modules = apache_get_modules(); 135 if ( ! in_array( 'mod_rewrite', $modules ) ) 136 echo '<p>' . __( '<strong>Warning!</strong> It looks like mod_rewrite is not installed.' ) . '</p>' . $mod_rewrite_msg; 78 $rewrite_enabled = false; 79 if ( got_mod_rewrite() ) // dangerous assumptions 80 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>'; 137 81 else 138 $rewrite_enabled = true; 139 } else { 140 echo '<p>' . __( 'Please make sure <code>mod_rewrite</code> is installed as it will be activated at the end of this install.' ) . '</p>' . $mod_rewrite_msg; 141 } 142 return $rewrite_enabled; 143 } 144 145 /** 146 * Prints most of step 1 for network settings. 147 * 148 * @since 3.0.0 149 * @param bool $rewrite_enabled Whether mod_rewrite is enabled. Default false. 150 */ 151 function printstep1form( $rewrite_enabled = false ) { 152 $weblog_title = sprintf( __( '%s Sites' ), ucfirst( get_option( 'blogname' ) ) ); 153 $email = get_option( 'admin_email' ); 154 $hostname = get_clean_basedomain(); 155 $invalid_host = false; 156 if ( 'localhost' == $hostname || preg_match( '|[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+|', $hostname, $match ) ) 157 $invalid_host = true; 158 if ( substr( $hostname, 0, 4 ) == 'www.' ) 159 $nowww = substr( $hostname, 4 ); 82 echo '<p>' . __( '<strong>Warning!</strong> It looks like Apache <code>mod_rewrite</code> module is not installed.' ) . '</p>'; 83 echo '<p>' . __( 'If <code>mod_rewrite</code> is disabled ask your administrator to enable that module, or look at the <a href="http://httpd.apache.org/docs/mod/mod_rewrite.html">Apache documentation</a> or <a href="http://www.google.com/search?q=apache+mod_rewrite">elsewhere</a> for help setting it up.' ) . '</p>'; 84 } 160 85 161 86 wp_nonce_field( 'install-network-1' ); … … 164 89 <p><?php _e( 'An existing WordPress Network was detected.' ); ?></p> 165 90 <p class="existing-network"> 166 <label><input type='checkbox' name='existing_network' value=' yes' /> <?php _e( 'Yes, keep the existing network of sites.' ); ?></label><br />91 <label><input type='checkbox' name='existing_network' value='1' /> <?php _e( 'Yes, keep the existing network of sites.' ); ?></label><br /> 167 92 </p> 168 93 169 94 <?php } else { ?> 170 <input type='hidden' name='existing_network' value=' none' />95 <input type='hidden' name='existing_network' value='0' /> 171 96 <?php } ?> 172 97 <input type='hidden' name='action' value='step2' /> 173 <h2><?php esc_html_e( 'Site Addresses' ); ?></h2> 174 <p><?php _e( 'Please choose whether you would like sites in your WordPress install to use sub-domains or sub-directories. You cannot change this later.' ); ?></p> 98 <h3><?php esc_html_e( 'Addresses of Sites in your Network' ); ?></h3> 99 100 <p><?php _e( 'Please choose whether you would like sites in your WordPress network to use sub-domains or sub-directories. <strong>You cannot change this later.</strong>' ); ?></p> 101 <p><?php _e( "You will need a wildcard DNS record if you're going to use the virtual host (sub-domain) functionality." ); ?></p> 102 <?php /* @todo: Link to an MS readme? */ ?> 175 103 <?php if ( ! $rewrite_enabled ) { ?> 176 104 <p><?php _e( '<strong>Note</strong> It looks like <code>mod_rewrite</code> is not installed.' ); ?></p> 177 105 <?php } ?> 178 <p class="blog-address">179 <label><input type='radio' name='vhost' value='yes'<?php if ( $rewrite_enabled ) echo ' checked="checked"'; ?> /> <?php _e( 'Sub-domains (like <code>blog1.example.com</code>)' ); ?></label><br />180 <label><input type='radio' name='vhost' value='no'<?php if ( ! $rewrite_enabled ) echo ' checked="checked"'; ?> /> <?php _e( 'Sub-directories (like <code>example.com/blog1</code>)' ); ?></label>181 </p>182 183 <h2><?php esc_html_e( 'Server Address' ); ?></h2>184 <?php if ( isset( $nowww ) ) { ?>185 <h3><?php printf( __( 'We recommend you change your siteurl to <code>%1$s</code> before enabling the network feature. It will still be possible to visit your site using the "www" prefix with an address like <code>%2$s</code> but any links will not have the "www" prefix.' ), $nowww, $hostname ); ?></h3>186 <?php } ?>187 106 <table class="form-table"> 188 107 <tr> 108 <th><label><input type='radio' name='vhost' value='yes'<?php checked( $rewrite_enabled ); ?> /> Sub-domains</label></th> 109 <td><?php _e('like <code>blog1.example.com</code> and <code>blog2.example.com</code>'); ?></td> 110 </tr> 111 <tr> 112 <th><label><input type='radio' name='vhost' value='no'<?php checked( ! $rewrite_enabled ); ?> /> Sub-directories</label></th> 113 <td><?php _e('like <code>example.com/blog1</code> and <code>example.com/blog2</code>'); ?></td> 114 </tr> 115 </table> 116 117 <?php 118 $is_www = ( substr( $hostname, 0, 4 ) == 'www.' ); 119 if ( $is_www ) : 120 ?> 121 <h3><?php esc_html_e( 'Server Address' ); ?></h3> 122 <p><?php printf( __( 'We recommend you change your siteurl to <code>%1$s</code> before enabling the network feature. It will still be possible to visit your site using the "www" prefix with an address like <code>%2$s</code> but any links will not have the "www" prefix.' ), substr( $hostname, 4 ), $hostname ); ?></h3> 123 <table class="form-table"> 124 <tr> 189 125 <th scope='row'><?php esc_html_e( 'Server Address' ); ?></th> 190 126 <td> 191 <?php if ( !$invalid_host ) { ?> 192 <?php printf( __( 'This will be the Internet address of your site: <strong><em>%s</em></strong>.' ), $hostname ); ?> 127 <?php printf( __( 'The Internet address of your network will be <code>%s</code>.' ), $hostname ); ?> 193 128 <input type='hidden' name='basedomain' value='<?php echo esc_attr( $hostname ); ?>' /> 194 <?php } else { ?>195 <?php _e( 'Do not use an IP address (like 127.0.0.1) or a single word hostname like <q>localhost</q> as your server address.' ); ?>196 <?php } ?>197 129 </td> 198 130 </tr> 199 131 </table> 200 201 <h2><?php esc_html_e( 'Site Details' ); ?></h2> 132 <?php endif; ?> 133 134 <h3><?php esc_html_e( 'Network Details' ); ?></h3> 202 135 <table class="form-table"> 203 <tr> 204 <th scope='row'><?php esc_html_e( 'Site Title' ); ?></th> 205 <td> 206 <input name='weblog_title' type='text' size='45' value='<?php echo esc_attr( $weblog_title ); ?>' /> 207 <br /><?php _e( 'What would you like to call your site?' ); ?> 208 </td> 209 </tr> 210 <tr> 211 <th scope='row'><?php esc_html_e( 'Email' ); ?></th> 212 <td> 213 <input name='email' type='text' size='45' value='<?php echo esc_attr( $email ); ?>' /> 136 <?php if ( ! $is_www ) : ?> 137 <tr> 138 <th scope='row'><?php esc_html_e( 'Server Address' ); ?></th> 139 <td> 140 <?php printf( __( 'The Internet address of your network will be <code>%s</code>.' ), $hostname ); ?> 141 </td> 142 </tr> 143 <?php endif; ?> 144 <tr> 145 <th scope='row'><?php esc_html_e( 'Network Title' ); ?></th> 146 <td> 147 <input name='weblog_title' type='text' size='45' value='<?php echo esc_attr( sprintf( __('%s Sites'), get_option( 'blogname' ) ) ); ?>' /> 148 <br /><?php _e( 'What would you like to call your network?' ); ?> 149 </td> 150 </tr> 151 <tr> 152 <th scope='row'><?php esc_html_e( 'Admin E-mail Address' ); ?></th> 153 <td> 154 <input name='email' type='text' size='45' value='<?php echo esc_attr( get_option( 'admin_email' ) ); ?>' /> 214 155 <br /><?php _e( 'Your email address.' ); ?> 215 156 </td> 216 157 </tr> 217 158 </table> 218 <?php if ( !$invalid_host ) { ?> 219 <p class='submit'><input class="button" name='submit' type='submit' value='<?php esc_attr_e( 'Proceed' ); ?>' /></p> 220 <?php } ?> 221 <?php 159 <p class='submit'><input class="button-primary" name='submit' type='submit' value='<?php esc_attr_e( 'Install' ); ?>' /></p> 160 <?php 222 161 } 223 162 224 163 /** 225 * Checks for active plugins & displays a notice to deactivate them.164 * Prints step 2 for Network installation process. 226 165 * 227 166 * @since 3.0.0 228 167 */ 229 function step1_plugin_check() { 230 $active_plugins = get_option( 'active_plugins' ); 231 if ( is_array( $active_plugins ) && !empty( $active_plugins ) ) { 232 ?> 233 <h2><?php esc_html_e( 'Enabling WordPress Sites' ); ?></h2> 234 <p><?php printf( __( 'Please <a href="%s">deactivate</a> your plugins before enabling WordPress Sites. Once WordPress Sites are enabled, you may reactivate your plugins.' ), admin_url( 'plugins.php' ) ); ?></p> 235 <?php 236 return false; 237 } 238 return true; 239 } 240 241 /** 242 * Checks for existing network data/tables. 243 * 244 * @since 3.0.0 245 */ 246 function network_domain_check() { 247 global $wpdb; 248 249 if ( $wpdb->get_var( "SHOW TABLES LIKE '$wpdb->site'" ) == $wpdb->site ) 250 return $wpdb->get_var( "SELECT domain FROM $wpdb->site ORDER BY id ASC LIMIT 1" ); 251 252 return false; 253 } 254 255 /** 256 * Prints step 2 for network settings. 257 * 258 * @since 3.0.0 259 */ 260 function step2() { 261 ?> 262 <h2><?php esc_html_e( 'Enabling WordPress Sites' ); ?></h2> 168 function ms_network_step2() { 169 global $base, $wpdb; 170 ?> 171 <h3><?php esc_html_e( 'Enabling the Network' ); ?></h3> 263 172 <p><?php _e( 'Complete the following steps to enable the features for creating a network of sites. <strong>Note:</strong> We recommend you make a backup copy of your existing <code>wp-config.php</code> and <code>.htaccess</code> files.' ); ?></p> 264 173 <ol> 265 174 <li><?php printf( __( 'Create a <code>%s/blogs.dir</code> directory. This directory is used to stored uploaded media for your additional sites and must be writeable by the web server.' ), WP_CONTENT_DIR ); ?></li> 266 <?php step2_config(); ?> 267 <?php step2_htaccess(); ?> 268 </ol> 269 <?php 270 } 271 272 /** 273 * Prints configuration file component of step 2 for network settings. 274 * 275 * @since 3.0.0 276 */ 277 function step2_config() { 278 global $base, $wpdb, $vhost; 279 175 <?php 280 176 $vhost = stripslashes( $_POST['vhost' ] ); 281 177 $prefix = $wpdb->base_prefix; 282 178 283 $config_sample = ABSPATH . 'wp-admin/includes/ wp-config.ms';179 $config_sample = ABSPATH . 'wp-admin/includes/ms-config-sample.php'; 284 180 if ( ! file_exists( $config_sample ) ) 285 181 wp_die( sprintf( __( 'Sorry, I need a <code>%s</code> to work from. Please re-upload this file to your WordPress installation.' ), $config_sample ) ); … … 342 238 </li> 343 239 <?php 240 241 // remove ending slash from $base and $url 242 $htaccess = ''; 243 if ( substr( $base, -1 ) == '/' ) 244 $base = substr( $base, 0, -1 ); 245 246 $htaccess_sample = ABSPATH . 'wp-admin/includes/htaccess.ms'; 247 if ( ! file_exists( $htaccess_sample ) ) 248 wp_die( sprintf( __( 'Sorry, I need a %s to work from. Please re-upload this file to your WordPress installation.' ), $htaccess_sample ) ); 249 250 $htaccess_file = file( $htaccess_sample ); 251 $fp = @fopen( $htaccess_sample, "r" ); 252 if ( $fp ) { 253 while ( ! feof( $fp ) ) { 254 $htaccess .= fgets( $fp, 4096 ); 255 } 256 fclose( $fp ); 257 $htaccess_file = str_replace( "BASE", $base, $htaccess ); 258 } else { 259 wp_die( sprintf( __( 'Sorry, I need to be able to read %s. Please check the permissions on this file.' ), $htaccess_sample ) ); 260 } 261 ?> 262 <li><p><?php printf( __( 'Replace the contents of your <code>%s.htaccess</code> with the following:' ), ABSPATH ); ?></p> 263 <textarea name="htaccess" cols="120" rows="20"> 264 <?php echo wp_htmledit_pre( $htaccess_file ); ?> 265 </textarea> 266 </li> 267 </ol> 268 <?php 344 269 } 345 270 346 /** 347 * Gets base domain of network. 348 * 349 * @since 3.0.0 350 */ 351 function get_clean_basedomain() { 352 global $wpdb; 353 354 $existing_domain = network_domain_check(); 355 if ( $existing_domain ) 356 return $existing_domain; 357 358 $domain = preg_replace( '|https?://|', '', get_option( 'siteurl' ) ); 359 if ( strpos( $domain, '/' ) ) 360 $domain = substr( $domain, 0, strpos( $domain, '/' ) ); 361 return $domain; 362 } 363 364 $action = isset( $_POST[ 'action' ] ) ? $_POST[ 'action' ] : null; 365 366 switch( $action ) { 271 $action = isset( $_POST['action'] ) ? $_POST['action'] : null; 272 273 switch ( $action ) { 367 274 case 'step2': 368 275 check_admin_referer( 'install-network-1' ); 369 276 370 if ( isset( $_POST[ 'existing_network' ] ) ) { 371 // Install! 372 $base = stripslashes( dirname( dirname( $_SERVER['SCRIPT_NAME'] ) ) ); 373 if ( $base != '/' ) 374 $base .= '/'; 375 376 require_once( ABSPATH . 'wp-admin/includes/upgrade.php' ); 377 // create network tables 378 $domain = get_clean_basedomain(); 379 install_network(); 380 if ( !network_domain_check() || $_POST[ 'existing_network' ] == 'none' ) 381 populate_network( 1, $domain, sanitize_email( $_POST['email'] ), $_POST['weblog_title'], $base, $_POST['vhost'] ); 382 // create wp-config.php / htaccess 383 step2(); 384 break; 385 } 277 // Install! 278 $base = trailingslashit( stripslashes( dirname( dirname( $_SERVER['SCRIPT_NAME'] ) ) ) ); 279 280 require_once( ABSPATH . 'wp-admin/includes/upgrade.php' ); 281 // create network tables 282 install_network(); 283 if ( !network_domain_check() || $_POST['existing_network'] == '0' ) 284 populate_network( 1, get_clean_basedomain(), sanitize_email( $_POST['email'] ), $_POST['weblog_title'], $base, $_POST['vhost'] ); 285 // create wp-config.php / htaccess 286 ms_network_step2(); 287 break; 288 386 289 default: 387 //@todo: give an informative screen instead 388 if ( is_multisite() ) { 389 _e( 'Network already enabled.' ); 390 } elseif ( step1_plugin_check() ) { 391 $rewrite_enabled = step1(); 392 printstep1form( $rewrite_enabled ); 393 } 394 break; 290 ms_network_step1(); 291 break; 395 292 } 396 293 ?>
Note: See TracChangeset
for help on using the changeset viewer.