diff --git a/wp-admin/network/edit.php b/wp-admin/network/edit.php index 6afc631439..5ef5176e53 100644 --- a/wp-admin/network/edit.php +++ b/wp-admin/network/edit.php @@ -158,70 +158,6 @@ switch ( $_GET['action'] ) { wp_redirect( add_query_arg( 'updated', 'true', network_admin_url( 'settings.php' ) ) ); exit(); break; - case 'addblog': - check_admin_referer( 'add-blog', '_wpnonce_add-blog' ); - - if ( ! current_user_can( 'manage_sites' ) ) - wp_die( __( 'You do not have permission to access this page.' ) ); - - if ( is_array( $_POST['blog'] ) == false ) - wp_die( __( 'Can’t create an empty site.' ) ); - $blog = $_POST['blog']; - $domain = ''; - if ( ! preg_match( '/(--)/', $blog['domain'] ) && preg_match( '|^([a-zA-Z0-9-])+$|', $blog['domain'] ) ) - $domain = strtolower( $blog['domain'] ); - - // If not a subdomain install, make sure the domain isn't a reserved word - if ( ! is_subdomain_install() ) { - $subdirectory_reserved_names = apply_filters( 'subdirectory_reserved_names', array( 'page', 'comments', 'blog', 'files', 'feed' ) ); - if ( in_array( $domain, $subdirectory_reserved_names ) ) - wp_die( sprintf( __('The following words are reserved for use by WordPress functions and cannot be used as blog names: %s' ), implode( ', ', $subdirectory_reserved_names ) ) ); - } - - $email = sanitize_email( $blog['email'] ); - $title = $blog['title']; - - if ( empty( $domain ) ) - wp_die( __( 'Missing or invalid site address.' ) ); - if ( empty( $email ) ) - wp_die( __( 'Missing email address.' ) ); - if ( !is_email( $email ) ) - wp_die( __( 'Invalid email address.' ) ); - - if ( is_subdomain_install() ) { - $newdomain = $domain . '.' . preg_replace( '|^www\.|', '', $current_site->domain ); - $path = $base; - } else { - $newdomain = $current_site->domain; - $path = $base . $domain . '/'; - } - - $password = 'N/A'; - $user_id = email_exists($email); - if ( !$user_id ) { // Create a new user with a random password - $password = wp_generate_password(); - $user_id = wpmu_create_user( $domain, $password, $email ); - if ( false == $user_id ) - wp_die( __( 'There was an error creating the user.' ) ); - else - wp_new_user_notification( $user_id, $password ); - } - - $wpdb->hide_errors(); - $id = wpmu_create_blog( $newdomain, $path, $title, $user_id , array( 'public' => 1 ), $current_site->id ); - $wpdb->show_errors(); - if ( !is_wp_error( $id ) ) { - if ( !is_super_admin( $user_id ) && !get_user_option( 'primary_blog', $user_id ) ) - update_user_option( $user_id, 'primary_blog', $id, true ); - $content_mail = sprintf( __( "New site created by %1s\n\nAddress: http://%2s\nName: %3s"), $current_user->user_login , $newdomain . $path, stripslashes( $title ) ); - 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' ) . '>' ); - wpmu_welcome_notification( $id, $user_id, $password, $title, array( 'public' => 1 ) ); - wp_redirect( add_query_arg( array( 'updated' => 'true', 'action' => 'add-blog' ), wp_get_referer() ) ); - exit(); - } else { - wp_die( $id->get_error_message() ); - } - break; case 'updateblog': check_admin_referer( 'editblog' ); diff --git a/wp-admin/network/menu.php b/wp-admin/network/menu.php index 3a055c62de..32ab5f2fc4 100644 --- a/wp-admin/network/menu.php +++ b/wp-admin/network/menu.php @@ -14,6 +14,10 @@ $menu[4] = array( '', 'read', 'separator1', '', 'wp-menu-separator' ); /* translators: Sites menu item */ $menu[5] = array(__('Sites'), 'manage_sites', 'sites.php', '', 'menu-top menu-icon-site', 'menu-site', 'div'); + +$submenu['sites.php'][5] = array( __('Sites'), 'manage_sites', 'sites.php' ); +$submenu['sites.php'][10] = array( __('Add New'), 'manage_sites', 'site-new.php' ); + $menu[10] = array(__('Users'), 'manage_network_users', 'users.php', '', 'menu-top menu-icon-users', 'menu-users', 'div'); $menu[15] = array(__('Themes'), 'manage_network_themes', 'themes.php', '', 'menu-top menu-icon-appearance', 'menu-appearance', 'div'); diff --git a/wp-admin/network/site-new.php b/wp-admin/network/site-new.php new file mode 100644 index 0000000000..4b866de66b --- /dev/null +++ b/wp-admin/network/site-new.php @@ -0,0 +1,137 @@ +%s' ), implode( ', ', $subdirectory_reserved_names ) ) ); + } + + $email = sanitize_email( $blog['email'] ); + $title = $blog['title']; + + if ( empty( $domain ) ) + wp_die( __( 'Missing or invalid site address.' ) ); + if ( empty( $email ) ) + wp_die( __( 'Missing email address.' ) ); + if ( !is_email( $email ) ) + wp_die( __( 'Invalid email address.' ) ); + + if ( is_subdomain_install() ) { + $newdomain = $domain . '.' . preg_replace( '|^www\.|', '', $current_site->domain ); + $path = $base; + } else { + $newdomain = $current_site->domain; + $path = $base . $domain . '/'; + } + + $password = 'N/A'; + $user_id = email_exists($email); + if ( !$user_id ) { // Create a new user with a random password + $password = wp_generate_password(); + $user_id = wpmu_create_user( $domain, $password, $email ); + if ( false == $user_id ) + wp_die( __( 'There was an error creating the user.' ) ); + else + wp_new_user_notification( $user_id, $password ); + } + + $wpdb->hide_errors(); + $id = wpmu_create_blog( $newdomain, $path, $title, $user_id , array( 'public' => 1 ), $current_site->id ); + $wpdb->show_errors(); + if ( !is_wp_error( $id ) ) { + if ( !is_super_admin( $user_id ) && !get_user_option( 'primary_blog', $user_id ) ) + update_user_option( $user_id, 'primary_blog', $id, true ); + $content_mail = sprintf( __( "New site created by %1s\n\nAddress: http://%2s\nName: %3s"), $current_user->user_login , $newdomain . $path, stripslashes( $title ) ); + 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' ) . '>' ); + wpmu_welcome_notification( $id, $user_id, $password, $title, array( 'public' => 1 ) ); + wp_redirect( add_query_arg( array('update' => 'added'), 'site-new.php' ) ); + exit; + } else { + wp_die( $id->get_error_message() ); + } +} + +if ( isset($_GET['update']) ) { + $messages = array(); + if ( 'added' == $_GET['update'] ) + $messages[] = __('Site added.'); +} + +$title = __('Add New Site'); +$parent_file = 'sites.php'; + +require('../admin-header.php'); + +?> + +
+ +

+

' . $msg . '

'; +} ?> +
+ + + + + + + + + + + + + + + + + +
+ + .domain );?> + domain . $current_site->path ?> + ' . __( 'Only the characters a-z and 0-9 recommended.' ) . '

'; + ?> +

+ +
+ + diff --git a/wp-admin/network/sites.php b/wp-admin/network/sites.php index 60babebcd7..446a3667ba 100644 --- a/wp-admin/network/sites.php +++ b/wp-admin/network/sites.php @@ -30,7 +30,7 @@ if ( isset( $_REQUEST['action'] ) && 'editblog' == $_REQUEST['action'] ) { ); } else { add_contextual_help($current_screen, - '

' . __('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.') . '

' . + '

' . __('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.') . '

' . '

' . __('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.') . '

' . '

' . __('Hovering over each site reveals seven options (three for the primary site):') . '

' . '' . '

' . __('The site ID is used internally, and is not shown on the front end of the site or to users/viewers.') . '

' . '

' . __('Clicking on bold settings can re-sort this table. The upper right icons switch between list and excerpt views.') . '

' . - '

' . __("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.") . '

' . '

' . __('If the admin email for the new site does not exist in the database, a new user will also be created.') . '

' . '

' . __('For more information:') . '

' . '

' . __('Documentation on Sites') . '

' . @@ -65,9 +64,6 @@ if ( isset( $_REQUEST['updated'] ) && $_REQUEST['updated'] == 'true' && ! empty( case 'delete': $msg = __( 'Site deleted.' ); break; - case 'add-blog': - $msg = __( 'Site added.' ); - break; case 'archive': $msg = __( 'Site archived.' ); break; @@ -355,7 +351,7 @@ switch ( $action ) {

- + ' . __( 'Search results for “%s”' ) . '', esc_html( $s ) ); } ?> @@ -378,40 +374,6 @@ switch ( $action ) { display(); ?> - -
-

-
- - - - - - - - - - - - - - - - - -
- - .domain );?> - domain . $current_site->path ?> - ' . __( 'Only the characters a-z and 0-9 recommended.' ) . '

'; - ?> -

-

-

-
-