Ticket #17630: wp-signup.php_code_tidy.patch
| File wp-signup.php_code_tidy.patch, 52.3 KB (added by , 10 years ago) |
|---|
-
src/wp-signup.php
1 1 <?php 2 2 3 3 /** Sets up the WordPress Environment. */ 4 require( dirname( __FILE__) . '/wp-load.php' );4 require( dirname( __FILE__ ) . '/wp-load.php' ); 5 5 6 6 add_action( 'wp_head', 'wp_no_robots' ); 7 7 8 8 require( dirname( __FILE__ ) . '/wp-blog-header.php' ); 9 9 10 if ( is_array( get_network_option( 'illegal_names' ) ) && isset( $_GET[ 'new' ] ) && in_array( $_GET[ 'new'], get_network_option( 'illegal_names' ) ) ) {10 if ( is_array( get_network_option( 'illegal_names' ) ) && isset( $_GET['new'] ) && in_array( $_GET['new'], get_network_option( 'illegal_names' ) ) ) { 11 11 wp_redirect( network_home_url() ); 12 12 die(); 13 13 } … … 25 25 */ 26 26 do_action( 'signup_header' ); 27 27 } 28 28 29 add_action( 'wp_head', 'do_signup_header' ); 29 30 30 if ( ! is_multisite() ) {31 if ( ! is_multisite() ) { 31 32 wp_redirect( wp_registration_url() ); 32 33 die(); 33 34 } 34 35 35 if ( ! is_main_site() ) {36 if ( ! is_main_site() ) { 36 37 wp_redirect( network_site_url( 'wp-signup.php' ) ); 37 38 die(); 38 39 } 39 40 41 $network_site_url = network_site_url( 'wp-signup.php' ); 42 /** 43 * Filter the signup location for this WordPress installation. 44 * 45 * @since 4.3.0 46 * 47 * @param string $network_site_url URL of the signup page for WordPress. 48 */ 49 $signup_location = apply_filters( 'wp_signup_location', $network_site_url ); 50 $signup_location_parts = explode( '?', $signup_location ); 51 52 // Redirect to the true signup location if the URL differs from default. 53 if ( $signup_location_parts[0] !== $network_site_url ) { 54 wp_redirect( $signup_location ); 55 exit; 56 } 57 40 58 // Fix for page title 41 59 $wp_query->is_404 = false; 42 60 … … 48 66 function wpmu_signup_stylesheet() { 49 67 ?> 50 68 <style type="text/css"> 51 .mu_register { width: 90%; margin:0 auto; } 52 .mu_register form { margin-top: 2em; } 53 .mu_register .error { font-weight:700; padding:10px; color:#333333; background:#FFEBE8; border:1px solid #CC0000; } 69 .mu_register { 70 width: 90%; 71 margin: 0 auto; 72 } 73 74 .mu_register form { 75 margin-top: 2em; 76 } 77 78 .mu_register .error { 79 font-weight: 700; 80 padding: 10px; 81 color: #333333; 82 background: #FFEBE8; 83 border: 1px solid #CC0000; 84 } 85 54 86 .mu_register input[type="submit"], 55 .mu_register #blog_title, 56 .mu_register #user_email, 57 .mu_register #blogname, 58 .mu_register #user_name { width:100%; font-size: 24px; margin:5px 0; } 87 .mu_register #blog_title, 88 .mu_register #user_email, 89 .mu_register #blogname, 90 .mu_register #user_name { 91 width: 100%; 92 font-size: 24px; 93 margin: 5px 0; 94 } 95 59 96 .mu_register .prefix_address, 60 .mu_register .suffix_address {font-size: 18px;display:inline; } 61 .mu_register label { font-weight:700; font-size:15px; display:block; margin:10px 0; } 62 .mu_register label.checkbox { display:inline; } 63 .mu_register .mu_alert { font-weight:700; padding:10px; color:#333333; background:#ffffe0; border:1px solid #e6db55; } 97 .mu_register .suffix_address { 98 font-size: 18px; 99 display: inline; 100 } 101 102 .mu_register label { 103 font-weight: 700; 104 font-size: 15px; 105 display: block; 106 margin: 10px 0; 107 } 108 109 .mu_register label.checkbox { 110 display: inline; 111 } 112 113 .mu_register .mu_alert { 114 font-weight: 700; 115 padding: 10px; 116 color: #333333; 117 background: #ffffe0; 118 border: 1px solid #e6db55; 119 } 64 120 </style> 65 121 <?php 66 122 } 67 123 68 124 add_action( 'wp_head', 'wpmu_signup_stylesheet' ); 125 126 /** 127 * Fires just before the site sign-up header. 128 * 129 * @since 4.4.0 130 */ 131 do_action( 'before_signup_header ' ); 69 132 get_header(); 70 133 71 134 /** … … 76 139 do_action( 'before_signup_form' ); 77 140 ?> 78 141 <div id="signup-content" class="widecolumn"> 79 <div class="mu_register wp-signup-container"> 80 <?php 81 /** 82 * Generates and displays the Signup and Create Site forms 83 * 84 * @since MU 85 * 86 * @param string $blogname The new site name 87 * @param string $blog_title The new site title 88 * @param array $errors 89 */ 90 function show_blog_form( $blogname = '', $blog_title = '', $errors = '' ) { 91 $current_site = get_current_site(); 92 // Blog name 93 if ( !is_subdomain_install() ) 94 echo '<label for="blogname">' . __('Site Name:') . '</label>'; 95 else 96 echo '<label for="blogname">' . __('Site Domain:') . '</label>'; 142 <div class="mu_register wp-signup-container"> 143 <?php 144 /** 145 * Generates and displays the Signup and Create Site forms 146 * 147 * @since MU 148 * 149 * @param string $blogname 150 * @param string $blog_title 151 * @param WP_Error $errors 152 */ 153 function show_blog_form( $blogname = '', $blog_title = '', $errors = null ) { 154 $current_site = get_current_site(); 155 // Blog name 156 if ( ! is_subdomain_install() ) { 157 echo '<label for="blogname">' . __( 'Site Name:' ) . '</label>'; 158 } else { 159 echo '<label for="blogname">' . __( 'Site Domain:' ) . '</label>'; 160 } 97 161 98 if ( $errmsg = $errors->get_error_message('blogname') ) { ?>99 <p class="error"><?php echo $errmsg ?></p>100 <?php }162 if ( $errmsg = $errors->get_error_message( 'blogname' ) ) { ?> 163 <p class="error"><?php echo $errmsg ?></p> 164 <?php } 101 165 102 if ( !is_subdomain_install() ) 103 echo '<span class="prefix_address">' . $current_site->domain . $current_site->path . '</span><input name="blogname" type="text" id="blogname" value="'. esc_attr($blogname) .'" maxlength="60" /><br />'; 104 else 105 echo '<input name="blogname" type="text" id="blogname" value="'.esc_attr($blogname).'" maxlength="60" /><span class="suffix_address">.' . ( $site_domain = preg_replace( '|^www\.|', '', $current_site->domain ) ) . '</span><br />'; 166 if ( ! is_subdomain_install() ) { 167 echo '<span class="prefix_address">' . $current_site->domain . $current_site->path . '</span><input name="blogname" type="text" id="blogname" value="' . esc_attr( $blogname ) . '" maxlength="60" /><br />'; 168 } else { 169 echo '<input name="blogname" type="text" id="blogname" value="' . esc_attr( $blogname ) . '" maxlength="60" /><span class="suffix_address">.' . ( $site_domain = preg_replace( '|^www\.|', '', $current_site->domain ) ) . '</span><br />'; 170 } 106 171 107 if ( !is_user_logged_in() ) { 108 if ( !is_subdomain_install() ) 109 $site = $current_site->domain . $current_site->path . __( 'sitename' ); 110 else 111 $site = __( 'domain' ) . '.' . $site_domain . $current_site->path; 112 echo '<p>(<strong>' . sprintf( __('Your address will be %s.'), $site ) . '</strong>) ' . __( 'Must be at least 4 characters, letters and numbers only. It cannot be changed, so choose carefully!' ) . '</p>'; 113 } 172 if ( ! is_user_logged_in() ) { 173 if ( ! is_subdomain_install() ) { 174 $site = $current_site->domain . $current_site->path . __( 'sitename' ); 175 } else { 176 $site = __( 'domain' ) . '.' . $site_domain . $current_site->path; 177 } 178 echo '<p>(<strong>' . sprintf( __( 'Your address will be %s.' ), $site ) . '</strong>) ' . __( 'Must be at least 4 characters, letters and numbers only. It cannot be changed, so choose carefully!' ) . '</p>'; 179 } 114 180 115 // Blog Title116 ?>117 <label for="blog_title"><?php _e('Site Title:') ?></label>118 <?php if ( $errmsg = $errors->get_error_message('blog_title') ) { ?>119 <p class="error"><?php echo $errmsg ?></p>120 <?php }121 echo '<input name="blog_title" type="text" id="blog_title" value="'.esc_attr($blog_title).'" />';122 ?>181 // Blog Title 182 ?> 183 <label for="blog_title"><?php _e( 'Site Title:' ) ?></label> 184 <?php if ( $errmsg = $errors->get_error_message( 'blog_title' ) ) { ?> 185 <p class="error"><?php echo $errmsg ?></p> 186 <?php } 187 echo '<input name="blog_title" type="text" id="blog_title" value="' . esc_attr( $blog_title ) . '" />'; 188 ?> 123 189 124 <div id="privacy"> 125 <p class="privacy-intro"> 126 <label for="blog_public_on"><?php _e('Privacy:') ?></label> 127 <?php _e( 'Allow search engines to index this site.' ); ?> 128 <br style="clear:both" /> 129 <label class="checkbox" for="blog_public_on"> 130 <input type="radio" id="blog_public_on" name="blog_public" value="1" <?php if ( !isset( $_POST['blog_public'] ) || $_POST['blog_public'] == '1' ) { ?>checked="checked"<?php } ?> /> 131 <strong><?php _e( 'Yes' ); ?></strong> 132 </label> 133 <label class="checkbox" for="blog_public_off"> 134 <input type="radio" id="blog_public_off" name="blog_public" value="0" <?php if ( isset( $_POST['blog_public'] ) && $_POST['blog_public'] == '0' ) { ?>checked="checked"<?php } ?> /> 135 <strong><?php _e( 'No' ); ?></strong> 136 </label> 137 </p> 138 </div> 190 <div id="privacy"> 191 <p class="privacy-intro"> 192 <label for="blog_public_on"><?php _e( 'Privacy:' ) ?></label> 193 <?php _e( 'Allow search engines to index this site.' ); ?> 194 <br style="clear:both"/> 195 <label class="checkbox" for="blog_public_on"> 196 <input type="radio" id="blog_public_on" name="blog_public" value="1" 197 <?php if ( ! isset( $_POST['blog_public'] ) || '1' == $_POST['blog_public'] ) { ?>checked="checked"<?php } ?> /> 198 <strong><?php _e( 'Yes' ); ?></strong> 199 </label> 200 <label class="checkbox" for="blog_public_off"> 201 <input type="radio" id="blog_public_off" name="blog_public" value="0" 202 <?php if ( isset( $_POST['blog_public'] ) && '0' == $_POST['blog_public'] ) { ?>checked="checked"<?php } ?> /> 203 <strong><?php _e( 'No' ); ?></strong> 204 </label> 205 </p> 206 </div> 139 207 140 <?php141 /**142 * Fires after the site sign-up form.143 *144 * @since 3.0.0145 *146 * @param array $errors An array possibly containing 'blogname' or 'blog_title' errors.147 */148 do_action( 'signup_blogform', $errors );149 }208 <?php 209 /** 210 * Fires after the site sign-up form. 211 * 212 * @since 3.0.0 213 * 214 * @param array $errors An array possibly containing 'blogname' or 'blog_title' errors. 215 */ 216 do_action( 'signup_blogform', $errors ); 217 } 150 218 151 /** 152 * Validate the new site signup 153 * 154 * @since MU 155 * 156 * @return array Contains the new site data and error messages. 157 */ 158 function validate_blog_form() { 159 $user = ''; 160 if ( is_user_logged_in() ) 161 $user = wp_get_current_user(); 219 /** 220 * Validate the new site signup 221 * 222 * @since MU 223 * 224 * @return array Contains the new site data and error messages. 225 */ 226 function validate_blog_form() { 227 $user = ''; 228 if ( is_user_logged_in() ) { 229 $user = wp_get_current_user(); 230 } 162 231 163 return wpmu_validate_blog_signup($_POST['blogname'], $_POST['blog_title'], $user);164 }232 return wpmu_validate_blog_signup( $_POST['blogname'], $_POST['blog_title'], $user ); 233 } 165 234 166 /** 167 * Display user registration form 168 * 169 * @since MU 170 * 171 * @param string $user_name The entered username 172 * @param string $user_email The entered email address 173 * @param array $errors 174 */ 175 function show_user_form($user_name = '', $user_email = '', $errors = '') { 176 // User name 177 echo '<label for="user_name">' . __('Username:') . '</label>'; 178 if ( $errmsg = $errors->get_error_message('user_name') ) { 179 echo '<p class="error">'.$errmsg.'</p>'; 180 } 181 echo '<input name="user_name" type="text" id="user_name" value="'. esc_attr($user_name) .'" maxlength="60" /><br />'; 182 _e( '(Must be at least 4 characters, letters and numbers only.)' ); 183 ?> 235 /** 236 * Display user registration form 237 * 238 * @since MU 239 * 240 * @param string $user_name The entered username 241 * @param string $user_email The entered email address 242 * @param WP_Error $errors 243 */ 244 function show_user_form( $user_name = '', $user_email = '', $errors = null ) { 184 245 185 <label for="user_email"><?php _e( 'Email Address:' ) ?></label> 186 <?php if ( $errmsg = $errors->get_error_message('user_email') ) { ?> 187 <p class="error"><?php echo $errmsg ?></p> 188 <?php } ?> 189 <input name="user_email" type="email" id="user_email" value="<?php echo esc_attr($user_email) ?>" maxlength="200" /><br /><?php _e('We send your registration email to this address. (Double-check your email address before continuing.)') ?> 190 <?php 191 if ( $errmsg = $errors->get_error_message('generic') ) { 192 echo '<p class="error">' . $errmsg . '</p>'; 193 } 194 /** 195 * Fires at the end of the user registration form on the site sign-up form. 196 * 197 * @since 3.0.0 198 * 199 * @param array $errors An array possibly containing 'user_name' or 'user_email' errors. 200 */ 201 do_action( 'signup_extra_fields', $errors ); 202 } 246 // User name 247 echo '<label for="user_name">' . __( 'Username:' ) . '</label>'; 248 if ( $errmsg = $errors->get_error_message( 'user_name' ) ) { 249 echo '<p class="error">' . $errmsg . '</p>'; 250 } 251 echo '<input name="user_name" type="text" id="user_name" value="' . esc_attr( $user_name ) . '" maxlength="60" /><br />'; 252 _e( '(Must be at least 4 characters, letters and numbers only.)' ); 253 ?> 203 254 204 /** 205 * Validate user signup name and email 206 * 207 * @since MU 208 * 209 * @return array Contains username, email, and error messages. 210 */ 211 function validate_user_form() { 212 return wpmu_validate_user_signup($_POST['user_name'], $_POST['user_email']); 213 } 255 <label for="user_email"><?php _e( 'Email Address:' ) ?></label> 256 <?php if ( $errmsg = $errors->get_error_message( 'user_email' ) ) { ?> 257 <p class="error"><?php echo $errmsg ?></p> 258 <?php } ?> 259 <input name="user_email" type="email" id="user_email" value="<?php echo esc_attr( $user_email ) ?>" 260 maxlength="200"/> 261 <br/><?php _e( 'We send your registration email to this address. (Double-check your email address before continuing.)' ) ?> 262 <?php 263 if ( $errmsg = $errors->get_error_message( 'generic' ) ) { 264 echo '<p class="error">' . $errmsg . '</p>'; 265 } 266 /** 267 * Fires at the end of the user registration form on the site sign-up form. 268 * 269 * @since 3.0.0 270 * 271 * @param array $errors An array possibly containing 'user_name' or 'user_email' errors. 272 */ 273 do_action( 'signup_extra_fields', $errors ); 274 } 214 275 215 /** 216 * Allow returning users to sign up for another site 217 * 218 * @since MU 219 * 220 * @param string $blogname The new site name 221 * @param string $blog_title The new blog title 222 * @param array $errors 223 */ 224 function signup_another_blog( $blogname = '', $blog_title = '', $errors = '' ) { 225 $current_user = wp_get_current_user(); 276 /** 277 * Validate user signup name and email 278 * 279 * @since MU 280 * 281 * @return array Contains username, email, and error messages. 282 */ 283 function validate_user_form() { 284 return wpmu_validate_user_signup( $_POST['user_name'], $_POST['user_email'] ); 285 } 226 286 227 if ( ! is_wp_error($errors) ) { 228 $errors = new WP_Error(); 229 } 287 /** 288 * Allow returning users to sign up for another site 289 * 290 * since MU 291 * 292 * @param string $blogname The new site name 293 * @param string $blog_title The new blog title 294 * @param WP_Error $errors 295 */ 296 function signup_another_blog( $blogname = '', $blog_title = '', $errors = null ) { 297 $current_user = wp_get_current_user(); 230 298 231 $signup_defaults = array( 232 'blogname' => $blogname, 233 'blog_title' => $blog_title, 234 'errors' => $errors 235 ); 299 if ( ! is_wp_error( $errors ) ) { 300 $errors = new WP_Error(); 301 } 236 302 237 /** 238 * Filter the default site sign-up variables. 239 * 240 * @since 3.0.0 241 * 242 * @param array $signup_defaults { 243 * An array of default site sign-up variables. 244 * 245 * @type string $blogname The site blogname. 246 * @type string $blog_title The site title. 247 * @type array $errors An array possibly containing 'blogname' or 'blog_title' errors. 248 * } 249 */ 250 $filtered_results = apply_filters( 'signup_another_blog_init', $signup_defaults ); 303 $signup_defaults = array( 304 'blogname' => $blogname, 305 'blog_title' => $blog_title, 306 'errors' => $errors, 307 ); 251 308 252 $blogname = $filtered_results['blogname']; 253 $blog_title = $filtered_results['blog_title']; 254 $errors = $filtered_results['errors']; 309 /** 310 * Filter the default site sign-up variables. 311 * 312 * @since 3.0.0 313 * 314 * @param array $signup_defaults { 315 * An array of default site sign-up variables. 316 * 317 * @type string $blogname The site blogname. 318 * @type string $blog_title The site title. 319 * @type array $errors An array possibly containing 'blogname' or 'blog_title' errors. 320 * } 321 */ 322 $filtered_results = apply_filters( 'signup_another_blog_init', $signup_defaults ); 255 323 256 echo '<h2>' . sprintf( __( 'Get <em>another</em> %s site in seconds' ), get_current_site()->site_name ) . '</h2>'; 324 $blogname = $filtered_results['blogname']; 325 $blog_title = $filtered_results['blog_title']; 326 $errors = $filtered_results['errors']; 257 327 258 if ( $errors->get_error_code() ) { 259 echo '<p>' . __( 'There was a problem, please correct the form below and try again.' ) . '</p>'; 260 } 261 ?> 262 <p><?php printf( __( 'Welcome back, %s. By filling out the form below, you can <strong>add another site to your account</strong>. There is no limit to the number of sites you can have, so create to your heart’s content, but write responsibly!' ), $current_user->display_name ) ?></p> 328 echo '<h2>' . sprintf( __( 'Get <em>another</em> %s site in seconds' ), get_current_site()->site_name ) . '</h2>'; 263 329 264 <?php 265 $blogs = get_blogs_of_user($current_user->ID); 266 if ( !empty($blogs) ) { ?> 330 if ( $errors->get_error_code() ) { 331 echo '<p>' . __( 'There was a problem, please correct the form below and try again.' ) . '</p>'; 332 } 333 ?> 334 <p><?php printf( __( 'Welcome back, %s. By filling out the form below, you can <strong>add another site to your account</strong>. There is no limit to the number of sites you can have, so create to your heart’s content, but write responsibly!' ), $current_user->display_name ) ?></p> 267 335 268 <p><?php _e( 'Sites you are already a member of:' ) ?></p> 269 <ul> 270 <?php foreach ( $blogs as $blog ) { 271 $home_url = get_home_url( $blog->userblog_id ); 272 echo '<li><a href="' . esc_url( $home_url ) . '">' . $home_url . '</a></li>'; 273 } ?> 274 </ul> 275 <?php } ?> 336 <?php 337 $blogs = get_blogs_of_user( $current_user->ID ); 338 if ( ! empty( $blogs ) ) { ?> 276 339 277 <p><?php _e( 'If you’re not going to use a great site domain, leave it for a new user. Now have at it!' ) ?></p> 278 <form id="setupform" method="post" action="wp-signup.php"> 279 <input type="hidden" name="stage" value="gimmeanotherblog" /> 280 <?php 340 <p><?php _e( 'Sites you are already a member of:' ) ?></p> 341 <ul> 342 <?php 343 foreach ( $blogs as $blog ) { 344 $home_url = get_home_url( $blog->userblog_id ); 345 echo '<li><a href="' . esc_url( $home_url ) . '">' . $home_url . '</a></li>'; 346 } 347 ?> 348 </ul> 349 <?php } ?> 350 351 <p><?php _e( 'If you’re not going to use a great site domain, leave it for a new user. Now have at it!' ) ?></p> 352 <form id="setupform" method="post" action="wp-signup.php"> 353 <input type="hidden" name="stage" value="gimmeanotherblog"/> 354 <?php 355 /** 356 * Hidden sign-up form fields output when creating another site or user. 357 * 358 * @since MU 359 * 360 * @param string $context A string describing the steps of the sign-up process. The value can be 361 * 'create-another-site', 'validate-user', or 'validate-site'. 362 */ 363 do_action( 'signup_hidden_fields', 'create-another-site' ); 364 ?> 365 <?php show_blog_form( $blogname, $blog_title, $errors ); ?> 366 <p class="submit"><input type="submit" name="submit" class="submit" 367 value="<?php esc_attr_e( 'Create Site' ) ?>"/></p> 368 </form> 369 <?php 370 } 371 281 372 /** 282 * Hidden sign-up form fields output when creating another site or user.373 * Validate a new blog signup 283 374 * 284 375 * @since MU 285 376 * 286 * @ param string $context A string describing the steps of the sign-up process. The value can be287 * 'create-another-site', 'validate-user', or 'validate-site'.377 * @return null|bool True if blog signup was validated, false if error. 378 * The function halts all execution if the user is not logged in. 288 379 */ 289 do_action( 'signup_hidden_fields', 'create-another-site' ); 290 ?> 291 <?php show_blog_form($blogname, $blog_title, $errors); ?> 292 <p class="submit"><input type="submit" name="submit" class="submit" value="<?php esc_attr_e( 'Create Site' ) ?>" /></p> 293 </form> 294 <?php 295 } 380 function validate_another_blog_signup() { 381 global $wpdb, $blogname, $blog_title, $errors, $domain, $path; 382 $current_user = wp_get_current_user(); 383 if ( ! is_user_logged_in() ) { 384 die(); 385 } 296 386 297 /** 298 * Validate a new blog signup 299 * 300 * @since MU 301 * 302 * @return null|bool True if blog signup was validated, false if error. 303 * The function halts all execution if the user is not logged in. 304 */ 305 function validate_another_blog_signup() { 306 global $wpdb, $blogname, $blog_title, $errors, $domain, $path; 307 $current_user = wp_get_current_user(); 308 if ( ! is_user_logged_in() ) { 309 die(); 310 } 387 $result = validate_blog_form(); 311 388 312 $result = validate_blog_form(); 389 // Extracted values set/overwrite globals. 390 $domain = $result['domain']; 391 $path = $result['path']; 392 $blogname = $result['blogname']; 393 $blog_title = $result['blog_title']; 394 $errors = $result['errors']; 313 395 314 // Extracted values set/overwrite globals. 315 $domain = $result['domain']; 316 $path = $result['path']; 317 $blogname = $result['blogname']; 318 $blog_title = $result['blog_title']; 319 $errors = $result['errors']; 396 if ( $errors->get_error_code() ) { 397 signup_another_blog( $blogname, $blog_title, $errors ); 320 398 321 if ( $errors->get_error_code() ) { 322 signup_another_blog($blogname, $blog_title, $errors); 323 return false; 324 } 399 return false; 400 } 325 401 326 $public = (int) $_POST['blog_public'];402 $public = (int) $_POST['blog_public']; 327 403 328 $blog_meta_defaults = array(329 'lang_id' => 1,330 'public' => $public331 );404 $blog_meta_defaults = array( 405 'lang_id' => 1, 406 'public' => $public, 407 ); 332 408 333 /**334 * Filter the new site meta variables.335 *336 * @since MU337 * @deprecated 3.0.0 Use the 'add_signup_meta' filter instead.338 *339 * @param array $blog_meta_defaults An array of default blog meta variables.340 */341 $meta_defaults = apply_filters( 'signup_create_blog_meta', $blog_meta_defaults );342 /**343 * Filter the new default site meta variables.344 *345 * @since 3.0.0346 *347 * @param array $meta {348 * An array of default site meta variables.349 *350 * @type int $lang_idThe language ID.351 *@type int $blog_public Whether search engines should be discouraged from indexing the site. 1 for true, 0 for false.352 * }353 */354 $meta = apply_filters( 'add_signup_meta', $meta_defaults );409 /** 410 * Filter the new site meta variables. 411 * 412 * @since MU 413 * @deprecated 3.0.0 Use the 'add_signup_meta' filter instead. 414 * 415 * @param array $blog_meta_defaults An array of default blog meta variables. 416 */ 417 $meta_defaults = apply_filters( 'signup_create_blog_meta', $blog_meta_defaults ); 418 /** 419 * Filter the new default site meta variables. 420 * 421 * @since 3.0.0 422 * 423 * @param array $meta { 424 * An array of default site meta variables. 425 * 426 * @type int $lang_id The language ID. 427 * @type int $blog_public Whether search engines should be discouraged from indexing the site. 1 for true, 0 for false. 428 * } 429 */ 430 $meta = apply_filters( 'add_signup_meta', $meta_defaults ); 355 431 356 $blog_id = wpmu_create_blog( $domain, $path, $blog_title, $current_user->ID, $meta, $wpdb->siteid );432 $blog_id = wpmu_create_blog( $domain, $path, $blog_title, $current_user->ID, $meta, $wpdb->siteid ); 357 433 358 if ( is_wp_error( $blog_id ) ) {359 return false;360 }434 if ( is_wp_error( $blog_id ) ) { 435 return false; 436 } 361 437 362 confirm_another_blog_signup( $domain, $path, $blog_title, $current_user->user_login, $current_user->user_email, $meta, $blog_id ); 363 return true; 364 } 438 confirm_another_blog_signup( $domain, $path, $blog_title, $current_user->user_login, $current_user->user_email, $meta, $blog_id ); 365 439 366 /** 367 * Confirm a new site signup 368 * 369 * @since MU 370 * @since 4.4.0 Added the `$blog_id` parameter. 371 * 372 * @param string $domain The domain URL 373 * @param string $path The site root path 374 * @param string $blog_title The blog title 375 * @param string $user_name The username 376 * @param string $user_email The user's email address 377 * @param array $meta Any additional meta from the 'add_signup_meta' filter in validate_blog_signup() 378 * @param int $blog_id The blog ID 379 */ 380 function confirm_another_blog_signup( $domain, $path, $blog_title, $user_name, $user_email = '', $meta = array(), $blog_id = 0 ) { 440 return true; 441 } 381 442 382 if ( $blog_id ) { 383 switch_to_blog( $blog_id ); 384 $home_url = home_url( '/' ); 385 $login_url = wp_login_url(); 386 restore_current_blog(); 387 } else { 388 $home_url = 'http://' . $domain . $path; 389 $login_url = 'http://' . $domain . $path . 'wp-login.php'; 390 } 443 /** 444 * Confirm a new site signup 445 * 446 * @since MU 447 * @since 4.4.0 Added the `$blog_id` parameter. 448 * 449 * @param string $domain The domain URL 450 * @param string $path The site root path 451 * @param string $blog_title The blog title 452 * @param string $user_name The username 453 * @param string $user_email The user's email address 454 * @param array $meta Any additional meta from the 'add_signup_meta' filter in validate_blog_signup() 455 * @param int $blog_id The blog ID 456 */ 457 function confirm_another_blog_signup( $domain, $path, $blog_title, $user_name, $user_email = '', $meta = array(), $blog_id = 0 ) { 391 458 392 $site = sprintf( '<a href="%1$s">%2$s</a>', 393 esc_url( $home_url ), 394 $blog_title 395 ); 459 if ( $blog_id ) { 460 switch_to_blog( $blog_id ); 461 $home_url = home_url( '/' ); 462 $login_url = wp_login_url(); 463 restore_current_blog(); 464 } else { 465 $home_url = 'http://' . $domain . $path; 466 $login_url = 'http://' . $domain . $path . 'wp-login.php'; 467 } 396 468 397 ?> 398 <h2><?php printf( __( 'The site %s is yours.' ), $site ); ?></h2> 399 <p> 400 <?php printf( 401 __( '<a href="%1$s">%2$s</a> is your new site. <a href="%3$s">Log in</a> as “%4$s” using your existing password.' ), 402 esc_url( $home_url ), 403 untrailingslashit( $domain . $path ), 404 esc_url( $login_url ), 405 $user_name 406 ); ?> 407 </p> 408 <?php 409 /** 410 * Fires when the site or user sign-up process is complete. 411 * 412 * @since 3.0.0 413 */ 414 do_action( 'signup_finished' ); 415 } 469 $site = sprintf( '<a href="%1$s">%2$s</a>', 470 esc_url( $home_url ), 471 $blog_title 472 ); 416 473 417 /** 418 * Setup the new user signup process 419 * 420 * @since MU 421 * 422 * @param string $user_name The username 423 * @param string $user_email The user's email 424 * @param array $errors 425 */ 426 function signup_user( $user_name = '', $user_email = '', $errors = '' ) { 427 global $active_signup; 474 ?> 475 <h2><?php printf( __( 'The site %s is yours.' ), $site ); ?></h2> 476 <p> 477 <?php 478 printf( 479 __( '<a href="%1$s">%2$s</a> is your new site. <a href="%3$s">Log in</a> as “%4$s” using your existing password.' ), 480 esc_url( $home_url ), 481 untrailingslashit( $domain . $path ), 482 esc_url( $login_url ), 483 $user_name 484 ); 485 ?> 486 </p> 487 <?php 488 /** 489 * Fires when the site or user sign-up process is complete. 490 * 491 * @since 3.0.0 492 */ 493 do_action( 'signup_finished' ); 494 } 428 495 429 if ( !is_wp_error($errors) ) 430 $errors = new WP_Error(); 496 /** 497 * Setup the new user signup process 498 * 499 * @since MU 500 * 501 * @param string $user_name The username 502 * @param string $user_email The user's email 503 * @param array $errors 504 */ 505 function signup_user( $user_name = '', $user_email = '', $errors = array() ) { 506 global $active_signup; 431 507 432 $signup_for = isset( $_POST[ 'signup_for' ] ) ? esc_html( $_POST[ 'signup_for' ] ) : 'blog'; 508 if ( ! is_wp_error( $errors ) ) { 509 $errors = new WP_Error(); 510 } 433 511 434 $signup_user_defaults = array( 435 'user_name' => $user_name, 436 'user_email' => $user_email, 437 'errors' => $errors, 438 ); 512 $signup_for = isset( $_POST['signup_for'] ) ? esc_html( $_POST['signup_for'] ) : 'blog'; 439 513 440 /** 441 * Filter the default user variables used on the user sign-up form. 442 * 443 * @since 3.0.0 444 * 445 * @param array $signup_user_defaults { 446 * An array of default user variables. 447 * 448 * @type string $user_name The user username. 449 * @type string $user_email The user email address. 450 * @type array $errors An array of possible errors relevant to the sign-up user. 451 * } 452 */ 453 $filtered_results = apply_filters( 'signup_user_init', $signup_user_defaults ); 454 $user_name = $filtered_results['user_name']; 455 $user_email = $filtered_results['user_email']; 456 $errors = $filtered_results['errors']; 514 $signup_user_defaults = array( 515 'user_name' => $user_name, 516 'user_email' => $user_email, 517 'errors' => $errors, 518 ); 457 519 458 ?> 520 /** 521 * Filter the default user variables used on the user sign-up form. 522 * 523 * @since 3.0.0 524 * 525 * @param array $signup_user_defaults { 526 * An array of default user variables. 527 * 528 * @type string $user_name The user username. 529 * @type string $user_email The user email address. 530 * @type array $errors An array of possible errors relevant to the sign-up user. 531 * } 532 */ 533 $filtered_results = apply_filters( 'signup_user_init', $signup_user_defaults ); 534 $user_name = $filtered_results['user_name']; 535 $user_email = $filtered_results['user_email']; 536 $errors = $filtered_results['errors']; 459 537 460 <h2><?php printf( __( 'Get your own %s account in seconds' ), get_current_site()->site_name ) ?></h2> 461 <form id="setupform" method="post" action="wp-signup.php" novalidate="novalidate"> 462 <input type="hidden" name="stage" value="validate-user-signup" /> 463 <?php 464 /** This action is documented in wp-signup.php */ 465 do_action( 'signup_hidden_fields', 'validate-user' ); 466 ?> 467 <?php show_user_form($user_name, $user_email, $errors); ?> 538 ?> 468 539 469 <p> 470 <?php if ( $active_signup == 'blog' ) { ?> 471 <input id="signupblog" type="hidden" name="signup_for" value="blog" /> 472 <?php } elseif ( $active_signup == 'user' ) { ?> 473 <input id="signupblog" type="hidden" name="signup_for" value="user" /> 474 <?php } else { ?> 475 <input id="signupblog" type="radio" name="signup_for" value="blog" <?php checked( $signup_for, 'blog' ); ?> /> 476 <label class="checkbox" for="signupblog"><?php _e('Gimme a site!') ?></label> 477 <br /> 478 <input id="signupuser" type="radio" name="signup_for" value="user" <?php checked( $signup_for, 'user' ); ?> /> 479 <label class="checkbox" for="signupuser"><?php _e('Just a username, please.') ?></label> 480 <?php } ?> 481 </p> 540 <h2><?php printf( __( 'Get your own %s account in seconds' ), get_current_site()->site_name ) ?></h2> 541 <form id="setupform" method="post" action="wp-signup.php" novalidate="novalidate"> 542 <input type="hidden" name="stage" value="validate-user-signup"/> 543 <?php 544 /** This action is documented in wp-signup.php */ 545 do_action( 'signup_hidden_fields', 'validate-user' ); 546 ?> 547 <?php show_user_form( $user_name, $user_email, $errors ); ?> 482 548 483 <p class="submit"><input type="submit" name="submit" class="submit" value="<?php esc_attr_e('Next') ?>" /></p> 484 </form> 485 <?php 486 } 549 <p> 550 <?php if ( 'blog' === $active_signup ) { ?> 551 <input id="signupblog" type="hidden" name="signup_for" value="blog"/> 552 <?php } elseif ( 'user' === $active_signup ) { ?> 553 <input id="signupblog" type="hidden" name="signup_for" value="user"/> 554 <?php } else { ?> 555 <input id="signupblog" type="radio" name="signup_for" 556 value="blog" <?php checked( $signup_for, 'blog' ); ?> /> 557 <label class="checkbox" for="signupblog"><?php _e( 'Gimme a site!' ) ?></label> 558 <br/> 559 <input id="signupuser" type="radio" name="signup_for" 560 value="user" <?php checked( $signup_for, 'user' ); ?> /> 561 <label class="checkbox" for="signupuser"><?php _e( 'Just a username, please.' ) ?></label> 562 <?php } ?> 563 </p> 487 564 488 /** 489 * Validate the new user signup 490 * 491 * @since MU 492 * 493 * @return bool True if new user signup was validated, false if error 494 */ 495 function validate_user_signup() { 496 $result = validate_user_form(); 497 $user_name = $result['user_name']; 498 $user_email = $result['user_email']; 499 $errors = $result['errors']; 565 <p class="submit"><input type="submit" name="submit" class="submit" 566 value="<?php esc_attr_e( 'Next' ) ?>"/></p> 567 </form> 568 <?php 569 } 500 570 501 if ( $errors->get_error_code() ) { 502 signup_user($user_name, $user_email, $errors); 503 return false; 504 } 571 /** 572 * Validate the new user signup 573 * 574 * @since MU 575 * 576 * @return bool True if new user signup was validated, false if error 577 */ 578 function validate_user_signup() { 579 $result = validate_user_form(); 580 $user_name = $result['user_name']; 581 $user_email = $result['user_email']; 582 $errors = $result['errors']; 505 583 506 if ( 'blog' == $_POST['signup_for'] ) { 507 signup_blog($user_name, $user_email); 508 return false; 509 } 584 if ( $errors->get_error_code() ) { 585 signup_user( $user_name, $user_email, $errors ); 510 586 511 /** This filter is documented in wp-signup.php */512 wpmu_signup_user( $user_name, $user_email, apply_filters( 'add_signup_meta', array() ) );587 return false; 588 } 513 589 514 confirm_user_signup($user_name, $user_email); 515 return true; 516 } 590 if ( 'blog' == $_POST['signup_for'] ) { 591 signup_blog( $user_name, $user_email ); 517 592 518 /** 519 * New user signup confirmation 520 * 521 * @since MU 522 * 523 * @param string $user_name The username 524 * @param string $user_email The user's email address 525 */ 526 function confirm_user_signup($user_name, $user_email) { 527 ?> 528 <h2><?php printf( __( '%s is your new username' ), $user_name) ?></h2> 529 <p><?php _e( 'But, before you can start using your new username, <strong>you must activate it</strong>.' ) ?></p> 530 <p><?php printf( __( 'Check your inbox at <strong>%s</strong> and click the link given.' ), $user_email ); ?></p> 531 <p><?php _e( 'If you do not activate your username within two days, you will have to sign up again.' ); ?></p> 532 <?php 533 /** This action is documented in wp-signup.php */ 534 do_action( 'signup_finished' ); 535 } 593 return false; 594 } 536 595 537 /** 538 * Setup the new site signup 539 * 540 * @since MU 541 * 542 * @param string $user_name The username 543 * @param string $user_email The user's email address 544 * @param string $blogname The site name 545 * @param string $blog_title The site title 546 * @param array $errors 547 */ 548 function signup_blog($user_name = '', $user_email = '', $blogname = '', $blog_title = '', $errors = '') { 549 if ( !is_wp_error($errors) ) 550 $errors = new WP_Error(); 596 /** This filter is documented in wp-signup.php */ 597 wpmu_signup_user( $user_name, $user_email, apply_filters( 'add_signup_meta', array() ) ); 551 598 552 $signup_blog_defaults = array( 553 'user_name' => $user_name, 554 'user_email' => $user_email, 555 'blogname' => $blogname, 556 'blog_title' => $blog_title, 557 'errors' => $errors 558 ); 599 confirm_user_signup( $user_name, $user_email ); 559 600 560 /** 561 * Filter the default site creation variables for the site sign-up form. 562 * 563 * @since 3.0.0 564 * 565 * @param array $signup_blog_defaults { 566 * An array of default site creation variables. 567 * 568 * @type string $user_name The user username. 569 * @type string $user_email The user email address. 570 * @type string $blogname The blogname. 571 * @type string $blog_title The title of the site. 572 * @type array $errors An array of possible errors relevant to new site creation variables. 573 * } 574 */ 575 $filtered_results = apply_filters( 'signup_blog_init', $signup_blog_defaults ); 601 return true; 602 } 576 603 577 $user_name = $filtered_results['user_name']; 578 $user_email = $filtered_results['user_email']; 579 $blogname = $filtered_results['blogname']; 580 $blog_title = $filtered_results['blog_title']; 581 $errors = $filtered_results['errors']; 604 /** 605 * New user signup confirmation 606 * 607 * @since MU 608 * 609 * @param string $user_name The username 610 * @param string $user_email The user's email address 611 */ 612 function confirm_user_signup( $user_name, $user_email ) { 613 ?> 614 <h2><?php printf( __( '%s is your new username' ), $user_name ) ?></h2> 615 <p><?php _e( 'But, before you can start using your new username, <strong>you must activate it</strong>.' ) ?></p> 616 <p><?php printf( __( 'Check your inbox at <strong>%s</strong> and click the link given.' ), $user_email ); ?></p> 617 <p><?php _e( 'If you do not activate your username within two days, you will have to sign up again.' ); ?></p> 618 <?php 619 /** This action is documented in wp-signup.php */ 620 do_action( 'signup_finished' ); 621 } 582 622 583 if ( empty($blogname) ) 584 $blogname = $user_name; 585 ?> 586 <form id="setupform" method="post" action="wp-signup.php"> 587 <input type="hidden" name="stage" value="validate-blog-signup" /> 588 <input type="hidden" name="user_name" value="<?php echo esc_attr($user_name) ?>" /> 589 <input type="hidden" name="user_email" value="<?php echo esc_attr($user_email) ?>" /> 590 <?php 591 /** This action is documented in wp-signup.php */ 592 do_action( 'signup_hidden_fields', 'validate-site' ); 593 ?> 594 <?php show_blog_form($blogname, $blog_title, $errors); ?> 595 <p class="submit"><input type="submit" name="submit" class="submit" value="<?php esc_attr_e('Signup') ?>" /></p> 596 </form> 597 <?php 598 } 623 /** 624 * Setup the new site signup 625 * 626 * @since MU 627 * 628 * @param string $user_name The username 629 * @param string $user_email The user's email address 630 * @param string $blogname The site name 631 * @param string $blog_title The site title 632 * @param array $errors 633 */ 634 function signup_blog( $user_name = '', $user_email = '', $blogname = '', $blog_title = '', $errors = array() ) { 635 if ( ! is_wp_error( $errors ) ) { 636 $errors = new WP_Error(); 637 } 599 638 600 /** 601 * Validate new site signup 602 * 603 * @since MU 604 * 605 * @return bool True if the site signup was validated, false if error 606 */ 607 function validate_blog_signup() { 608 // Re-validate user info. 609 $user_result = wpmu_validate_user_signup( $_POST['user_name'], $_POST['user_email'] ); 610 $user_name = $user_result['user_name']; 611 $user_email = $user_result['user_email']; 612 $user_errors = $user_result['errors']; 639 $signup_blog_defaults = array( 640 'user_name' => $user_name, 641 'user_email' => $user_email, 642 'blogname' => $blogname, 643 'blog_title' => $blog_title, 644 'errors' => $errors, 645 ); 613 646 614 if ( $user_errors->get_error_code() ) { 615 signup_user( $user_name, $user_email, $user_errors ); 616 return false; 617 } 647 /** 648 * Filter the default site creation variables for the site sign-up form. 649 * 650 * @since 3.0.0 651 * 652 * @param array $signup_blog_defaults { 653 * An array of default site creation variables. 654 * 655 * @type string $user_name The user username. 656 * @type string $user_email The user email address. 657 * @type string $blogname The blogname. 658 * @type string $blog_title The title of the site. 659 * @type array $errors An array of possible errors relevant to new site creation variables. 660 * } 661 */ 662 $filtered_results = apply_filters( 'signup_blog_init', $signup_blog_defaults ); 618 663 619 $result = wpmu_validate_blog_signup( $_POST['blogname'], $_POST['blog_title'] ); 620 $domain = $result['domain']; 621 $path = $result['path']; 622 $blogname = $result['blogname']; 623 $blog_title = $result['blog_title']; 624 $errors = $result['errors']; 664 $user_name = $filtered_results['user_name']; 665 $user_email = $filtered_results['user_email']; 666 $blogname = $filtered_results['blogname']; 667 $blog_title = $filtered_results['blog_title']; 668 $errors = $filtered_results['errors']; 625 669 626 if ( $errors->get_error_code() ) { 627 signup_blog($user_name, $user_email, $blogname, $blog_title, $errors); 628 return false; 629 } 670 if ( empty( $blogname ) ) { 671 $blogname = $user_name; 672 } 673 ?> 674 <form id="setupform" method="post" action="wp-signup.php"> 675 <input type="hidden" name="stage" value="validate-blog-signup"/> 676 <input type="hidden" name="user_name" value="<?php echo esc_attr( $user_name ) ?>"/> 677 <input type="hidden" name="user_email" value="<?php echo esc_attr( $user_email ) ?>"/> 678 <?php 679 /** This action is documented in wp-signup.php */ 680 do_action( 'signup_hidden_fields', 'validate-site' ); 681 ?> 682 <?php show_blog_form( $blogname, $blog_title, $errors ); ?> 683 <p class="submit"><input type="submit" name="submit" class="submit" 684 value="<?php esc_attr_e( 'Signup' ) ?>"/></p> 685 </form> 686 <?php 687 } 630 688 631 $public = (int) $_POST['blog_public']; 632 $signup_meta = array ('lang_id' => 1, 'public' => $public); 689 /** 690 * Validate new site signup 691 * 692 * @since MU 693 * 694 * @return bool True if the site signup was validated, false if error 695 */ 696 function validate_blog_signup() { 697 // Re-validate user info. 698 $user_result = wpmu_validate_user_signup( $_POST['user_name'], $_POST['user_email'] ); 699 $user_name = $user_result['user_name']; 700 $user_email = $user_result['user_email']; 701 $user_errors = $user_result['errors']; 633 702 634 /** This filter is documented in wp-signup.php */635 $meta = apply_filters( 'add_signup_meta', $signup_meta);703 if ( $user_errors->get_error_code() ) { 704 signup_user( $user_name, $user_email, $user_errors ); 636 705 637 wpmu_signup_blog($domain, $path, $blog_title, $user_name, $user_email, $meta); 638 confirm_blog_signup($domain, $path, $blog_title, $user_name, $user_email, $meta); 639 return true; 640 } 706 return false; 707 } 641 708 642 /** 643 * New site signup confirmation 644 * 645 * @since MU 646 * 647 * @param string $domain The domain URL 648 * @param string $path The site root path 649 * @param string $blog_title The new site title 650 * @param string $user_name The user's username 651 * @param string $user_email The user's email address 652 * @param array $meta Any additional meta from the 'add_signup_meta' filter in validate_blog_signup() 653 */ 654 function confirm_blog_signup( $domain, $path, $blog_title, $user_name = '', $user_email = '', $meta = array() ) { 655 ?> 656 <h2><?php printf( __( 'Congratulations! Your new site, %s, is almost ready.' ), "<a href='http://{$domain}{$path}'>{$blog_title}</a>" ) ?></h2> 709 $result = wpmu_validate_blog_signup( $_POST['blogname'], $_POST['blog_title'] ); 710 $domain = $result['domain']; 711 $path = $result['path']; 712 $blogname = $result['blogname']; 713 $blog_title = $result['blog_title']; 714 $errors = $result['errors']; 657 715 658 <p><?php _e( 'But, before you can start using your site, <strong>you must activate it</strong>.' ) ?></p> 659 <p><?php printf( __( 'Check your inbox at <strong>%s</strong> and click the link given.' ), $user_email) ?></p> 660 <p><?php _e( 'If you do not activate your site within two days, you will have to sign up again.' ); ?></p> 661 <h2><?php _e( 'Still waiting for your email?' ); ?></h2> 662 <p> 663 <?php _e( 'If you haven’t received your email yet, there are a number of things you can do:' ) ?> 664 <ul id="noemail-tips"> 665 <li><p><strong><?php _e( 'Wait a little longer. Sometimes delivery of email can be delayed by processes outside of our control.' ) ?></strong></p></li> 666 <li><p><?php _e( 'Check the junk or spam folder of your email client. Sometime emails wind up there by mistake.' ) ?></p></li> 667 <li><?php printf( __( 'Have you entered your email correctly? You have entered %s, if it’s incorrect, you will not receive your email.' ), $user_email ) ?></li> 668 </ul> 669 </p> 670 <?php 671 /** This action is documented in wp-signup.php */ 672 do_action( 'signup_finished' ); 673 } 716 if ( $errors->get_error_code() ) { 717 signup_blog( $user_name, $user_email, $blogname, $blog_title, $errors ); 674 718 675 // Main 676 $active_signup = get_network_option( 'registration', 'none' ); 677 /** 678 * Filter the type of site sign-up. 679 * 680 * @since 3.0.0 681 * 682 * @param string $active_signup String that returns registration type. The value can be 683 * 'all', 'none', 'blog', or 'user'. 684 */ 685 $active_signup = apply_filters( 'wpmu_active_signup', $active_signup ); 719 return false; 720 } 686 721 687 // Make the signup type translatable. 688 $i18n_signup['all'] = _x('all', 'Multisite active signup type'); 689 $i18n_signup['none'] = _x('none', 'Multisite active signup type'); 690 $i18n_signup['blog'] = _x('blog', 'Multisite active signup type'); 691 $i18n_signup['user'] = _x('user', 'Multisite active signup type'); 722 $public = (int) $_POST['blog_public']; 723 $signup_meta = array( 'lang_id' => 1, 'public' => $public ); 692 724 693 if ( is_super_admin() ) 694 echo '<div class="mu_alert">' . sprintf( __( 'Greetings Site Administrator! You are currently allowing “%s” registrations. To change or disable registration go to your <a href="%s">Options page</a>.' ), $i18n_signup[$active_signup], esc_url( network_admin_url( 'settings.php' ) ) ) . '</div>';725 /** This filter is documented in wp-signup.php */ 726 $meta = apply_filters( 'add_signup_meta', $signup_meta ); 695 727 696 $newblogname = isset($_GET['new']) ? strtolower(preg_replace('/^-|-$|[^-a-zA-Z0-9]/', '', $_GET['new'])) : null; 728 wpmu_signup_blog( $domain, $path, $blog_title, $user_name, $user_email, $meta ); 729 confirm_blog_signup( $domain, $path, $blog_title, $user_name, $user_email, $meta ); 697 730 698 $current_user = wp_get_current_user(); 699 if ( $active_signup == 'none' ) { 700 _e( 'Registration has been disabled.' ); 701 } elseif ( $active_signup == 'blog' && !is_user_logged_in() ) { 702 $login_url = wp_login_url( network_site_url( 'wp-signup.php' ) ); 703 echo sprintf( __( 'You must first <a href="%s">log in</a>, and then you can create a new site.' ), $login_url ); 704 } else { 705 $stage = isset( $_POST['stage'] ) ? $_POST['stage'] : 'default'; 706 switch ( $stage ) { 707 case 'validate-user-signup' : 708 if ( $active_signup == 'all' || $_POST[ 'signup_for' ] == 'blog' && $active_signup == 'blog' || $_POST[ 'signup_for' ] == 'user' && $active_signup == 'user' ) 709 validate_user_signup(); 710 else 711 _e( 'User registration has been disabled.' ); 712 break; 713 case 'validate-blog-signup': 714 if ( $active_signup == 'all' || $active_signup == 'blog' ) 715 validate_blog_signup(); 716 else 717 _e( 'Site registration has been disabled.' ); 718 break; 719 case 'gimmeanotherblog': 720 validate_another_blog_signup(); 721 break; 722 case 'default': 723 default : 724 $user_email = isset( $_POST[ 'user_email' ] ) ? $_POST[ 'user_email' ] : ''; 725 /** 726 * Fires when the site sign-up form is sent. 727 * 728 * @since 3.0.0 729 */ 730 do_action( 'preprocess_signup_form' ); 731 if ( is_user_logged_in() && ( $active_signup == 'all' || $active_signup == 'blog' ) ) 732 signup_another_blog($newblogname); 733 elseif ( ! is_user_logged_in() && ( $active_signup == 'all' || $active_signup == 'user' ) ) 734 signup_user( $newblogname, $user_email ); 735 elseif ( ! is_user_logged_in() && ( $active_signup == 'blog' ) ) 736 _e( 'Sorry, new registrations are not allowed at this time.' ); 737 else 738 _e( 'You are logged in already. No need to register again!' ); 731 return true; 732 } 739 733 740 if ( $newblogname ) { 741 $newblog = get_blogaddress_by_name( $newblogname ); 734 /** 735 * New site signup confirmation 736 * 737 * @since MU 738 * 739 * @param string $domain The domain URL 740 * @param string $path The site root path 741 * @param string $blog_title The new site title 742 * @param string $user_name The user's username 743 * @param string $user_email The user's email address 744 * @param array $meta Any additional meta from the 'add_signup_meta' filter in validate_blog_signup() 745 */ 746 function confirm_blog_signup( $domain, $path, $blog_title, $user_name = '', $user_email = '', $meta = array() ) { 747 ?> 748 <h2><?php printf( __( 'Congratulations! Your new site, %s, is almost ready.' ), "<a href='http://{$domain}{$path}'>{$blog_title}</a>" ) ?></h2> 742 749 743 if ( $active_signup == 'blog' || $active_signup == 'all' ) 744 printf( '<p><em>' . __( 'The site you were looking for, <strong>%s</strong>, does not exist, but you can create it now!' ) . '</em></p>', $newblog ); 745 else 746 printf( '<p><em>' . __( 'The site you were looking for, <strong>%s</strong>, does not exist.' ) . '</em></p>', $newblog ); 750 <p><?php _e( 'But, before you can start using your site, <strong>you must activate it</strong>.' ) ?></p> 751 <p><?php printf( __( 'Check your inbox at <strong>%s</strong> and click the link given.' ), $user_email ) ?></p> 752 <p><?php _e( 'If you do not activate your site within two days, you will have to sign up again.' ); ?></p> 753 <h2><?php _e( 'Still waiting for your email?' ); ?></h2> 754 <p> 755 <?php _e( 'If you haven’t received your email yet, there are a number of things you can do:' ) ?> 756 <ul id="noemail-tips"> 757 <li><p><strong><?php _e( 'Wait a little longer. Sometimes delivery of email can be delayed by processes outside of our control.' ) ?></strong></p></li> 758 <li><p><?php _e( 'Check the junk or spam folder of your email client. Sometime emails wind up there by mistake.' ) ?></p></li> 759 <li><?php printf( __( 'Have you entered your email correctly? You have entered %s, if it’s incorrect, you will not receive your email.' ), $user_email ) ?></li> 760 </ul> 761 </p> 762 <?php 763 /** This action is documented in wp-signup.php */ 764 do_action( 'signup_finished' ); 765 } 766 767 // Main 768 $active_signup = get_network_option( 'registration', 'none' ); 769 /** 770 * Filter the type of site sign-up. 771 * 772 * @since 3.0.0 773 * 774 * @param string $active_signup String that returns registration type. The value can be 775 * 'all', 'none', 'blog', or 'user'. 776 */ 777 $active_signup = apply_filters( 'wpmu_active_signup', $active_signup ); 778 779 // Make the signup type translatable. 780 $i18n_signup['all'] = _x( 'all', 'Multisite active signup type' ); 781 $i18n_signup['none'] = _x( 'none', 'Multisite active signup type' ); 782 $i18n_signup['blog'] = _x( 'blog', 'Multisite active signup type' ); 783 $i18n_signup['user'] = _x( 'user', 'Multisite active signup type' ); 784 785 if ( is_super_admin() ) { 786 echo '<div class="mu_alert">' . sprintf( __( 'Greetings Site Administrator! You are currently allowing “%s” registrations. To change or disable registration go to your <a href="%s">Options page</a>.' ), $i18n_signup[ $active_signup ], esc_url( network_admin_url( 'settings.php' ) ) ) . '</div>'; 787 } 788 789 $newblogname = isset( $_GET['new'] ) ? strtolower( preg_replace( '/^-|-$|[^-a-zA-Z0-9]/', '', $_GET['new'] ) ) : null; 790 791 $current_user = wp_get_current_user(); 792 if ( 'none' === $active_signup ) { 793 _e( 'Registration has been disabled.' ); 794 } elseif ( 'blog' === $active_signup && ! is_user_logged_in() ) { 795 $login_url = wp_login_url( network_site_url( 'wp-signup.php' ) ); 796 echo sprintf( __( 'You must first <a href="%s">log in</a>, and then you can create a new site.' ), $login_url ); 797 } else { 798 $stage = isset( $_POST['stage'] ) ? $_POST['stage'] : 'default'; 799 switch ( $stage ) { 800 case 'validate-user-signup' : 801 if ( 'all' === $active_signup || 802 'blog' === $_POST['signup_for'] && 'blog' === $active_signup || 803 'user' === $_POST['signup_for'] && 'user' === $active_signup ) { 804 validate_user_signup(); 805 } else { 806 _e( 'User registration has been disabled.' ); 807 } 808 break; 809 case 'validate-blog-signup': 810 if ( 'all' === $active_signup || 'blog' === $active_signup ) { 811 validate_blog_signup(); 812 } else { 813 _e( 'Site registration has been disabled.' ); 814 } 815 break; 816 case 'gimmeanotherblog': 817 validate_another_blog_signup(); 818 break; 819 case 'default': 820 default : 821 $user_email = isset( $_POST['user_email'] ) ? $_POST['user_email'] : ''; 822 /** 823 * Fires when the site sign-up form is sent. 824 * 825 * @since 3.0.0 826 */ 827 do_action( 'preprocess_signup_form' ); 828 if ( is_user_logged_in() && ( 'all' === $active_signup || 'blog' === $active_signup ) ) { 829 signup_another_blog( $newblogname ); 830 } elseif ( ! is_user_logged_in() && ( 'all' === $active_signup || 'user' === $active_signup ) ) { 831 signup_user( $newblogname, $user_email ); 832 } elseif ( ! is_user_logged_in() && ( 'blog' === $active_signup ) ) { 833 _e( 'Sorry, new registrations are not allowed at this time.' ); 834 } else { 835 _e( 'You are logged in already. No need to register again!' ); 836 } 837 838 if ( $newblogname ) { 839 $newblog = get_blogaddress_by_name( $newblogname ); 840 841 if ( 'blog' === $active_signup || 'all' === $active_signup ) { 842 printf( '<p><em>' . __( 'The site you were looking for, <strong>%s</strong>, does not exist, but you can create it now!' ) . '</em></p>', $newblog ); 843 } else { 844 printf( '<p><em>' . __( 'The site you were looking for, <strong>%s</strong>, does not exist.' ) . '</em></p>', $newblog ); 845 } 846 } 847 break; 747 848 } 748 break; 749 } 750 } 751 ?> 849 } 850 ?> 851 </div> 752 852 </div> 753 </div>754 853 <?php 755 854 /** 756 855 * Fires after the sign-up forms, before wp_footer.