wp/wp-signup.php
changeset 9 177826044cd9
parent 7 cf61fcea0001
child 16 a86126ab1dd4
equal deleted inserted replaced
8:c7c34916027a 9:177826044cd9
     1 <?php
     1 <?php
     2 
     2 
     3 /** Sets up the WordPress Environment. */
     3 /** Sets up the WordPress Environment. */
     4 require( dirname(__FILE__) . '/wp-load.php' );
     4 require( dirname( __FILE__ ) . '/wp-load.php' );
     5 
     5 
     6 add_action( 'wp_head', 'wp_no_robots' );
     6 add_action( 'wp_head', 'wp_no_robots' );
     7 
     7 
     8 require( dirname( __FILE__ ) . '/wp-blog-header.php' );
     8 require( dirname( __FILE__ ) . '/wp-blog-header.php' );
     9 
     9 
    10 nocache_headers();
    10 nocache_headers();
    11 
    11 
    12 if ( is_array( get_site_option( 'illegal_names' )) && isset( $_GET[ 'new' ] ) && in_array( $_GET[ 'new' ], get_site_option( 'illegal_names' ) ) ) {
    12 if ( is_array( get_site_option( 'illegal_names' ) ) && isset( $_GET['new'] ) && in_array( $_GET['new'], get_site_option( 'illegal_names' ) ) ) {
    13 	wp_redirect( network_home_url() );
    13 	wp_redirect( network_home_url() );
    14 	die();
    14 	die();
    15 }
    15 }
    16 
    16 
    17 /**
    17 /**
    27 	 */
    27 	 */
    28 	do_action( 'signup_header' );
    28 	do_action( 'signup_header' );
    29 }
    29 }
    30 add_action( 'wp_head', 'do_signup_header' );
    30 add_action( 'wp_head', 'do_signup_header' );
    31 
    31 
    32 if ( !is_multisite() ) {
    32 if ( ! is_multisite() ) {
    33 	wp_redirect( wp_registration_url() );
    33 	wp_redirect( wp_registration_url() );
    34 	die();
    34 	die();
    35 }
    35 }
    36 
    36 
    37 if ( !is_main_site() ) {
    37 if ( ! is_main_site() ) {
    38 	wp_redirect( network_site_url( 'wp-signup.php' ) );
    38 	wp_redirect( network_site_url( 'wp-signup.php' ) );
    39 	die();
    39 	die();
    40 }
    40 }
    41 
    41 
    42 // Fix for page title
    42 // Fix for page title
    57 function wpmu_signup_stylesheet() {
    57 function wpmu_signup_stylesheet() {
    58 	?>
    58 	?>
    59 	<style type="text/css">
    59 	<style type="text/css">
    60 		.mu_register { width: 90%; margin:0 auto; }
    60 		.mu_register { width: 90%; margin:0 auto; }
    61 		.mu_register form { margin-top: 2em; }
    61 		.mu_register form { margin-top: 2em; }
    62 		.mu_register .error { font-weight:700; padding:10px; color:#333333; background:#FFEBE8; border:1px solid #CC0000; }
    62 		.mu_register .error { font-weight: 600; padding: 10px; color: #333333; background: #FFEBE8; border: 1px solid #CC0000; }
    63 		.mu_register input[type="submit"],
    63 		.mu_register input[type="submit"],
    64 			.mu_register #blog_title,
    64 			.mu_register #blog_title,
    65 			.mu_register #user_email,
    65 			.mu_register #user_email,
    66 			.mu_register #blogname,
    66 			.mu_register #blogname,
    67 			.mu_register #user_name { width:100%; font-size: 24px; margin:5px 0; }
    67 			.mu_register #user_name { width:100%; font-size: 24px; margin:5px 0; }
    68 		.mu_register #site-language { display: block; }
    68 		.mu_register #site-language { display: block; }
    69 		.mu_register .prefix_address,
    69 		.mu_register .prefix_address,
    70 			.mu_register .suffix_address {font-size: 18px;display:inline; }
    70 			.mu_register .suffix_address { font-size: 18px; display:inline; }
    71 		.mu_register label { font-weight:700; font-size:15px; display:block; margin:10px 0; }
    71 		.mu_register label { font-weight: 600; font-size: 15px; display: block; margin: 10px 0; }
    72 		.mu_register label.checkbox { display:inline; }
    72 		.mu_register label.checkbox { display:inline; }
    73 		.mu_register .mu_alert { font-weight:700; padding:10px; color:#333333; background:#ffffe0; border:1px solid #e6db55; }
    73 		.mu_register .mu_alert { font-weight: 600; padding: 10px; color: #333333; background: #ffffe0; border: 1px solid #e6db55; }
    74 	</style>
    74 	</style>
    75 	<?php
    75 	<?php
    76 }
    76 }
    77 
    77 
    78 add_action( 'wp_head', 'wpmu_signup_stylesheet' );
    78 add_action( 'wp_head', 'wpmu_signup_stylesheet' );
   101 	if ( ! is_wp_error( $errors ) ) {
   101 	if ( ! is_wp_error( $errors ) ) {
   102 		$errors = new WP_Error();
   102 		$errors = new WP_Error();
   103 	}
   103 	}
   104 
   104 
   105 	$current_network = get_network();
   105 	$current_network = get_network();
   106 	// Blog name
   106 	// Blog name.
   107 	if ( !is_subdomain_install() )
   107 	if ( ! is_subdomain_install() ) {
   108 		echo '<label for="blogname">' . __('Site Name:') . '</label>';
   108 		echo '<label for="blogname">' . __( 'Site Name:' ) . '</label>';
   109 	else
   109 	} else {
   110 		echo '<label for="blogname">' . __('Site Domain:') . '</label>';
   110 		echo '<label for="blogname">' . __( 'Site Domain:' ) . '</label>';
   111 
   111 	}
   112 	if ( $errmsg = $errors->get_error_message('blogname') ) { ?>
   112 
   113 		<p class="error"><?php echo $errmsg ?></p>
   113 	$errmsg = $errors->get_error_message( 'blogname' );
   114 	<?php }
   114 	if ( $errmsg ) {
   115 
   115 		?>
   116 	if ( !is_subdomain_install() )
   116 		<p class="error"><?php echo $errmsg; ?></p>
   117 		echo '<span class="prefix_address">' . $current_network->domain . $current_network->path . '</span><input name="blogname" type="text" id="blogname" value="'. esc_attr($blogname) .'" maxlength="60" /><br />';
   117 		<?php
   118 	else
   118 	}
   119 		echo '<input name="blogname" type="text" id="blogname" value="'.esc_attr($blogname).'" maxlength="60" /><span class="suffix_address">.' . ( $site_domain = preg_replace( '|^www\.|', '', $current_network->domain ) ) . '</span><br />';
   119 
       
   120 	if ( ! is_subdomain_install() ) {
       
   121 		echo '<span class="prefix_address">' . $current_network->domain . $current_network->path . '</span><input name="blogname" type="text" id="blogname" value="' . esc_attr( $blogname ) . '" maxlength="60" /><br />';
       
   122 	} else {
       
   123 		$site_domain = preg_replace( '|^www\.|', '', $current_network->domain );
       
   124 		echo '<input name="blogname" type="text" id="blogname" value="' . esc_attr( $blogname ) . '" maxlength="60" /><span class="suffix_address">.' . esc_html( $site_domain ) . '</span><br />';
       
   125 	}
   120 
   126 
   121 	if ( ! is_user_logged_in() ) {
   127 	if ( ! is_user_logged_in() ) {
   122 		if ( ! is_subdomain_install() ) {
   128 		if ( ! is_subdomain_install() ) {
   123 			$site = $current_network->domain . $current_network->path . __( 'sitename' );
   129 			$site = $current_network->domain . $current_network->path . __( 'sitename' );
   124 		} else {
   130 		} else {
   129 		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>';
   135 		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>';
   130 	}
   136 	}
   131 
   137 
   132 	// Blog Title
   138 	// Blog Title
   133 	?>
   139 	?>
   134 	<label for="blog_title"><?php _e('Site Title:') ?></label>
   140 	<label for="blog_title"><?php _e( 'Site Title:' ); ?></label>
   135 	<?php if ( $errmsg = $errors->get_error_message('blog_title') ) { ?>
   141 	<?php
   136 		<p class="error"><?php echo $errmsg ?></p>
   142 	$errmsg = $errors->get_error_message( 'blog_title' );
   137 	<?php }
   143 	if ( $errmsg ) {
   138 	echo '<input name="blog_title" type="text" id="blog_title" value="'.esc_attr($blog_title).'" />';
   144 		?>
       
   145 		<p class="error"><?php echo $errmsg; ?></p>
       
   146 		<?php
       
   147 	}
       
   148 	echo '<input name="blog_title" type="text" id="blog_title" value="' . esc_attr( $blog_title ) . '" />';
   139 	?>
   149 	?>
   140 
   150 
   141 	<?php
   151 	<?php
   142 	// Site Language.
   152 	// Site Language.
   143 	$languages = signup_get_available_languages();
   153 	$languages = signup_get_available_languages();
   157 			// Use US English if the default isn't available.
   167 			// Use US English if the default isn't available.
   158 			if ( ! in_array( $lang, $languages ) ) {
   168 			if ( ! in_array( $lang, $languages ) ) {
   159 				$lang = '';
   169 				$lang = '';
   160 			}
   170 			}
   161 
   171 
   162 			wp_dropdown_languages( array(
   172 			wp_dropdown_languages(
   163 				'name'                        => 'WPLANG',
   173 				array(
   164 				'id'                          => 'site-language',
   174 					'name'                        => 'WPLANG',
   165 				'selected'                    => $lang,
   175 					'id'                          => 'site-language',
   166 				'languages'                   => $languages,
   176 					'selected'                    => $lang,
   167 				'show_available_translations' => false,
   177 					'languages'                   => $languages,
   168 			) );
   178 					'show_available_translations' => false,
       
   179 				)
       
   180 			);
   169 			?>
   181 			?>
   170 		</p>
   182 		</p>
   171 	<?php endif; // Languages. ?>
   183 		<?php
       
   184 		endif; // Languages.
       
   185 
       
   186 		$blog_public_on_checked  = '';
       
   187 		$blog_public_off_checked = '';
       
   188 	if ( isset( $_POST['blog_public'] ) && '0' == $_POST['blog_public'] ) {
       
   189 		$blog_public_off_checked = 'checked="checked"';
       
   190 	} else {
       
   191 		$blog_public_on_checked = 'checked="checked"';
       
   192 	}
       
   193 	?>
   172 
   194 
   173 	<div id="privacy">
   195 	<div id="privacy">
   174         <p class="privacy-intro">
   196 		<p class="privacy-intro">
   175             <label for="blog_public_on"><?php _e('Privacy:') ?></label>
   197 			<label for="blog_public_on"><?php _e( 'Privacy:' ); ?></label>
   176             <?php _e( 'Allow search engines to index this site.' ); ?>
   198 			<?php _e( 'Allow search engines to index this site.' ); ?>
   177             <br style="clear:both" />
   199 			<br style="clear:both" />
   178             <label class="checkbox" for="blog_public_on">
   200 			<label class="checkbox" for="blog_public_on">
   179                 <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 } ?> />
   201 				<input type="radio" id="blog_public_on" name="blog_public" value="1" <?php echo $blog_public_on_checked; ?> />
   180                 <strong><?php _e( 'Yes' ); ?></strong>
   202 				<strong><?php _e( 'Yes' ); ?></strong>
   181             </label>
   203 			</label>
   182             <label class="checkbox" for="blog_public_off">
   204 			<label class="checkbox" for="blog_public_off">
   183                 <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 } ?> />
   205 				<input type="radio" id="blog_public_off" name="blog_public" value="0" <?php echo $blog_public_off_checked; ?> />
   184                 <strong><?php _e( 'No' ); ?></strong>
   206 				<strong><?php _e( 'No' ); ?></strong>
   185             </label>
   207 			</label>
   186         </p>
   208 		</p>
   187 	</div>
   209 	</div>
   188 
   210 
   189 	<?php
   211 	<?php
   190 	/**
   212 	/**
   191 	 * Fires after the site sign-up form.
   213 	 * Fires after the site sign-up form.
   204  *
   226  *
   205  * @return array Contains the new site data and error messages.
   227  * @return array Contains the new site data and error messages.
   206  */
   228  */
   207 function validate_blog_form() {
   229 function validate_blog_form() {
   208 	$user = '';
   230 	$user = '';
   209 	if ( is_user_logged_in() )
   231 	if ( is_user_logged_in() ) {
   210 		$user = wp_get_current_user();
   232 		$user = wp_get_current_user();
   211 
   233 	}
   212 	return wpmu_validate_blog_signup($_POST['blogname'], $_POST['blog_title'], $user);
   234 
       
   235 	return wpmu_validate_blog_signup( $_POST['blogname'], $_POST['blog_title'], $user );
   213 }
   236 }
   214 
   237 
   215 /**
   238 /**
   216  * Display user registration form
   239  * Display user registration form
   217  *
   240  *
   219  *
   242  *
   220  * @param string          $user_name  The entered username.
   243  * @param string          $user_name  The entered username.
   221  * @param string          $user_email The entered email address.
   244  * @param string          $user_email The entered email address.
   222  * @param WP_Error|string $errors     A WP_Error object containing existing errors. Defaults to empty string.
   245  * @param WP_Error|string $errors     A WP_Error object containing existing errors. Defaults to empty string.
   223  */
   246  */
   224 function show_user_form($user_name = '', $user_email = '', $errors = '') {
   247 function show_user_form( $user_name = '', $user_email = '', $errors = '' ) {
   225 	if ( ! is_wp_error( $errors ) ) {
   248 	if ( ! is_wp_error( $errors ) ) {
   226 		$errors = new WP_Error();
   249 		$errors = new WP_Error();
   227 	}
   250 	}
   228 
   251 
   229 	// User name
   252 	// User name
   230 	echo '<label for="user_name">' . __('Username:') . '</label>';
   253 	echo '<label for="user_name">' . __( 'Username:' ) . '</label>';
   231 	if ( $errmsg = $errors->get_error_message('user_name') ) {
   254 	$errmsg = $errors->get_error_message( 'user_name' );
   232 		echo '<p class="error">'.$errmsg.'</p>';
   255 	if ( $errmsg ) {
   233 	}
   256 		echo '<p class="error">' . $errmsg . '</p>';
   234 	echo '<input name="user_name" type="text" id="user_name" value="'. esc_attr( $user_name ) .'" autocapitalize="none" autocorrect="off" maxlength="60" /><br />';
   257 	}
       
   258 	echo '<input name="user_name" type="text" id="user_name" value="' . esc_attr( $user_name ) . '" autocapitalize="none" autocorrect="off" maxlength="60" /><br />';
   235 	_e( '(Must be at least 4 characters, letters and numbers only.)' );
   259 	_e( '(Must be at least 4 characters, letters and numbers only.)' );
   236 	?>
   260 	?>
   237 
   261 
   238 	<label for="user_email"><?php _e( 'Email&nbsp;Address:' ) ?></label>
   262 	<label for="user_email"><?php _e( 'Email&nbsp;Address:' ); ?></label>
   239 	<?php if ( $errmsg = $errors->get_error_message('user_email') ) { ?>
   263 	<?php
   240 		<p class="error"><?php echo $errmsg ?></p>
   264 	$errmsg = $errors->get_error_message( 'user_email' );
       
   265 	if ( $errmsg ) {
       
   266 		?>
       
   267 		<p class="error"><?php echo $errmsg; ?></p>
   241 	<?php } ?>
   268 	<?php } ?>
   242 	<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.)') ?>
   269 	<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.)' ); ?>
   243 	<?php
   270 	<?php
   244 	if ( $errmsg = $errors->get_error_message('generic') ) {
   271 	$errmsg = $errors->get_error_message( 'generic' );
       
   272 	if ( $errmsg ) {
   245 		echo '<p class="error">' . $errmsg . '</p>';
   273 		echo '<p class="error">' . $errmsg . '</p>';
   246 	}
   274 	}
   247 	/**
   275 	/**
   248 	 * Fires at the end of the user registration form on the site sign-up form.
   276 	 * Fires at the end of the user registration form on the site sign-up form.
   249 	 *
   277 	 *
   260  * @since MU (3.0.0)
   288  * @since MU (3.0.0)
   261  *
   289  *
   262  * @return array Contains username, email, and error messages.
   290  * @return array Contains username, email, and error messages.
   263  */
   291  */
   264 function validate_user_form() {
   292 function validate_user_form() {
   265 	return wpmu_validate_user_signup($_POST['user_name'], $_POST['user_email']);
   293 	return wpmu_validate_user_signup( $_POST['user_name'], $_POST['user_email'] );
   266 }
   294 }
   267 
   295 
   268 /**
   296 /**
   269  * Allow returning users to sign up for another site
   297  * Allow returning users to sign up for another site
   270  *
   298  *
   275  * @param WP_Error|string $errors     A WP_Error object containing existing errors. Defaults to empty string.
   303  * @param WP_Error|string $errors     A WP_Error object containing existing errors. Defaults to empty string.
   276  */
   304  */
   277 function signup_another_blog( $blogname = '', $blog_title = '', $errors = '' ) {
   305 function signup_another_blog( $blogname = '', $blog_title = '', $errors = '' ) {
   278 	$current_user = wp_get_current_user();
   306 	$current_user = wp_get_current_user();
   279 
   307 
   280 	if ( ! is_wp_error($errors) ) {
   308 	if ( ! is_wp_error( $errors ) ) {
   281 		$errors = new WP_Error();
   309 		$errors = new WP_Error();
   282 	}
   310 	}
   283 
   311 
   284 	$signup_defaults = array(
   312 	$signup_defaults = array(
   285 		'blogname'   => $blogname,
   313 		'blogname'   => $blogname,
   286 		'blog_title' => $blog_title,
   314 		'blog_title' => $blog_title,
   287 		'errors'     => $errors
   315 		'errors'     => $errors,
   288 	);
   316 	);
   289 
   317 
   290 	/**
   318 	/**
   291 	 * Filters the default site sign-up variables.
   319 	 * Filters the default site sign-up variables.
   292 	 *
   320 	 *
   300 	 *     @type WP_Error $errors     A WP_Error object possibly containing 'blogname' or 'blog_title' errors.
   328 	 *     @type WP_Error $errors     A WP_Error object possibly containing 'blogname' or 'blog_title' errors.
   301 	 * }
   329 	 * }
   302 	 */
   330 	 */
   303 	$filtered_results = apply_filters( 'signup_another_blog_init', $signup_defaults );
   331 	$filtered_results = apply_filters( 'signup_another_blog_init', $signup_defaults );
   304 
   332 
   305 	$blogname = $filtered_results['blogname'];
   333 	$blogname   = $filtered_results['blogname'];
   306 	$blog_title = $filtered_results['blog_title'];
   334 	$blog_title = $filtered_results['blog_title'];
   307 	$errors = $filtered_results['errors'];
   335 	$errors     = $filtered_results['errors'];
   308 
   336 
       
   337 	/* translators: %s: Network's site name. */
   309 	echo '<h2>' . sprintf( __( 'Get <em>another</em> %s site in seconds' ), get_network()->site_name ) . '</h2>';
   338 	echo '<h2>' . sprintf( __( 'Get <em>another</em> %s site in seconds' ), get_network()->site_name ) . '</h2>';
   310 
   339 
   311 	if ( $errors->get_error_code() ) {
   340 	if ( $errors->has_errors() ) {
   312 		echo '<p>' . __( 'There was a problem, please correct the form below and try again.' ) . '</p>';
   341 		echo '<p>' . __( 'There was a problem, please correct the form below and try again.' ) . '</p>';
   313 	}
   342 	}
   314 	?>
   343 	?>
   315 	<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&#8217;s content, but write responsibly!' ), $current_user->display_name ) ?></p>
   344 	<p>
   316 
   345 		<?php
   317 	<?php
   346 		printf(
   318 	$blogs = get_blogs_of_user($current_user->ID);
   347 			/* translators: %s: Current user's display name. */
   319 	if ( !empty($blogs) ) { ?>
   348 			__( '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&#8217;s content, but write responsibly!' ),
   320 
   349 			$current_user->display_name
   321 			<p><?php _e( 'Sites you are already a member of:' ) ?></p>
   350 		);
       
   351 		?>
       
   352 	</p>
       
   353 
       
   354 	<?php
       
   355 	$blogs = get_blogs_of_user( $current_user->ID );
       
   356 	if ( ! empty( $blogs ) ) {
       
   357 		?>
       
   358 
       
   359 			<p><?php _e( 'Sites you are already a member of:' ); ?></p>
   322 			<ul>
   360 			<ul>
   323 				<?php foreach ( $blogs as $blog ) {
   361 				<?php
       
   362 				foreach ( $blogs as $blog ) {
   324 					$home_url = get_home_url( $blog->userblog_id );
   363 					$home_url = get_home_url( $blog->userblog_id );
   325 					echo '<li><a href="' . esc_url( $home_url ) . '">' . $home_url . '</a></li>';
   364 					echo '<li><a href="' . esc_url( $home_url ) . '">' . $home_url . '</a></li>';
   326 				} ?>
   365 				}
       
   366 				?>
   327 			</ul>
   367 			</ul>
   328 	<?php } ?>
   368 	<?php } ?>
   329 
   369 
   330 	<p><?php _e( 'If you&#8217;re not going to use a great site domain, leave it for a new user. Now have at it!' ) ?></p>
   370 	<p><?php _e( 'If you&#8217;re not going to use a great site domain, leave it for a new user. Now have at it!' ); ?></p>
   331 	<form id="setupform" method="post" action="wp-signup.php">
   371 	<form id="setupform" method="post" action="wp-signup.php">
   332 		<input type="hidden" name="stage" value="gimmeanotherblog" />
   372 		<input type="hidden" name="stage" value="gimmeanotherblog" />
   333 		<?php
   373 		<?php
   334 		/**
   374 		/**
   335 		 * Hidden sign-up form fields output when creating another site or user.
   375 		 * Hidden sign-up form fields output when creating another site or user.
   339 		 * @param string $context A string describing the steps of the sign-up process. The value can be
   379 		 * @param string $context A string describing the steps of the sign-up process. The value can be
   340 		 *                        'create-another-site', 'validate-user', or 'validate-site'.
   380 		 *                        'create-another-site', 'validate-user', or 'validate-site'.
   341 		 */
   381 		 */
   342 		do_action( 'signup_hidden_fields', 'create-another-site' );
   382 		do_action( 'signup_hidden_fields', 'create-another-site' );
   343 		?>
   383 		?>
   344 		<?php show_blog_form($blogname, $blog_title, $errors); ?>
   384 		<?php show_blog_form( $blogname, $blog_title, $errors ); ?>
   345 		<p class="submit"><input type="submit" name="submit" class="submit" value="<?php esc_attr_e( 'Create Site' ) ?>" /></p>
   385 		<p class="submit"><input type="submit" name="submit" class="submit" value="<?php esc_attr_e( 'Create Site' ); ?>" /></p>
   346 	</form>
   386 	</form>
   347 	<?php
   387 	<?php
   348 }
   388 }
   349 
   389 
   350 /**
   390 /**
   351  * Validate a new site signup.
   391  * Validate a new site signup for an existing user.
       
   392  *
       
   393  * @global string          $blogname   The new site's subdomain or directory name.
       
   394  * @global string          $blog_title The new site's title.
       
   395  * @global WP_Error        $errors     Existing errors in the global scope.
       
   396  * @global string          $domain     The new site's domain.
       
   397  * @global string          $path       The new site's path.
   352  *
   398  *
   353  * @since MU (3.0.0)
   399  * @since MU (3.0.0)
   354  *
   400  *
   355  * @return null|bool True if site signup was validated, false if error.
   401  * @return null|bool True if site signup was validated, false if error.
   356  *                   The function halts all execution if the user is not logged in.
   402  *                   The function halts all execution if the user is not logged in.
   363 	}
   409 	}
   364 
   410 
   365 	$result = validate_blog_form();
   411 	$result = validate_blog_form();
   366 
   412 
   367 	// Extracted values set/overwrite globals.
   413 	// Extracted values set/overwrite globals.
   368 	$domain = $result['domain'];
   414 	$domain     = $result['domain'];
   369 	$path = $result['path'];
   415 	$path       = $result['path'];
   370 	$blogname = $result['blogname'];
   416 	$blogname   = $result['blogname'];
   371 	$blog_title = $result['blog_title'];
   417 	$blog_title = $result['blog_title'];
   372 	$errors = $result['errors'];
   418 	$errors     = $result['errors'];
   373 
   419 
   374 	if ( $errors->get_error_code() ) {
   420 	if ( $errors->has_errors() ) {
   375 		signup_another_blog($blogname, $blog_title, $errors);
   421 		signup_another_blog( $blogname, $blog_title, $errors );
   376 		return false;
   422 		return false;
   377 	}
   423 	}
   378 
   424 
   379 	$public = (int) $_POST['blog_public'];
   425 	$public = (int) $_POST['blog_public'];
   380 
   426 
   381 	$blog_meta_defaults = array(
   427 	$blog_meta_defaults = array(
   382 		'lang_id' => 1,
   428 		'lang_id' => 1,
   383 		'public'  => $public
   429 		'public'  => $public,
   384 	);
   430 	);
   385 
   431 
   386 	// Handle the language setting for the new site.
   432 	// Handle the language setting for the new site.
   387 	if ( ! empty( $_POST['WPLANG'] ) ) {
   433 	if ( ! empty( $_POST['WPLANG'] ) ) {
   388 
   434 
   393 
   439 
   394 			if ( $language ) {
   440 			if ( $language ) {
   395 				$blog_meta_defaults['WPLANG'] = $language;
   441 				$blog_meta_defaults['WPLANG'] = $language;
   396 			}
   442 			}
   397 		}
   443 		}
   398 
       
   399 	}
   444 	}
   400 
   445 
   401 	/**
   446 	/**
   402 	 * Filters the new site meta variables.
   447 	 * Filters the new site meta variables.
   403 	 *
   448 	 *
   458 	} else {
   503 	} else {
   459 		$home_url  = 'http://' . $domain . $path;
   504 		$home_url  = 'http://' . $domain . $path;
   460 		$login_url = 'http://' . $domain . $path . 'wp-login.php';
   505 		$login_url = 'http://' . $domain . $path . 'wp-login.php';
   461 	}
   506 	}
   462 
   507 
   463 	$site = sprintf( '<a href="%1$s">%2$s</a>',
   508 	$site = sprintf(
       
   509 		'<a href="%1$s">%2$s</a>',
   464 		esc_url( $home_url ),
   510 		esc_url( $home_url ),
   465 		$blog_title
   511 		$blog_title
   466 	);
   512 	);
   467 
   513 
   468 	?>
   514 	?>
   469 	<h2><?php
   515 	<h2>
       
   516 	<?php
   470 		/* translators: %s: site name */
   517 		/* translators: %s: site name */
   471 		printf( __( 'The site %s is yours.' ), $site );
   518 		printf( __( 'The site %s is yours.' ), $site );
   472 	?></h2>
   519 	?>
       
   520 	</h2>
   473 	<p>
   521 	<p>
   474 		<?php printf(
   522 		<?php
       
   523 		printf(
   475 			/* translators: 1: link to new site, 2: login URL, 3: username */
   524 			/* translators: 1: link to new site, 2: login URL, 3: username */
   476 			__( '%1$s is your new site. <a href="%2$s">Log in</a> as &#8220;%3$s&#8221; using your existing password.' ),
   525 			__( '%1$s is your new site. <a href="%2$s">Log in</a> as &#8220;%3$s&#8221; using your existing password.' ),
   477 			sprintf(
   526 			sprintf(
   478 				'<a href="%s">%s</a>',
   527 				'<a href="%s">%s</a>',
   479 				esc_url( $home_url ),
   528 				esc_url( $home_url ),
   480 				untrailingslashit( $domain . $path )
   529 				untrailingslashit( $domain . $path )
   481 			),
   530 			),
   482 			esc_url( $login_url ),
   531 			esc_url( $login_url ),
   483 			$user_name
   532 			$user_name
   484 		); ?>
   533 		);
       
   534 		?>
   485 	</p>
   535 	</p>
   486 	<?php
   536 	<?php
   487 	/**
   537 	/**
   488 	 * Fires when the site or user sign-up process is complete.
   538 	 * Fires when the site or user sign-up process is complete.
   489 	 *
   539 	 *
   502  * @param WP_Error|string $errors     A WP_Error object containing existing errors. Defaults to empty string.
   552  * @param WP_Error|string $errors     A WP_Error object containing existing errors. Defaults to empty string.
   503  */
   553  */
   504 function signup_user( $user_name = '', $user_email = '', $errors = '' ) {
   554 function signup_user( $user_name = '', $user_email = '', $errors = '' ) {
   505 	global $active_signup;
   555 	global $active_signup;
   506 
   556 
   507 	if ( !is_wp_error($errors) )
   557 	if ( ! is_wp_error( $errors ) ) {
   508 		$errors = new WP_Error();
   558 		$errors = new WP_Error();
   509 
   559 	}
   510 	$signup_for = isset( $_POST[ 'signup_for' ] ) ? esc_html( $_POST[ 'signup_for' ] ) : 'blog';
   560 
       
   561 	$signup_for = isset( $_POST['signup_for'] ) ? esc_html( $_POST['signup_for'] ) : 'blog';
   511 
   562 
   512 	$signup_user_defaults = array(
   563 	$signup_user_defaults = array(
   513 		'user_name'  => $user_name,
   564 		'user_name'  => $user_name,
   514 		'user_email' => $user_email,
   565 		'user_email' => $user_email,
   515 		'errors'     => $errors,
   566 		'errors'     => $errors,
   527 	 *     @type string   $user_email The user email address.
   578 	 *     @type string   $user_email The user email address.
   528 	 *     @type WP_Error $errors     A WP_Error object with possible errors relevant to the sign-up user.
   579 	 *     @type WP_Error $errors     A WP_Error object with possible errors relevant to the sign-up user.
   529 	 * }
   580 	 * }
   530 	 */
   581 	 */
   531 	$filtered_results = apply_filters( 'signup_user_init', $signup_user_defaults );
   582 	$filtered_results = apply_filters( 'signup_user_init', $signup_user_defaults );
   532 	$user_name = $filtered_results['user_name'];
   583 	$user_name        = $filtered_results['user_name'];
   533 	$user_email = $filtered_results['user_email'];
   584 	$user_email       = $filtered_results['user_email'];
   534 	$errors = $filtered_results['errors'];
   585 	$errors           = $filtered_results['errors'];
   535 
   586 
   536 	?>
   587 	?>
   537 
   588 
   538 	<h2><?php
   589 	<h2>
       
   590 	<?php
   539 		/* translators: %s: name of the network */
   591 		/* translators: %s: name of the network */
   540 		printf( __( 'Get your own %s account in seconds' ), get_network()->site_name );
   592 		printf( __( 'Get your own %s account in seconds' ), get_network()->site_name );
   541 	?></h2>
   593 	?>
       
   594 	</h2>
   542 	<form id="setupform" method="post" action="wp-signup.php" novalidate="novalidate">
   595 	<form id="setupform" method="post" action="wp-signup.php" novalidate="novalidate">
   543 		<input type="hidden" name="stage" value="validate-user-signup" />
   596 		<input type="hidden" name="stage" value="validate-user-signup" />
   544 		<?php
   597 		<?php
   545 		/** This action is documented in wp-signup.php */
   598 		/** This action is documented in wp-signup.php */
   546 		do_action( 'signup_hidden_fields', 'validate-user' );
   599 		do_action( 'signup_hidden_fields', 'validate-user' );
   547 		?>
   600 		?>
   548 		<?php show_user_form($user_name, $user_email, $errors); ?>
   601 		<?php show_user_form( $user_name, $user_email, $errors ); ?>
   549 
   602 
   550 		<p>
   603 		<p>
   551 		<?php if ( $active_signup == 'blog' ) { ?>
   604 		<?php if ( 'blog' === $active_signup ) { ?>
   552 			<input id="signupblog" type="hidden" name="signup_for" value="blog" />
   605 			<input id="signupblog" type="hidden" name="signup_for" value="blog" />
   553 		<?php } elseif ( $active_signup == 'user' ) { ?>
   606 		<?php } elseif ( 'user' === $active_signup ) { ?>
   554 			<input id="signupblog" type="hidden" name="signup_for" value="user" />
   607 			<input id="signupblog" type="hidden" name="signup_for" value="user" />
   555 		<?php } else { ?>
   608 		<?php } else { ?>
   556 			<input id="signupblog" type="radio" name="signup_for" value="blog" <?php checked( $signup_for, 'blog' ); ?> />
   609 			<input id="signupblog" type="radio" name="signup_for" value="blog" <?php checked( $signup_for, 'blog' ); ?> />
   557 			<label class="checkbox" for="signupblog"><?php _e('Gimme a site!') ?></label>
   610 			<label class="checkbox" for="signupblog"><?php _e( 'Gimme a site!' ); ?></label>
   558 			<br />
   611 			<br />
   559 			<input id="signupuser" type="radio" name="signup_for" value="user" <?php checked( $signup_for, 'user' ); ?> />
   612 			<input id="signupuser" type="radio" name="signup_for" value="user" <?php checked( $signup_for, 'user' ); ?> />
   560 			<label class="checkbox" for="signupuser"><?php _e('Just a username, please.') ?></label>
   613 			<label class="checkbox" for="signupuser"><?php _e( 'Just a username, please.' ); ?></label>
   561 		<?php } ?>
   614 		<?php } ?>
   562 		</p>
   615 		</p>
   563 
   616 
   564 		<p class="submit"><input type="submit" name="submit" class="submit" value="<?php esc_attr_e('Next') ?>" /></p>
   617 		<p class="submit"><input type="submit" name="submit" class="submit" value="<?php esc_attr_e( 'Next' ); ?>" /></p>
   565 	</form>
   618 	</form>
   566 	<?php
   619 	<?php
   567 }
   620 }
   568 
   621 
   569 /**
   622 /**
   572  * @since MU (3.0.0)
   625  * @since MU (3.0.0)
   573  *
   626  *
   574  * @return bool True if new user signup was validated, false if error
   627  * @return bool True if new user signup was validated, false if error
   575  */
   628  */
   576 function validate_user_signup() {
   629 function validate_user_signup() {
   577 	$result = validate_user_form();
   630 	$result     = validate_user_form();
   578 	$user_name = $result['user_name'];
   631 	$user_name  = $result['user_name'];
   579 	$user_email = $result['user_email'];
   632 	$user_email = $result['user_email'];
   580 	$errors = $result['errors'];
   633 	$errors     = $result['errors'];
   581 
   634 
   582 	if ( $errors->get_error_code() ) {
   635 	if ( $errors->has_errors() ) {
   583 		signup_user($user_name, $user_email, $errors);
   636 		signup_user( $user_name, $user_email, $errors );
   584 		return false;
   637 		return false;
   585 	}
   638 	}
   586 
   639 
   587 	if ( 'blog' == $_POST['signup_for'] ) {
   640 	if ( 'blog' == $_POST['signup_for'] ) {
   588 		signup_blog($user_name, $user_email);
   641 		signup_blog( $user_name, $user_email );
   589 		return false;
   642 		return false;
   590 	}
   643 	}
   591 
   644 
   592 	/** This filter is documented in wp-signup.php */
   645 	/** This filter is documented in wp-signup.php */
   593 	wpmu_signup_user( $user_name, $user_email, apply_filters( 'add_signup_meta', array() ) );
   646 	wpmu_signup_user( $user_name, $user_email, apply_filters( 'add_signup_meta', array() ) );
   594 
   647 
   595 	confirm_user_signup($user_name, $user_email);
   648 	confirm_user_signup( $user_name, $user_email );
   596 	return true;
   649 	return true;
   597 }
   650 }
   598 
   651 
   599 /**
   652 /**
   600  * New user signup confirmation
   653  * New user signup confirmation
   602  * @since MU (3.0.0)
   655  * @since MU (3.0.0)
   603  *
   656  *
   604  * @param string $user_name The username
   657  * @param string $user_name The username
   605  * @param string $user_email The user's email address
   658  * @param string $user_email The user's email address
   606  */
   659  */
   607 function confirm_user_signup($user_name, $user_email) {
   660 function confirm_user_signup( $user_name, $user_email ) {
   608 	?>
   661 	?>
   609 	<h2><?php /* translators: %s: username */
   662 	<h2>
   610 	printf( __( '%s is your new username' ), $user_name) ?></h2>
   663 	<?php
   611 	<p><?php _e( 'But, before you can start using your new username, <strong>you must activate it</strong>.' ) ?></p>
   664 	/* translators: %s: username */
   612 	<p><?php /* translators: %s: email address */
   665 	printf( __( '%s is your new username' ), $user_name )
   613 	printf( __( 'Check your inbox at %s and click the link given.' ), '<strong>' . $user_email . '</strong>' ); ?></p>
   666 	?>
       
   667 	</h2>
       
   668 	<p><?php _e( 'But, before you can start using your new username, <strong>you must activate it</strong>.' ); ?></p>
       
   669 	<p>
       
   670 	<?php
       
   671 	/* translators: %s: email address */
       
   672 	printf( __( 'Check your inbox at %s and click the link given.' ), '<strong>' . $user_email . '</strong>' );
       
   673 	?>
       
   674 	</p>
   614 	<p><?php _e( 'If you do not activate your username within two days, you will have to sign up again.' ); ?></p>
   675 	<p><?php _e( 'If you do not activate your username within two days, you will have to sign up again.' ); ?></p>
   615 	<?php
   676 	<?php
   616 	/** This action is documented in wp-signup.php */
   677 	/** This action is documented in wp-signup.php */
   617 	do_action( 'signup_finished' );
   678 	do_action( 'signup_finished' );
   618 }
   679 }
   626  * @param string          $user_email The user's email address.
   687  * @param string          $user_email The user's email address.
   627  * @param string          $blogname   The site name.
   688  * @param string          $blogname   The site name.
   628  * @param string          $blog_title The site title.
   689  * @param string          $blog_title The site title.
   629  * @param WP_Error|string $errors     A WP_Error object containing existing errors. Defaults to empty string.
   690  * @param WP_Error|string $errors     A WP_Error object containing existing errors. Defaults to empty string.
   630  */
   691  */
   631 function signup_blog($user_name = '', $user_email = '', $blogname = '', $blog_title = '', $errors = '') {
   692 function signup_blog( $user_name = '', $user_email = '', $blogname = '', $blog_title = '', $errors = '' ) {
   632 	if ( !is_wp_error($errors) )
   693 	if ( ! is_wp_error( $errors ) ) {
   633 		$errors = new WP_Error();
   694 		$errors = new WP_Error();
       
   695 	}
   634 
   696 
   635 	$signup_blog_defaults = array(
   697 	$signup_blog_defaults = array(
   636 		'user_name'  => $user_name,
   698 		'user_name'  => $user_name,
   637 		'user_email' => $user_email,
   699 		'user_email' => $user_email,
   638 		'blogname'   => $blogname,
   700 		'blogname'   => $blogname,
   639 		'blog_title' => $blog_title,
   701 		'blog_title' => $blog_title,
   640 		'errors'     => $errors
   702 		'errors'     => $errors,
   641 	);
   703 	);
   642 
   704 
   643 	/**
   705 	/**
   644 	 * Filters the default site creation variables for the site sign-up form.
   706 	 * Filters the default site creation variables for the site sign-up form.
   645 	 *
   707 	 *
   655 	 *     @type WP_Error $errors     A WP_Error object with possible errors relevant to new site creation variables.
   717 	 *     @type WP_Error $errors     A WP_Error object with possible errors relevant to new site creation variables.
   656 	 * }
   718 	 * }
   657 	 */
   719 	 */
   658 	$filtered_results = apply_filters( 'signup_blog_init', $signup_blog_defaults );
   720 	$filtered_results = apply_filters( 'signup_blog_init', $signup_blog_defaults );
   659 
   721 
   660 	$user_name = $filtered_results['user_name'];
   722 	$user_name  = $filtered_results['user_name'];
   661 	$user_email = $filtered_results['user_email'];
   723 	$user_email = $filtered_results['user_email'];
   662 	$blogname = $filtered_results['blogname'];
   724 	$blogname   = $filtered_results['blogname'];
   663 	$blog_title = $filtered_results['blog_title'];
   725 	$blog_title = $filtered_results['blog_title'];
   664 	$errors = $filtered_results['errors'];
   726 	$errors     = $filtered_results['errors'];
   665 
   727 
   666 	if ( empty($blogname) )
   728 	if ( empty( $blogname ) ) {
   667 		$blogname = $user_name;
   729 		$blogname = $user_name;
       
   730 	}
   668 	?>
   731 	?>
   669 	<form id="setupform" method="post" action="wp-signup.php">
   732 	<form id="setupform" method="post" action="wp-signup.php">
   670 		<input type="hidden" name="stage" value="validate-blog-signup" />
   733 		<input type="hidden" name="stage" value="validate-blog-signup" />
   671 		<input type="hidden" name="user_name" value="<?php echo esc_attr($user_name) ?>" />
   734 		<input type="hidden" name="user_name" value="<?php echo esc_attr( $user_name ); ?>" />
   672 		<input type="hidden" name="user_email" value="<?php echo esc_attr($user_email) ?>" />
   735 		<input type="hidden" name="user_email" value="<?php echo esc_attr( $user_email ); ?>" />
   673 		<?php
   736 		<?php
   674 		/** This action is documented in wp-signup.php */
   737 		/** This action is documented in wp-signup.php */
   675 		do_action( 'signup_hidden_fields', 'validate-site' );
   738 		do_action( 'signup_hidden_fields', 'validate-site' );
   676 		?>
   739 		?>
   677 		<?php show_blog_form($blogname, $blog_title, $errors); ?>
   740 		<?php show_blog_form( $blogname, $blog_title, $errors ); ?>
   678 		<p class="submit"><input type="submit" name="submit" class="submit" value="<?php esc_attr_e('Signup') ?>" /></p>
   741 		<p class="submit"><input type="submit" name="submit" class="submit" value="<?php esc_attr_e( 'Signup' ); ?>" /></p>
   679 	</form>
   742 	</form>
   680 	<?php
   743 	<?php
   681 }
   744 }
   682 
   745 
   683 /**
   746 /**
   688  * @return bool True if the site signup was validated, false if error
   751  * @return bool True if the site signup was validated, false if error
   689  */
   752  */
   690 function validate_blog_signup() {
   753 function validate_blog_signup() {
   691 	// Re-validate user info.
   754 	// Re-validate user info.
   692 	$user_result = wpmu_validate_user_signup( $_POST['user_name'], $_POST['user_email'] );
   755 	$user_result = wpmu_validate_user_signup( $_POST['user_name'], $_POST['user_email'] );
   693 	$user_name = $user_result['user_name'];
   756 	$user_name   = $user_result['user_name'];
   694 	$user_email = $user_result['user_email'];
   757 	$user_email  = $user_result['user_email'];
   695 	$user_errors = $user_result['errors'];
   758 	$user_errors = $user_result['errors'];
   696 
   759 
   697 	if ( $user_errors->get_error_code() ) {
   760 	if ( $user_errors->has_errors() ) {
   698 		signup_user( $user_name, $user_email, $user_errors );
   761 		signup_user( $user_name, $user_email, $user_errors );
   699 		return false;
   762 		return false;
   700 	}
   763 	}
   701 
   764 
   702 	$result = wpmu_validate_blog_signup( $_POST['blogname'], $_POST['blog_title'] );
   765 	$result     = wpmu_validate_blog_signup( $_POST['blogname'], $_POST['blog_title'] );
   703 	$domain = $result['domain'];
   766 	$domain     = $result['domain'];
   704 	$path = $result['path'];
   767 	$path       = $result['path'];
   705 	$blogname = $result['blogname'];
   768 	$blogname   = $result['blogname'];
   706 	$blog_title = $result['blog_title'];
   769 	$blog_title = $result['blog_title'];
   707 	$errors = $result['errors'];
   770 	$errors     = $result['errors'];
   708 
   771 
   709 	if ( $errors->get_error_code() ) {
   772 	if ( $errors->has_errors() ) {
   710 		signup_blog($user_name, $user_email, $blogname, $blog_title, $errors);
   773 		signup_blog( $user_name, $user_email, $blogname, $blog_title, $errors );
   711 		return false;
   774 		return false;
   712 	}
   775 	}
   713 
   776 
   714 	$public = (int) $_POST['blog_public'];
   777 	$public      = (int) $_POST['blog_public'];
   715 	$signup_meta = array ('lang_id' => 1, 'public' => $public);
   778 	$signup_meta = array(
       
   779 		'lang_id' => 1,
       
   780 		'public'  => $public,
       
   781 	);
   716 
   782 
   717 	// Handle the language setting for the new site.
   783 	// Handle the language setting for the new site.
   718 	if ( ! empty( $_POST['WPLANG'] ) ) {
   784 	if ( ! empty( $_POST['WPLANG'] ) ) {
   719 
   785 
   720 		$languages = signup_get_available_languages();
   786 		$languages = signup_get_available_languages();
   724 
   790 
   725 			if ( $language ) {
   791 			if ( $language ) {
   726 				$signup_meta['WPLANG'] = $language;
   792 				$signup_meta['WPLANG'] = $language;
   727 			}
   793 			}
   728 		}
   794 		}
   729 
       
   730 	}
   795 	}
   731 
   796 
   732 	/** This filter is documented in wp-signup.php */
   797 	/** This filter is documented in wp-signup.php */
   733 	$meta = apply_filters( 'add_signup_meta', $signup_meta );
   798 	$meta = apply_filters( 'add_signup_meta', $signup_meta );
   734 
   799 
   735 	wpmu_signup_blog($domain, $path, $blog_title, $user_name, $user_email, $meta);
   800 	wpmu_signup_blog( $domain, $path, $blog_title, $user_name, $user_email, $meta );
   736 	confirm_blog_signup($domain, $path, $blog_title, $user_name, $user_email, $meta);
   801 	confirm_blog_signup( $domain, $path, $blog_title, $user_name, $user_email, $meta );
   737 	return true;
   802 	return true;
   738 }
   803 }
   739 
   804 
   740 /**
   805 /**
   741  * New site signup confirmation
   806  * New site signup confirmation
   749  * @param string $user_email The user's email address
   814  * @param string $user_email The user's email address
   750  * @param array $meta Any additional meta from the {@see 'add_signup_meta'} filter in validate_blog_signup()
   815  * @param array $meta Any additional meta from the {@see 'add_signup_meta'} filter in validate_blog_signup()
   751  */
   816  */
   752 function confirm_blog_signup( $domain, $path, $blog_title, $user_name = '', $user_email = '', $meta = array() ) {
   817 function confirm_blog_signup( $domain, $path, $blog_title, $user_name = '', $user_email = '', $meta = array() ) {
   753 	?>
   818 	?>
   754 	<h2><?php /* translators: %s: site address */
   819 	<h2>
   755 	printf( __( 'Congratulations! Your new site, %s, is almost ready.' ), "<a href='http://{$domain}{$path}'>{$blog_title}</a>" ) ?></h2>
   820 	<?php
   756 
   821 	/* translators: %s: site address */
   757 	<p><?php _e( 'But, before you can start using your site, <strong>you must activate it</strong>.' ) ?></p>
   822 	printf( __( 'Congratulations! Your new site, %s, is almost ready.' ), "<a href='http://{$domain}{$path}'>{$blog_title}</a>" )
   758 	<p><?php /* translators: %s: email address */
   823 	?>
   759 	printf( __( 'Check your inbox at %s and click the link given.' ), '<strong>' . $user_email . '</strong>' ); ?></p>
   824 	</h2>
       
   825 
       
   826 	<p><?php _e( 'But, before you can start using your site, <strong>you must activate it</strong>.' ); ?></p>
       
   827 	<p>
       
   828 	<?php
       
   829 	/* translators: %s: email address */
       
   830 	printf( __( 'Check your inbox at %s and click the link given.' ), '<strong>' . $user_email . '</strong>' );
       
   831 	?>
       
   832 	</p>
   760 	<p><?php _e( 'If you do not activate your site within two days, you will have to sign up again.' ); ?></p>
   833 	<p><?php _e( 'If you do not activate your site within two days, you will have to sign up again.' ); ?></p>
   761 	<h2><?php _e( 'Still waiting for your email?' ); ?></h2>
   834 	<h2><?php _e( 'Still waiting for your email?' ); ?></h2>
   762 	<p>
   835 	<p>
   763 		<?php _e( 'If you haven&#8217;t received your email yet, there are a number of things you can do:' ) ?>
   836 		<?php _e( 'If you haven&#8217;t received your email yet, there are a number of things you can do:' ); ?>
   764 		<ul id="noemail-tips">
   837 		<ul id="noemail-tips">
   765 			<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>
   838 			<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>
   766 			<li><p><?php _e( 'Check the junk or spam folder of your email client. Sometime emails wind up there by mistake.' ) ?></p></li>
   839 			<li><p><?php _e( 'Check the junk or spam folder of your email client. Sometime emails wind up there by mistake.' ); ?></p></li>
   767 			<li><?php
   840 			<li>
       
   841 			<?php
   768 				/* translators: %s: email address */
   842 				/* translators: %s: email address */
   769 				printf( __( 'Have you entered your email correctly? You have entered %s, if it&#8217;s incorrect, you will not receive your email.' ), $user_email );
   843 				printf( __( 'Have you entered your email correctly? You have entered %s, if it&#8217;s incorrect, you will not receive your email.' ), $user_email );
   770 			?></li>
   844 			?>
       
   845 			</li>
   771 		</ul>
   846 		</ul>
   772 	</p>
   847 	</p>
   773 	<?php
   848 	<?php
   774 	/** This action is documented in wp-signup.php */
   849 	/** This action is documented in wp-signup.php */
   775 	do_action( 'signup_finished' );
   850 	do_action( 'signup_finished' );
   846 	/* translators: %s: network settings URL */
   921 	/* translators: %s: network settings URL */
   847 	printf( __( 'To change or disable registration go to your <a href="%s">Options page</a>.' ), esc_url( network_admin_url( 'settings.php' ) ) );
   922 	printf( __( 'To change or disable registration go to your <a href="%s">Options page</a>.' ), esc_url( network_admin_url( 'settings.php' ) ) );
   848 	echo '</div>';
   923 	echo '</div>';
   849 }
   924 }
   850 
   925 
   851 $newblogname = isset($_GET['new']) ? strtolower(preg_replace('/^-|-$|[^-a-zA-Z0-9]/', '', $_GET['new'])) : null;
   926 $newblogname = isset( $_GET['new'] ) ? strtolower( preg_replace( '/^-|-$|[^-a-zA-Z0-9]/', '', $_GET['new'] ) ) : null;
   852 
   927 
   853 $current_user = wp_get_current_user();
   928 $current_user = wp_get_current_user();
   854 if ( $active_signup == 'none' ) {
   929 if ( 'none' === $active_signup ) {
   855 	_e( 'Registration has been disabled.' );
   930 	_e( 'Registration has been disabled.' );
   856 } elseif ( $active_signup == 'blog' && !is_user_logged_in() ) {
   931 } elseif ( 'blog' === $active_signup && ! is_user_logged_in() ) {
   857 	$login_url = wp_login_url( network_site_url( 'wp-signup.php' ) );
   932 	$login_url = wp_login_url( network_site_url( 'wp-signup.php' ) );
   858 	/* translators: %s: login URL */
   933 	/* translators: %s: login URL */
   859 	printf( __( 'You must first <a href="%s">log in</a>, and then you can create a new site.' ), $login_url );
   934 	printf( __( 'You must first <a href="%s">log in</a>, and then you can create a new site.' ), $login_url );
   860 } else {
   935 } else {
   861 	$stage = isset( $_POST['stage'] ) ?  $_POST['stage'] : 'default';
   936 	$stage = isset( $_POST['stage'] ) ? $_POST['stage'] : 'default';
   862 	switch ( $stage ) {
   937 	switch ( $stage ) {
   863 		case 'validate-user-signup' :
   938 		case 'validate-user-signup':
   864 			if ( $active_signup == 'all' || $_POST[ 'signup_for' ] == 'blog' && $active_signup == 'blog' || $_POST[ 'signup_for' ] == 'user' && $active_signup == 'user' )
   939 			if ( 'all' === $active_signup
       
   940 				|| ( 'blog' === $_POST['signup_for'] && 'blog' === $active_signup )
       
   941 				|| ( 'user' === $_POST['signup_for'] && 'user' === $active_signup )
       
   942 			) {
   865 				validate_user_signup();
   943 				validate_user_signup();
   866 			else
   944 			} else {
   867 				_e( 'User registration has been disabled.' );
   945 				_e( 'User registration has been disabled.' );
   868 		break;
   946 			}
       
   947 			break;
   869 		case 'validate-blog-signup':
   948 		case 'validate-blog-signup':
   870 			if ( $active_signup == 'all' || $active_signup == 'blog' )
   949 			if ( 'all' === $active_signup || 'blog' === $active_signup ) {
   871 				validate_blog_signup();
   950 				validate_blog_signup();
   872 			else
   951 			} else {
   873 				_e( 'Site registration has been disabled.' );
   952 				_e( 'Site registration has been disabled.' );
       
   953 			}
   874 			break;
   954 			break;
   875 		case 'gimmeanotherblog':
   955 		case 'gimmeanotherblog':
   876 			validate_another_blog_signup();
   956 			validate_another_blog_signup();
   877 			break;
   957 			break;
   878 		case 'default':
   958 		case 'default':
   879 		default :
   959 		default:
   880 			$user_email = isset( $_POST[ 'user_email' ] ) ? $_POST[ 'user_email' ] : '';
   960 			$user_email = isset( $_POST['user_email'] ) ? $_POST['user_email'] : '';
   881 			/**
   961 			/**
   882 			 * Fires when the site sign-up form is sent.
   962 			 * Fires when the site sign-up form is sent.
   883 			 *
   963 			 *
   884 			 * @since 3.0.0
   964 			 * @since 3.0.0
   885 			 */
   965 			 */
   886 			do_action( 'preprocess_signup_form' );
   966 			do_action( 'preprocess_signup_form' );
   887 			if ( is_user_logged_in() && ( $active_signup == 'all' || $active_signup == 'blog' ) )
   967 			if ( is_user_logged_in() && ( 'all' === $active_signup || 'blog' === $active_signup ) ) {
   888 				signup_another_blog($newblogname);
   968 				signup_another_blog( $newblogname );
   889 			elseif ( ! is_user_logged_in() && ( $active_signup == 'all' || $active_signup == 'user' ) )
   969 			} elseif ( ! is_user_logged_in() && ( 'all' === $active_signup || 'user' === $active_signup ) ) {
   890 				signup_user( $newblogname, $user_email );
   970 				signup_user( $newblogname, $user_email );
   891 			elseif ( ! is_user_logged_in() && ( $active_signup == 'blog' ) )
   971 			} elseif ( ! is_user_logged_in() && ( 'blog' === $active_signup ) ) {
   892 				_e( 'Sorry, new registrations are not allowed at this time.' );
   972 				_e( 'Sorry, new registrations are not allowed at this time.' );
   893 			else
   973 			} else {
   894 				_e( 'You are logged in already. No need to register again!' );
   974 				_e( 'You are logged in already. No need to register again!' );
       
   975 			}
   895 
   976 
   896 			if ( $newblogname ) {
   977 			if ( $newblogname ) {
   897 				$newblog = get_blogaddress_by_name( $newblogname );
   978 				$newblog = get_blogaddress_by_name( $newblogname );
   898 
   979 
   899 				if ( $active_signup == 'blog' || $active_signup == 'all' )
   980 				if ( 'blog' === $active_signup || 'all' === $active_signup ) {
   900 					/* translators: %s: site address */
   981 					printf(
   901 					printf( '<p><em>' . __( 'The site you were looking for, %s, does not exist, but you can create it now!' ) . '</em></p>',
   982 						/* translators: %s: site address */
       
   983 						'<p><em>' . __( 'The site you were looking for, %s, does not exist, but you can create it now!' ) . '</em></p>',
   902 						'<strong>' . $newblog . '</strong>'
   984 						'<strong>' . $newblog . '</strong>'
   903 					);
   985 					);
   904 				else
   986 				} else {
   905 					/* translators: %s: site address */
   987 					printf(
   906 					printf( '<p><em>' . __( 'The site you were looking for, %s, does not exist.' ) . '</em></p>',
   988 						/* translators: %s: site address */
       
   989 						'<p><em>' . __( 'The site you were looking for, %s, does not exist.' ) . '</em></p>',
   907 						'<strong>' . $newblog . '</strong>'
   990 						'<strong>' . $newblog . '</strong>'
   908 					);
   991 					);
       
   992 				}
   909 			}
   993 			}
   910 			break;
   994 			break;
   911 	}
   995 	}
   912 }
   996 }
   913 ?>
   997 ?>
   917 /**
  1001 /**
   918  * Fires after the sign-up forms, before wp_footer.
  1002  * Fires after the sign-up forms, before wp_footer.
   919  *
  1003  *
   920  * @since 3.0.0
  1004  * @since 3.0.0
   921  */
  1005  */
   922 do_action( 'after_signup_form' ); ?>
  1006 do_action( 'after_signup_form' );
   923 
  1007 ?>
   924 <?php get_footer( 'wp-signup' );
  1008 
       
  1009 <?php
       
  1010 get_footer( 'wp-signup' );