Changeset 42343 for trunk/src/wp-admin/network/site-new.php
- Timestamp:
- 11/30/2017 11:09:33 PM (7 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-admin/network/site-new.php
r42228 r42343 18 18 } 19 19 20 get_current_screen()->add_help_tab( array( 21 'id' => 'overview', 22 'title' => __('Overview'), 23 'content' => 24 '<p>' . __('This screen is for Super Admins to add new sites to the network. This is not affected by the registration settings.') . '</p>' . 25 '<p>' . __('If the admin email for the new site does not exist in the database, a new user will also be created.') . '</p>' 26 ) ); 20 get_current_screen()->add_help_tab( 21 array( 22 'id' => 'overview', 23 'title' => __( 'Overview' ), 24 'content' => 25 '<p>' . __( 'This screen is for Super Admins to add new sites to the network. This is not affected by the registration settings.' ) . '</p>' . 26 '<p>' . __( 'If the admin email for the new site does not exist in the database, a new user will also be created.' ) . '</p>', 27 ) 28 ); 27 29 28 30 get_current_screen()->set_help_sidebar( 29 '<p><strong>' . __( 'For more information:') . '</strong></p>' .30 '<p>' . __( '<a href="https://codex.wordpress.org/Network_Admin_Sites_Screen">Documentation on Site Management</a>') . '</p>' .31 '<p>' . __( '<a href="https://wordpress.org/support/forum/multisite/">Support Forums</a>') . '</p>'31 '<p><strong>' . __( 'For more information:' ) . '</strong></p>' . 32 '<p>' . __( '<a href="https://codex.wordpress.org/Network_Admin_Sites_Screen">Documentation on Site Management</a>' ) . '</p>' . 33 '<p>' . __( '<a href="https://wordpress.org/support/forum/multisite/">Support Forums</a>' ) . '</p>' 32 34 ); 33 35 34 if ( isset( $_REQUEST['action']) && 'add-site' == $_REQUEST['action'] ) {36 if ( isset( $_REQUEST['action'] ) && 'add-site' == $_REQUEST['action'] ) { 35 37 check_admin_referer( 'add-blog', '_wpnonce_add-blog' ); 36 38 37 if ( ! is_array( $_POST['blog'] ) ) 39 if ( ! is_array( $_POST['blog'] ) ) { 38 40 wp_die( __( 'Can’t create an empty site.' ) ); 39 40 $blog = $_POST['blog']; 41 } 42 43 $blog = $_POST['blog']; 41 44 $domain = ''; 42 if ( preg_match( '|^([a-zA-Z0-9-])+$|', $blog['domain'] ) ) 45 if ( preg_match( '|^([a-zA-Z0-9-])+$|', $blog['domain'] ) ) { 43 46 $domain = strtolower( $blog['domain'] ); 47 } 44 48 45 49 // If not a subdomain installation, make sure the domain isn't a reserved word … … 50 54 wp_die( 51 55 /* translators: %s: reserved names list */ 52 sprintf( __( 'The following words are reserved for use by WordPress functions and cannot be used as blog names: %s' ), 56 sprintf( 57 __( 'The following words are reserved for use by WordPress functions and cannot be used as blog names: %s' ), 53 58 '<code>' . implode( '</code>, <code>', $subdirectory_reserved_names ) . '</code>' 54 59 ) … … 60 65 61 66 $meta = array( 62 'public' => 1 67 'public' => 1, 63 68 ); 64 69 … … 77 82 } 78 83 79 if ( empty( $domain ) ) 84 if ( empty( $domain ) ) { 80 85 wp_die( __( 'Missing or invalid site address.' ) ); 86 } 81 87 82 88 if ( isset( $blog['email'] ) && '' === trim( $blog['email'] ) ) { … … 98 104 99 105 $password = 'N/A'; 100 $user_id = email_exists($email);101 if ( ! $user_id ) { // Create a new user with a random password106 $user_id = email_exists( $email ); 107 if ( ! $user_id ) { // Create a new user with a random password 102 108 /** 103 109 * Fires immediately before a new user is created via the network site-new.php page. … … 114 120 } 115 121 $password = wp_generate_password( 12, false ); 116 $user_id = wpmu_create_user( $domain, $password, $email );122 $user_id = wpmu_create_user( $domain, $password, $email ); 117 123 if ( false === $user_id ) { 118 124 wp_die( __( 'There was an error creating the user.' ) ); … … 133 139 $wpdb->show_errors(); 134 140 if ( ! is_wp_error( $id ) ) { 135 if ( ! is_super_admin( $user_id ) && ! get_user_option( 'primary_blog', $user_id ) ) {141 if ( ! is_super_admin( $user_id ) && ! get_user_option( 'primary_blog', $user_id ) ) { 136 142 update_user_option( $user_id, 'primary_blog', $id, true ); 137 143 } … … 146 152 sprintf( 147 153 /* translators: 1: user login, 2: site url, 3: site name/title */ 148 __( 'New site created by %1$s 154 __( 155 'New site created by %1$s 149 156 150 157 Address: %2$s 151 Name: %3$s' ), 158 Name: %3$s' 159 ), 152 160 $current_user->user_login, 153 161 get_site_url( $id ), … … 161 169 ); 162 170 wpmu_welcome_notification( $id, $user_id, $password, $title, array( 'public' => 1 ) ); 163 wp_redirect( add_query_arg( array( 'update' => 'added', 'id' => $id ), 'site-new.php' ) ); 171 wp_redirect( 172 add_query_arg( 173 array( 174 'update' => 'added', 175 'id' => $id, 176 ), 'site-new.php' 177 ) 178 ); 164 179 exit; 165 180 } else { … … 168 183 } 169 184 170 if ( isset( $_GET['update']) ) {185 if ( isset( $_GET['update'] ) ) { 171 186 $messages = array(); 172 if ( 'added' == $_GET['update'] ) 187 if ( 'added' == $_GET['update'] ) { 173 188 $messages[] = sprintf( 174 189 /* translators: 1: dashboard url, 2: network admin edit url */ … … 177 192 network_admin_url( 'site-info.php?id=' . absint( $_GET['id'] ) ) 178 193 ); 179 } 180 181 $title = __('Add New Site'); 194 } 195 } 196 197 $title = __( 'Add New Site' ); 182 198 $parent_file = 'sites.php'; 183 199 … … 192 208 <?php 193 209 if ( ! empty( $messages ) ) { 194 foreach ( $messages as $msg ) 210 foreach ( $messages as $msg ) { 195 211 echo '<div id="message" class="updated notice is-dismissible"><p>' . $msg . '</p></div>'; 196 } ?> 212 } 213 } 214 ?> 197 215 <form method="post" action="<?php echo network_admin_url( 'site-new.php?action=add-site' ); ?>" novalidate="novalidate"> 198 <?php wp_nonce_field( 'add-blog', '_wpnonce_add-blog' ) ?>216 <?php wp_nonce_field( 'add-blog', '_wpnonce_add-blog' ); ?> 199 217 <table class="form-table"> 200 218 <tr class="form-field form-required"> 201 <th scope="row"><label for="site-address"><?php _e( 'Site Address (URL)' ) ?></label></th>219 <th scope="row"><label for="site-address"><?php _e( 'Site Address (URL)' ); ?></label></th> 202 220 <td> 203 221 <?php if ( is_subdomain_install() ) { ?> 204 222 <input name="blog[domain]" type="text" class="regular-text" id="site-address" aria-describedby="site-address-desc" autocapitalize="none" autocorrect="off"/><span class="no-break">.<?php echo preg_replace( '|^www\.|', '', get_network()->domain ); ?></span> 205 <?php } else { 206 echo get_network()->domain . get_network()->path ?><input name="blog[domain]" type="text" class="regular-text" id="site-address" aria-describedby="site-address-desc" autocapitalize="none" autocorrect="off" /> 207 <?php } 223 <?php 224 } else { 225 echo get_network()->domain . get_network()->path 226 ?> 227 <input name="blog[domain]" type="text" class="regular-text" id="site-address" aria-describedby="site-address-desc" autocapitalize="none" autocorrect="off" /> 228 <?php 229 } 208 230 echo '<p class="description" id="site-address-desc">' . __( 'Only lowercase letters (a-z), numbers, and hyphens are allowed.' ) . '</p>'; 209 231 ?> … … 211 233 </tr> 212 234 <tr class="form-field form-required"> 213 <th scope="row"><label for="site-title"><?php _e( 'Site Title' ) ?></label></th>235 <th scope="row"><label for="site-title"><?php _e( 'Site Title' ); ?></label></th> 214 236 <td><input name="blog[title]" type="text" class="regular-text" id="site-title" /></td> 215 237 </tr> … … 231 253 } 232 254 233 wp_dropdown_languages( array( 234 'name' => 'WPLANG', 235 'id' => 'site-language', 236 'selected' => $lang, 237 'languages' => $languages, 238 'translations' => $translations, 239 'show_available_translations' => current_user_can( 'install_languages' ), 240 ) ); 255 wp_dropdown_languages( 256 array( 257 'name' => 'WPLANG', 258 'id' => 'site-language', 259 'selected' => $lang, 260 'languages' => $languages, 261 'translations' => $translations, 262 'show_available_translations' => current_user_can( 'install_languages' ), 263 ) 264 ); 241 265 ?> 242 266 </td> … … 244 268 <?php endif; // Languages. ?> 245 269 <tr class="form-field form-required"> 246 <th scope="row"><label for="admin-email"><?php _e( 'Admin Email' ) ?></label></th>270 <th scope="row"><label for="admin-email"><?php _e( 'Admin Email' ); ?></label></th> 247 271 <td><input name="blog[email]" type="email" class="regular-text wp-suggest-user" id="admin-email" data-autocomplete-type="search" data-autocomplete-field="user_email" /></td> 248 272 </tr> 249 273 <tr class="form-field"> 250 <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 a link to set the password will be mailed to this email address.' )?></td>274 <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 a link to set the password will be mailed to this email address.' ); ?></td> 251 275 </tr> 252 276 </table>
Note: See TracChangeset
for help on using the changeset viewer.