Changeset 15886
- Timestamp:
- 10/21/2010 01:49:49 PM (14 years ago)
- Location:
- trunk/wp-admin/network
- Files:
-
- 1 added
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/wp-admin/network/edit.php
r15843 r15886 159 159 exit(); 160 160 break; 161 case 'addblog':162 check_admin_referer( 'add-blog', '_wpnonce_add-blog' );163 164 if ( ! current_user_can( 'manage_sites' ) )165 wp_die( __( 'You do not have permission to access this page.' ) );166 167 if ( is_array( $_POST['blog'] ) == false )168 wp_die( __( 'Can’t create an empty site.' ) );169 $blog = $_POST['blog'];170 $domain = '';171 if ( ! preg_match( '/(--)/', $blog['domain'] ) && preg_match( '|^([a-zA-Z0-9-])+$|', $blog['domain'] ) )172 $domain = strtolower( $blog['domain'] );173 174 // If not a subdomain install, make sure the domain isn't a reserved word175 if ( ! is_subdomain_install() ) {176 $subdirectory_reserved_names = apply_filters( 'subdirectory_reserved_names', array( 'page', 'comments', 'blog', 'files', 'feed' ) );177 if ( in_array( $domain, $subdirectory_reserved_names ) )178 wp_die( sprintf( __('The following words are reserved for use by WordPress functions and cannot be used as blog names: <code>%s</code>' ), implode( '</code>, <code>', $subdirectory_reserved_names ) ) );179 }180 181 $email = sanitize_email( $blog['email'] );182 $title = $blog['title'];183 184 if ( empty( $domain ) )185 wp_die( __( 'Missing or invalid site address.' ) );186 if ( empty( $email ) )187 wp_die( __( 'Missing email address.' ) );188 if ( !is_email( $email ) )189 wp_die( __( 'Invalid email address.' ) );190 191 if ( is_subdomain_install() ) {192 $newdomain = $domain . '.' . preg_replace( '|^www\.|', '', $current_site->domain );193 $path = $base;194 } else {195 $newdomain = $current_site->domain;196 $path = $base . $domain . '/';197 }198 199 $password = 'N/A';200 $user_id = email_exists($email);201 if ( !$user_id ) { // Create a new user with a random password202 $password = wp_generate_password();203 $user_id = wpmu_create_user( $domain, $password, $email );204 if ( false == $user_id )205 wp_die( __( 'There was an error creating the user.' ) );206 else207 wp_new_user_notification( $user_id, $password );208 }209 210 $wpdb->hide_errors();211 $id = wpmu_create_blog( $newdomain, $path, $title, $user_id , array( 'public' => 1 ), $current_site->id );212 $wpdb->show_errors();213 if ( !is_wp_error( $id ) ) {214 if ( !is_super_admin( $user_id ) && !get_user_option( 'primary_blog', $user_id ) )215 update_user_option( $user_id, 'primary_blog', $id, true );216 $content_mail = sprintf( __( "New site created by %1s\n\nAddress: http://%2s\nName: %3s"), $current_user->user_login , $newdomain . $path, stripslashes( $title ) );217 wp_mail( get_site_option('admin_email'), sprintf( __( '[%s] New Site Created' ), $current_site->site_name ), $content_mail, 'From: "Site Admin" <' . get_site_option( 'admin_email' ) . '>' );218 wpmu_welcome_notification( $id, $user_id, $password, $title, array( 'public' => 1 ) );219 wp_redirect( add_query_arg( array( 'updated' => 'true', 'action' => 'add-blog' ), wp_get_referer() ) );220 exit();221 } else {222 wp_die( $id->get_error_message() );223 }224 break;225 161 226 162 case 'updateblog': -
trunk/wp-admin/network/menu.php
r15880 r15886 15 15 /* translators: Sites menu item */ 16 16 $menu[5] = array(__('Sites'), 'manage_sites', 'sites.php', '', 'menu-top menu-icon-site', 'menu-site', 'div'); 17 18 $submenu['sites.php'][5] = array( __('Sites'), 'manage_sites', 'sites.php' ); 19 $submenu['sites.php'][10] = array( __('Add New'), 'manage_sites', 'site-new.php' ); 20 17 21 $menu[10] = array(__('Users'), 'manage_network_users', 'users.php', '', 'menu-top menu-icon-users', 'menu-users', 'div'); 18 22 $menu[15] = array(__('Themes'), 'manage_network_themes', 'themes.php', '', 'menu-top menu-icon-appearance', 'menu-appearance', 'div'); -
trunk/wp-admin/network/sites.php
r15882 r15886 31 31 } else { 32 32 add_contextual_help($current_screen, 33 '<p>' . __('Add New takes you farther down on this same page. You can search for a site by Name, ID number, or IP address. Screen Options allows you to choose how many sites to display on one page.') . '</p>' .33 '<p>' . __('Add New takes you to the Add New Site screen. You can search for a site by Name, ID number, or IP address. Screen Options allows you to choose how many sites to display on one page.') . '</p>' . 34 34 '<p>' . __('This is the main table of all sites on this network. Switch between list and excerpt views by using the icons above the right side of the table.') . '</p>' . 35 35 '<p>' . __('Hovering over each site reveals seven options (three for the primary site):') . '</p>' . … … 41 41 '<p>' . __('The site ID is used internally, and is not shown on the front end of the site or to users/viewers.') . '</p>' . 42 42 '<p>' . __('Clicking on bold settings can re-sort this table. The upper right icons switch between list and excerpt views.') . '</p>' . 43 '<p>' . __("Clicking on Add Site, after filling out the address, title, and admin's email address, adds the site instantly to the network and this table. You may want to then click on the action link to edit options for that site.") . '</p>' .44 43 '<p>' . __('If the admin email for the new site does not exist in the database, a new user will also be created.') . '</p>' . 45 44 '<p><strong>' . __('For more information:') . '</strong></p>' . … … 65 64 case 'delete': 66 65 $msg = __( 'Site deleted.' ); 67 break;68 case 'add-blog':69 $msg = __( 'Site added.' );70 66 break; 71 67 case 'archive': … … 356 352 <h2><?php _e('Sites') ?> 357 353 <?php echo $msg; ?> 358 <a href=" #form-add-site" class="button add-new-h2"><?php echo esc_html_x( 'Add New', 'sites' ); ?></a>354 <a href="<?php echo network_admin_url('site-new.php'); ?>" class="button add-new-h2"><?php echo esc_html_x( 'Add New', 'sites' ); ?></a> 359 355 <?php if ( isset( $_REQUEST['s'] ) && $_REQUEST['s'] ) { 360 356 printf( '<span class="subtitle">' . __( 'Search results for “%s”' ) . '</span>', esc_html( $s ) ); … … 379 375 </form> 380 376 </div> 381 382 <div id="form-add-site" class="wrap">383 <h3><?php _e( 'Add Site' ) ?></h3>384 <form method="post" action="edit.php?action=addblog">385 <?php wp_nonce_field( 'add-blog', '_wpnonce_add-blog' ) ?>386 <table class="form-table">387 <tr class="form-field form-required">388 <th scope="row"><?php _e( 'Site Address' ) ?></th>389 <td>390 <?php if ( is_subdomain_install() ) { ?>391 <input name="blog[domain]" type="text" class="regular-text" title="<?php _e( 'Domain' ) ?>"/>.<?php echo preg_replace( '|^www\.|', '', $current_site->domain );?>392 <?php } else {393 echo $current_site->domain . $current_site->path ?><input name="blog[domain]" class="regular-text" type="text" title="<?php _e( 'Domain' ) ?>"/>394 <?php }395 echo '<p>' . __( 'Only the characters a-z and 0-9 recommended.' ) . '</p>';396 ?>397 </td>398 </tr>399 <tr class="form-field form-required">400 <th scope="row"><?php _e( 'Site Title' ) ?></th>401 <td><input name="blog[title]" type="text" class="regular-text" title="<?php _e( 'Title' ) ?>"/></td>402 </tr>403 <tr class="form-field form-required">404 <th scope="row"><?php _e( 'Admin Email' ) ?></th>405 <td><input name="blog[email]" type="text" class="regular-text" title="<?php _e( 'Email' ) ?>"/></td>406 </tr>407 <tr class="form-field">408 <td colspan="2"><?php _e( 'A new user will be created if the above email address is not in the database.' ) ?><br /><?php _e( 'The username and password will be mailed to this email address.' ) ?></td>409 </tr>410 </table>411 <p class="submit">412 <input class="button" type="submit" name="go" value="<?php esc_attr_e( 'Add Site' ) ?>" /></p>413 </form>414 </div>415 377 <?php 416 378 break;
Note: See TracChangeset
for help on using the changeset viewer.