wp/wp-signup.php
changeset 9 177826044cd9
parent 7 cf61fcea0001
child 16 a86126ab1dd4
--- a/wp/wp-signup.php	Mon Oct 14 18:06:33 2019 +0200
+++ b/wp/wp-signup.php	Mon Oct 14 18:28:13 2019 +0200
@@ -1,7 +1,7 @@
 <?php
 
 /** Sets up the WordPress Environment. */
-require( dirname(__FILE__) . '/wp-load.php' );
+require( dirname( __FILE__ ) . '/wp-load.php' );
 
 add_action( 'wp_head', 'wp_no_robots' );
 
@@ -9,7 +9,7 @@
 
 nocache_headers();
 
-if ( is_array( get_site_option( 'illegal_names' )) && isset( $_GET[ 'new' ] ) && in_array( $_GET[ 'new' ], get_site_option( 'illegal_names' ) ) ) {
+if ( is_array( get_site_option( 'illegal_names' ) ) && isset( $_GET['new'] ) && in_array( $_GET['new'], get_site_option( 'illegal_names' ) ) ) {
 	wp_redirect( network_home_url() );
 	die();
 }
@@ -29,12 +29,12 @@
 }
 add_action( 'wp_head', 'do_signup_header' );
 
-if ( !is_multisite() ) {
+if ( ! is_multisite() ) {
 	wp_redirect( wp_registration_url() );
 	die();
 }
 
-if ( !is_main_site() ) {
+if ( ! is_main_site() ) {
 	wp_redirect( network_site_url( 'wp-signup.php' ) );
 	die();
 }
@@ -59,7 +59,7 @@
 	<style type="text/css">
 		.mu_register { width: 90%; margin:0 auto; }
 		.mu_register form { margin-top: 2em; }
-		.mu_register .error { font-weight:700; padding:10px; color:#333333; background:#FFEBE8; border:1px solid #CC0000; }
+		.mu_register .error { font-weight: 600; padding: 10px; color: #333333; background: #FFEBE8; border: 1px solid #CC0000; }
 		.mu_register input[type="submit"],
 			.mu_register #blog_title,
 			.mu_register #user_email,
@@ -67,10 +67,10 @@
 			.mu_register #user_name { width:100%; font-size: 24px; margin:5px 0; }
 		.mu_register #site-language { display: block; }
 		.mu_register .prefix_address,
-			.mu_register .suffix_address {font-size: 18px;display:inline; }
-		.mu_register label { font-weight:700; font-size:15px; display:block; margin:10px 0; }
+			.mu_register .suffix_address { font-size: 18px; display:inline; }
+		.mu_register label { font-weight: 600; font-size: 15px; display: block; margin: 10px 0; }
 		.mu_register label.checkbox { display:inline; }
-		.mu_register .mu_alert { font-weight:700; padding:10px; color:#333333; background:#ffffe0; border:1px solid #e6db55; }
+		.mu_register .mu_alert { font-weight: 600; padding: 10px; color: #333333; background: #ffffe0; border: 1px solid #e6db55; }
 	</style>
 	<?php
 }
@@ -103,20 +103,26 @@
 	}
 
 	$current_network = get_network();
-	// Blog name
-	if ( !is_subdomain_install() )
-		echo '<label for="blogname">' . __('Site Name:') . '</label>';
-	else
-		echo '<label for="blogname">' . __('Site Domain:') . '</label>';
+	// Blog name.
+	if ( ! is_subdomain_install() ) {
+		echo '<label for="blogname">' . __( 'Site Name:' ) . '</label>';
+	} else {
+		echo '<label for="blogname">' . __( 'Site Domain:' ) . '</label>';
+	}
 
-	if ( $errmsg = $errors->get_error_message('blogname') ) { ?>
-		<p class="error"><?php echo $errmsg ?></p>
-	<?php }
+	$errmsg = $errors->get_error_message( 'blogname' );
+	if ( $errmsg ) {
+		?>
+		<p class="error"><?php echo $errmsg; ?></p>
+		<?php
+	}
 
-	if ( !is_subdomain_install() )
-		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 />';
-	else
-		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 />';
+	if ( ! is_subdomain_install() ) {
+		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 />';
+	} else {
+		$site_domain = preg_replace( '|^www\.|', '', $current_network->domain );
+		echo '<input name="blogname" type="text" id="blogname" value="' . esc_attr( $blogname ) . '" maxlength="60" /><span class="suffix_address">.' . esc_html( $site_domain ) . '</span><br />';
+	}
 
 	if ( ! is_user_logged_in() ) {
 		if ( ! is_subdomain_install() ) {
@@ -131,11 +137,15 @@
 
 	// Blog Title
 	?>
-	<label for="blog_title"><?php _e('Site Title:') ?></label>
-	<?php if ( $errmsg = $errors->get_error_message('blog_title') ) { ?>
-		<p class="error"><?php echo $errmsg ?></p>
-	<?php }
-	echo '<input name="blog_title" type="text" id="blog_title" value="'.esc_attr($blog_title).'" />';
+	<label for="blog_title"><?php _e( 'Site Title:' ); ?></label>
+	<?php
+	$errmsg = $errors->get_error_message( 'blog_title' );
+	if ( $errmsg ) {
+		?>
+		<p class="error"><?php echo $errmsg; ?></p>
+		<?php
+	}
+	echo '<input name="blog_title" type="text" id="blog_title" value="' . esc_attr( $blog_title ) . '" />';
 	?>
 
 	<?php
@@ -159,31 +169,43 @@
 				$lang = '';
 			}
 
-			wp_dropdown_languages( array(
-				'name'                        => 'WPLANG',
-				'id'                          => 'site-language',
-				'selected'                    => $lang,
-				'languages'                   => $languages,
-				'show_available_translations' => false,
-			) );
+			wp_dropdown_languages(
+				array(
+					'name'                        => 'WPLANG',
+					'id'                          => 'site-language',
+					'selected'                    => $lang,
+					'languages'                   => $languages,
+					'show_available_translations' => false,
+				)
+			);
 			?>
 		</p>
-	<?php endif; // Languages. ?>
+		<?php
+		endif; // Languages.
+
+		$blog_public_on_checked  = '';
+		$blog_public_off_checked = '';
+	if ( isset( $_POST['blog_public'] ) && '0' == $_POST['blog_public'] ) {
+		$blog_public_off_checked = 'checked="checked"';
+	} else {
+		$blog_public_on_checked = 'checked="checked"';
+	}
+	?>
 
 	<div id="privacy">
-        <p class="privacy-intro">
-            <label for="blog_public_on"><?php _e('Privacy:') ?></label>
-            <?php _e( 'Allow search engines to index this site.' ); ?>
-            <br style="clear:both" />
-            <label class="checkbox" for="blog_public_on">
-                <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 } ?> />
-                <strong><?php _e( 'Yes' ); ?></strong>
-            </label>
-            <label class="checkbox" for="blog_public_off">
-                <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 } ?> />
-                <strong><?php _e( 'No' ); ?></strong>
-            </label>
-        </p>
+		<p class="privacy-intro">
+			<label for="blog_public_on"><?php _e( 'Privacy:' ); ?></label>
+			<?php _e( 'Allow search engines to index this site.' ); ?>
+			<br style="clear:both" />
+			<label class="checkbox" for="blog_public_on">
+				<input type="radio" id="blog_public_on" name="blog_public" value="1" <?php echo $blog_public_on_checked; ?> />
+				<strong><?php _e( 'Yes' ); ?></strong>
+			</label>
+			<label class="checkbox" for="blog_public_off">
+				<input type="radio" id="blog_public_off" name="blog_public" value="0" <?php echo $blog_public_off_checked; ?> />
+				<strong><?php _e( 'No' ); ?></strong>
+			</label>
+		</p>
 	</div>
 
 	<?php
@@ -206,10 +228,11 @@
  */
 function validate_blog_form() {
 	$user = '';
-	if ( is_user_logged_in() )
+	if ( is_user_logged_in() ) {
 		$user = wp_get_current_user();
+	}
 
-	return wpmu_validate_blog_signup($_POST['blogname'], $_POST['blog_title'], $user);
+	return wpmu_validate_blog_signup( $_POST['blogname'], $_POST['blog_title'], $user );
 }
 
 /**
@@ -221,27 +244,32 @@
  * @param string          $user_email The entered email address.
  * @param WP_Error|string $errors     A WP_Error object containing existing errors. Defaults to empty string.
  */
-function show_user_form($user_name = '', $user_email = '', $errors = '') {
+function show_user_form( $user_name = '', $user_email = '', $errors = '' ) {
 	if ( ! is_wp_error( $errors ) ) {
 		$errors = new WP_Error();
 	}
 
 	// User name
-	echo '<label for="user_name">' . __('Username:') . '</label>';
-	if ( $errmsg = $errors->get_error_message('user_name') ) {
-		echo '<p class="error">'.$errmsg.'</p>';
+	echo '<label for="user_name">' . __( 'Username:' ) . '</label>';
+	$errmsg = $errors->get_error_message( 'user_name' );
+	if ( $errmsg ) {
+		echo '<p class="error">' . $errmsg . '</p>';
 	}
-	echo '<input name="user_name" type="text" id="user_name" value="'. esc_attr( $user_name ) .'" autocapitalize="none" autocorrect="off" maxlength="60" /><br />';
+	echo '<input name="user_name" type="text" id="user_name" value="' . esc_attr( $user_name ) . '" autocapitalize="none" autocorrect="off" maxlength="60" /><br />';
 	_e( '(Must be at least 4 characters, letters and numbers only.)' );
 	?>
 
-	<label for="user_email"><?php _e( 'Email&nbsp;Address:' ) ?></label>
-	<?php if ( $errmsg = $errors->get_error_message('user_email') ) { ?>
-		<p class="error"><?php echo $errmsg ?></p>
+	<label for="user_email"><?php _e( 'Email&nbsp;Address:' ); ?></label>
+	<?php
+	$errmsg = $errors->get_error_message( 'user_email' );
+	if ( $errmsg ) {
+		?>
+		<p class="error"><?php echo $errmsg; ?></p>
 	<?php } ?>
-	<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.)') ?>
+	<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.)' ); ?>
 	<?php
-	if ( $errmsg = $errors->get_error_message('generic') ) {
+	$errmsg = $errors->get_error_message( 'generic' );
+	if ( $errmsg ) {
 		echo '<p class="error">' . $errmsg . '</p>';
 	}
 	/**
@@ -262,7 +290,7 @@
  * @return array Contains username, email, and error messages.
  */
 function validate_user_form() {
-	return wpmu_validate_user_signup($_POST['user_name'], $_POST['user_email']);
+	return wpmu_validate_user_signup( $_POST['user_name'], $_POST['user_email'] );
 }
 
 /**
@@ -277,14 +305,14 @@
 function signup_another_blog( $blogname = '', $blog_title = '', $errors = '' ) {
 	$current_user = wp_get_current_user();
 
-	if ( ! is_wp_error($errors) ) {
+	if ( ! is_wp_error( $errors ) ) {
 		$errors = new WP_Error();
 	}
 
 	$signup_defaults = array(
 		'blogname'   => $blogname,
 		'blog_title' => $blog_title,
-		'errors'     => $errors
+		'errors'     => $errors,
 	);
 
 	/**
@@ -302,32 +330,44 @@
 	 */
 	$filtered_results = apply_filters( 'signup_another_blog_init', $signup_defaults );
 
-	$blogname = $filtered_results['blogname'];
+	$blogname   = $filtered_results['blogname'];
 	$blog_title = $filtered_results['blog_title'];
-	$errors = $filtered_results['errors'];
+	$errors     = $filtered_results['errors'];
 
+	/* translators: %s: Network's site name. */
 	echo '<h2>' . sprintf( __( 'Get <em>another</em> %s site in seconds' ), get_network()->site_name ) . '</h2>';
 
-	if ( $errors->get_error_code() ) {
+	if ( $errors->has_errors() ) {
 		echo '<p>' . __( 'There was a problem, please correct the form below and try again.' ) . '</p>';
 	}
 	?>
-	<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>
+	<p>
+		<?php
+		printf(
+			/* translators: %s: Current user's display name. */
+			__( '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>
 
 	<?php
-	$blogs = get_blogs_of_user($current_user->ID);
-	if ( !empty($blogs) ) { ?>
+	$blogs = get_blogs_of_user( $current_user->ID );
+	if ( ! empty( $blogs ) ) {
+		?>
 
-			<p><?php _e( 'Sites you are already a member of:' ) ?></p>
+			<p><?php _e( 'Sites you are already a member of:' ); ?></p>
 			<ul>
-				<?php foreach ( $blogs as $blog ) {
+				<?php
+				foreach ( $blogs as $blog ) {
 					$home_url = get_home_url( $blog->userblog_id );
 					echo '<li><a href="' . esc_url( $home_url ) . '">' . $home_url . '</a></li>';
-				} ?>
+				}
+				?>
 			</ul>
 	<?php } ?>
 
-	<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>
+	<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>
 	<form id="setupform" method="post" action="wp-signup.php">
 		<input type="hidden" name="stage" value="gimmeanotherblog" />
 		<?php
@@ -341,14 +381,20 @@
 		 */
 		do_action( 'signup_hidden_fields', 'create-another-site' );
 		?>
-		<?php show_blog_form($blogname, $blog_title, $errors); ?>
-		<p class="submit"><input type="submit" name="submit" class="submit" value="<?php esc_attr_e( 'Create Site' ) ?>" /></p>
+		<?php show_blog_form( $blogname, $blog_title, $errors ); ?>
+		<p class="submit"><input type="submit" name="submit" class="submit" value="<?php esc_attr_e( 'Create Site' ); ?>" /></p>
 	</form>
 	<?php
 }
 
 /**
- * Validate a new site signup.
+ * Validate a new site signup for an existing user.
+ *
+ * @global string          $blogname   The new site's subdomain or directory name.
+ * @global string          $blog_title The new site's title.
+ * @global WP_Error        $errors     Existing errors in the global scope.
+ * @global string          $domain     The new site's domain.
+ * @global string          $path       The new site's path.
  *
  * @since MU (3.0.0)
  *
@@ -365,14 +411,14 @@
 	$result = validate_blog_form();
 
 	// Extracted values set/overwrite globals.
-	$domain = $result['domain'];
-	$path = $result['path'];
-	$blogname = $result['blogname'];
+	$domain     = $result['domain'];
+	$path       = $result['path'];
+	$blogname   = $result['blogname'];
 	$blog_title = $result['blog_title'];
-	$errors = $result['errors'];
+	$errors     = $result['errors'];
 
-	if ( $errors->get_error_code() ) {
-		signup_another_blog($blogname, $blog_title, $errors);
+	if ( $errors->has_errors() ) {
+		signup_another_blog( $blogname, $blog_title, $errors );
 		return false;
 	}
 
@@ -380,7 +426,7 @@
 
 	$blog_meta_defaults = array(
 		'lang_id' => 1,
-		'public'  => $public
+		'public'  => $public,
 	);
 
 	// Handle the language setting for the new site.
@@ -395,7 +441,6 @@
 				$blog_meta_defaults['WPLANG'] = $language;
 			}
 		}
-
 	}
 
 	/**
@@ -460,18 +505,22 @@
 		$login_url = 'http://' . $domain . $path . 'wp-login.php';
 	}
 
-	$site = sprintf( '<a href="%1$s">%2$s</a>',
+	$site = sprintf(
+		'<a href="%1$s">%2$s</a>',
 		esc_url( $home_url ),
 		$blog_title
 	);
 
 	?>
-	<h2><?php
+	<h2>
+	<?php
 		/* translators: %s: site name */
 		printf( __( 'The site %s is yours.' ), $site );
-	?></h2>
+	?>
+	</h2>
 	<p>
-		<?php printf(
+		<?php
+		printf(
 			/* translators: 1: link to new site, 2: login URL, 3: username */
 			__( '%1$s is your new site. <a href="%2$s">Log in</a> as &#8220;%3$s&#8221; using your existing password.' ),
 			sprintf(
@@ -481,7 +530,8 @@
 			),
 			esc_url( $login_url ),
 			$user_name
-		); ?>
+		);
+		?>
 	</p>
 	<?php
 	/**
@@ -504,10 +554,11 @@
 function signup_user( $user_name = '', $user_email = '', $errors = '' ) {
 	global $active_signup;
 
-	if ( !is_wp_error($errors) )
+	if ( ! is_wp_error( $errors ) ) {
 		$errors = new WP_Error();
+	}
 
-	$signup_for = isset( $_POST[ 'signup_for' ] ) ? esc_html( $_POST[ 'signup_for' ] ) : 'blog';
+	$signup_for = isset( $_POST['signup_for'] ) ? esc_html( $_POST['signup_for'] ) : 'blog';
 
 	$signup_user_defaults = array(
 		'user_name'  => $user_name,
@@ -529,39 +580,41 @@
 	 * }
 	 */
 	$filtered_results = apply_filters( 'signup_user_init', $signup_user_defaults );
-	$user_name = $filtered_results['user_name'];
-	$user_email = $filtered_results['user_email'];
-	$errors = $filtered_results['errors'];
+	$user_name        = $filtered_results['user_name'];
+	$user_email       = $filtered_results['user_email'];
+	$errors           = $filtered_results['errors'];
 
 	?>
 
-	<h2><?php
+	<h2>
+	<?php
 		/* translators: %s: name of the network */
 		printf( __( 'Get your own %s account in seconds' ), get_network()->site_name );
-	?></h2>
+	?>
+	</h2>
 	<form id="setupform" method="post" action="wp-signup.php" novalidate="novalidate">
 		<input type="hidden" name="stage" value="validate-user-signup" />
 		<?php
 		/** This action is documented in wp-signup.php */
 		do_action( 'signup_hidden_fields', 'validate-user' );
 		?>
-		<?php show_user_form($user_name, $user_email, $errors); ?>
+		<?php show_user_form( $user_name, $user_email, $errors ); ?>
 
 		<p>
-		<?php if ( $active_signup == 'blog' ) { ?>
+		<?php if ( 'blog' === $active_signup ) { ?>
 			<input id="signupblog" type="hidden" name="signup_for" value="blog" />
-		<?php } elseif ( $active_signup == 'user' ) { ?>
+		<?php } elseif ( 'user' === $active_signup ) { ?>
 			<input id="signupblog" type="hidden" name="signup_for" value="user" />
 		<?php } else { ?>
 			<input id="signupblog" type="radio" name="signup_for" value="blog" <?php checked( $signup_for, 'blog' ); ?> />
-			<label class="checkbox" for="signupblog"><?php _e('Gimme a site!') ?></label>
+			<label class="checkbox" for="signupblog"><?php _e( 'Gimme a site!' ); ?></label>
 			<br />
 			<input id="signupuser" type="radio" name="signup_for" value="user" <?php checked( $signup_for, 'user' ); ?> />
-			<label class="checkbox" for="signupuser"><?php _e('Just a username, please.') ?></label>
+			<label class="checkbox" for="signupuser"><?php _e( 'Just a username, please.' ); ?></label>
 		<?php } ?>
 		</p>
 
-		<p class="submit"><input type="submit" name="submit" class="submit" value="<?php esc_attr_e('Next') ?>" /></p>
+		<p class="submit"><input type="submit" name="submit" class="submit" value="<?php esc_attr_e( 'Next' ); ?>" /></p>
 	</form>
 	<?php
 }
@@ -574,25 +627,25 @@
  * @return bool True if new user signup was validated, false if error
  */
 function validate_user_signup() {
-	$result = validate_user_form();
-	$user_name = $result['user_name'];
+	$result     = validate_user_form();
+	$user_name  = $result['user_name'];
 	$user_email = $result['user_email'];
-	$errors = $result['errors'];
+	$errors     = $result['errors'];
 
-	if ( $errors->get_error_code() ) {
-		signup_user($user_name, $user_email, $errors);
+	if ( $errors->has_errors() ) {
+		signup_user( $user_name, $user_email, $errors );
 		return false;
 	}
 
 	if ( 'blog' == $_POST['signup_for'] ) {
-		signup_blog($user_name, $user_email);
+		signup_blog( $user_name, $user_email );
 		return false;
 	}
 
 	/** This filter is documented in wp-signup.php */
 	wpmu_signup_user( $user_name, $user_email, apply_filters( 'add_signup_meta', array() ) );
 
-	confirm_user_signup($user_name, $user_email);
+	confirm_user_signup( $user_name, $user_email );
 	return true;
 }
 
@@ -604,13 +657,21 @@
  * @param string $user_name The username
  * @param string $user_email The user's email address
  */
-function confirm_user_signup($user_name, $user_email) {
+function confirm_user_signup( $user_name, $user_email ) {
+	?>
+	<h2>
+	<?php
+	/* translators: %s: username */
+	printf( __( '%s is your new username' ), $user_name )
 	?>
-	<h2><?php /* translators: %s: username */
-	printf( __( '%s is your new username' ), $user_name) ?></h2>
-	<p><?php _e( 'But, before you can start using your new username, <strong>you must activate it</strong>.' ) ?></p>
-	<p><?php /* translators: %s: email address */
-	printf( __( 'Check your inbox at %s and click the link given.' ), '<strong>' . $user_email . '</strong>' ); ?></p>
+	</h2>
+	<p><?php _e( 'But, before you can start using your new username, <strong>you must activate it</strong>.' ); ?></p>
+	<p>
+	<?php
+	/* translators: %s: email address */
+	printf( __( 'Check your inbox at %s and click the link given.' ), '<strong>' . $user_email . '</strong>' );
+	?>
+	</p>
 	<p><?php _e( 'If you do not activate your username within two days, you will have to sign up again.' ); ?></p>
 	<?php
 	/** This action is documented in wp-signup.php */
@@ -628,16 +689,17 @@
  * @param string          $blog_title The site title.
  * @param WP_Error|string $errors     A WP_Error object containing existing errors. Defaults to empty string.
  */
-function signup_blog($user_name = '', $user_email = '', $blogname = '', $blog_title = '', $errors = '') {
-	if ( !is_wp_error($errors) )
+function signup_blog( $user_name = '', $user_email = '', $blogname = '', $blog_title = '', $errors = '' ) {
+	if ( ! is_wp_error( $errors ) ) {
 		$errors = new WP_Error();
+	}
 
 	$signup_blog_defaults = array(
 		'user_name'  => $user_name,
 		'user_email' => $user_email,
 		'blogname'   => $blogname,
 		'blog_title' => $blog_title,
-		'errors'     => $errors
+		'errors'     => $errors,
 	);
 
 	/**
@@ -657,25 +719,26 @@
 	 */
 	$filtered_results = apply_filters( 'signup_blog_init', $signup_blog_defaults );
 
-	$user_name = $filtered_results['user_name'];
+	$user_name  = $filtered_results['user_name'];
 	$user_email = $filtered_results['user_email'];
-	$blogname = $filtered_results['blogname'];
+	$blogname   = $filtered_results['blogname'];
 	$blog_title = $filtered_results['blog_title'];
-	$errors = $filtered_results['errors'];
+	$errors     = $filtered_results['errors'];
 
-	if ( empty($blogname) )
+	if ( empty( $blogname ) ) {
 		$blogname = $user_name;
+	}
 	?>
 	<form id="setupform" method="post" action="wp-signup.php">
 		<input type="hidden" name="stage" value="validate-blog-signup" />
-		<input type="hidden" name="user_name" value="<?php echo esc_attr($user_name) ?>" />
-		<input type="hidden" name="user_email" value="<?php echo esc_attr($user_email) ?>" />
+		<input type="hidden" name="user_name" value="<?php echo esc_attr( $user_name ); ?>" />
+		<input type="hidden" name="user_email" value="<?php echo esc_attr( $user_email ); ?>" />
 		<?php
 		/** This action is documented in wp-signup.php */
 		do_action( 'signup_hidden_fields', 'validate-site' );
 		?>
-		<?php show_blog_form($blogname, $blog_title, $errors); ?>
-		<p class="submit"><input type="submit" name="submit" class="submit" value="<?php esc_attr_e('Signup') ?>" /></p>
+		<?php show_blog_form( $blogname, $blog_title, $errors ); ?>
+		<p class="submit"><input type="submit" name="submit" class="submit" value="<?php esc_attr_e( 'Signup' ); ?>" /></p>
 	</form>
 	<?php
 }
@@ -690,29 +753,32 @@
 function validate_blog_signup() {
 	// Re-validate user info.
 	$user_result = wpmu_validate_user_signup( $_POST['user_name'], $_POST['user_email'] );
-	$user_name = $user_result['user_name'];
-	$user_email = $user_result['user_email'];
+	$user_name   = $user_result['user_name'];
+	$user_email  = $user_result['user_email'];
 	$user_errors = $user_result['errors'];
 
-	if ( $user_errors->get_error_code() ) {
+	if ( $user_errors->has_errors() ) {
 		signup_user( $user_name, $user_email, $user_errors );
 		return false;
 	}
 
-	$result = wpmu_validate_blog_signup( $_POST['blogname'], $_POST['blog_title'] );
-	$domain = $result['domain'];
-	$path = $result['path'];
-	$blogname = $result['blogname'];
+	$result     = wpmu_validate_blog_signup( $_POST['blogname'], $_POST['blog_title'] );
+	$domain     = $result['domain'];
+	$path       = $result['path'];
+	$blogname   = $result['blogname'];
 	$blog_title = $result['blog_title'];
-	$errors = $result['errors'];
+	$errors     = $result['errors'];
 
-	if ( $errors->get_error_code() ) {
-		signup_blog($user_name, $user_email, $blogname, $blog_title, $errors);
+	if ( $errors->has_errors() ) {
+		signup_blog( $user_name, $user_email, $blogname, $blog_title, $errors );
 		return false;
 	}
 
-	$public = (int) $_POST['blog_public'];
-	$signup_meta = array ('lang_id' => 1, 'public' => $public);
+	$public      = (int) $_POST['blog_public'];
+	$signup_meta = array(
+		'lang_id' => 1,
+		'public'  => $public,
+	);
 
 	// Handle the language setting for the new site.
 	if ( ! empty( $_POST['WPLANG'] ) ) {
@@ -726,14 +792,13 @@
 				$signup_meta['WPLANG'] = $language;
 			}
 		}
-
 	}
 
 	/** This filter is documented in wp-signup.php */
 	$meta = apply_filters( 'add_signup_meta', $signup_meta );
 
-	wpmu_signup_blog($domain, $path, $blog_title, $user_name, $user_email, $meta);
-	confirm_blog_signup($domain, $path, $blog_title, $user_name, $user_email, $meta);
+	wpmu_signup_blog( $domain, $path, $blog_title, $user_name, $user_email, $meta );
+	confirm_blog_signup( $domain, $path, $blog_title, $user_name, $user_email, $meta );
 	return true;
 }
 
@@ -751,23 +816,33 @@
  */
 function confirm_blog_signup( $domain, $path, $blog_title, $user_name = '', $user_email = '', $meta = array() ) {
 	?>
-	<h2><?php /* translators: %s: site address */
-	printf( __( 'Congratulations! Your new site, %s, is almost ready.' ), "<a href='http://{$domain}{$path}'>{$blog_title}</a>" ) ?></h2>
+	<h2>
+	<?php
+	/* translators: %s: site address */
+	printf( __( 'Congratulations! Your new site, %s, is almost ready.' ), "<a href='http://{$domain}{$path}'>{$blog_title}</a>" )
+	?>
+	</h2>
 
-	<p><?php _e( 'But, before you can start using your site, <strong>you must activate it</strong>.' ) ?></p>
-	<p><?php /* translators: %s: email address */
-	printf( __( 'Check your inbox at %s and click the link given.' ), '<strong>' . $user_email . '</strong>' ); ?></p>
+	<p><?php _e( 'But, before you can start using your site, <strong>you must activate it</strong>.' ); ?></p>
+	<p>
+	<?php
+	/* translators: %s: email address */
+	printf( __( 'Check your inbox at %s and click the link given.' ), '<strong>' . $user_email . '</strong>' );
+	?>
+	</p>
 	<p><?php _e( 'If you do not activate your site within two days, you will have to sign up again.' ); ?></p>
 	<h2><?php _e( 'Still waiting for your email?' ); ?></h2>
 	<p>
-		<?php _e( 'If you haven&#8217;t received your email yet, there are a number of things you can do:' ) ?>
+		<?php _e( 'If you haven&#8217;t received your email yet, there are a number of things you can do:' ); ?>
 		<ul id="noemail-tips">
-			<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>
-			<li><p><?php _e( 'Check the junk or spam folder of your email client. Sometime emails wind up there by mistake.' ) ?></p></li>
-			<li><?php
+			<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>
+			<li><p><?php _e( 'Check the junk or spam folder of your email client. Sometime emails wind up there by mistake.' ); ?></p></li>
+			<li>
+			<?php
 				/* translators: %s: email address */
 				printf( __( 'Have you entered your email correctly? You have entered %s, if it&#8217;s incorrect, you will not receive your email.' ), $user_email );
-			?></li>
+			?>
+			</li>
 		</ul>
 	</p>
 	<?php
@@ -848,64 +923,73 @@
 	echo '</div>';
 }
 
-$newblogname = isset($_GET['new']) ? strtolower(preg_replace('/^-|-$|[^-a-zA-Z0-9]/', '', $_GET['new'])) : null;
+$newblogname = isset( $_GET['new'] ) ? strtolower( preg_replace( '/^-|-$|[^-a-zA-Z0-9]/', '', $_GET['new'] ) ) : null;
 
 $current_user = wp_get_current_user();
-if ( $active_signup == 'none' ) {
+if ( 'none' === $active_signup ) {
 	_e( 'Registration has been disabled.' );
-} elseif ( $active_signup == 'blog' && !is_user_logged_in() ) {
+} elseif ( 'blog' === $active_signup && ! is_user_logged_in() ) {
 	$login_url = wp_login_url( network_site_url( 'wp-signup.php' ) );
 	/* translators: %s: login URL */
 	printf( __( 'You must first <a href="%s">log in</a>, and then you can create a new site.' ), $login_url );
 } else {
-	$stage = isset( $_POST['stage'] ) ?  $_POST['stage'] : 'default';
+	$stage = isset( $_POST['stage'] ) ? $_POST['stage'] : 'default';
 	switch ( $stage ) {
-		case 'validate-user-signup' :
-			if ( $active_signup == 'all' || $_POST[ 'signup_for' ] == 'blog' && $active_signup == 'blog' || $_POST[ 'signup_for' ] == 'user' && $active_signup == 'user' )
+		case 'validate-user-signup':
+			if ( 'all' === $active_signup
+				|| ( 'blog' === $_POST['signup_for'] && 'blog' === $active_signup )
+				|| ( 'user' === $_POST['signup_for'] && 'user' === $active_signup )
+			) {
 				validate_user_signup();
-			else
+			} else {
 				_e( 'User registration has been disabled.' );
-		break;
+			}
+			break;
 		case 'validate-blog-signup':
-			if ( $active_signup == 'all' || $active_signup == 'blog' )
+			if ( 'all' === $active_signup || 'blog' === $active_signup ) {
 				validate_blog_signup();
-			else
+			} else {
 				_e( 'Site registration has been disabled.' );
+			}
 			break;
 		case 'gimmeanotherblog':
 			validate_another_blog_signup();
 			break;
 		case 'default':
-		default :
-			$user_email = isset( $_POST[ 'user_email' ] ) ? $_POST[ 'user_email' ] : '';
+		default:
+			$user_email = isset( $_POST['user_email'] ) ? $_POST['user_email'] : '';
 			/**
 			 * Fires when the site sign-up form is sent.
 			 *
 			 * @since 3.0.0
 			 */
 			do_action( 'preprocess_signup_form' );
-			if ( is_user_logged_in() && ( $active_signup == 'all' || $active_signup == 'blog' ) )
-				signup_another_blog($newblogname);
-			elseif ( ! is_user_logged_in() && ( $active_signup == 'all' || $active_signup == 'user' ) )
+			if ( is_user_logged_in() && ( 'all' === $active_signup || 'blog' === $active_signup ) ) {
+				signup_another_blog( $newblogname );
+			} elseif ( ! is_user_logged_in() && ( 'all' === $active_signup || 'user' === $active_signup ) ) {
 				signup_user( $newblogname, $user_email );
-			elseif ( ! is_user_logged_in() && ( $active_signup == 'blog' ) )
+			} elseif ( ! is_user_logged_in() && ( 'blog' === $active_signup ) ) {
 				_e( 'Sorry, new registrations are not allowed at this time.' );
-			else
+			} else {
 				_e( 'You are logged in already. No need to register again!' );
+			}
 
 			if ( $newblogname ) {
 				$newblog = get_blogaddress_by_name( $newblogname );
 
-				if ( $active_signup == 'blog' || $active_signup == 'all' )
-					/* translators: %s: site address */
-					printf( '<p><em>' . __( 'The site you were looking for, %s, does not exist, but you can create it now!' ) . '</em></p>',
+				if ( 'blog' === $active_signup || 'all' === $active_signup ) {
+					printf(
+						/* translators: %s: site address */
+						'<p><em>' . __( 'The site you were looking for, %s, does not exist, but you can create it now!' ) . '</em></p>',
 						'<strong>' . $newblog . '</strong>'
 					);
-				else
-					/* translators: %s: site address */
-					printf( '<p><em>' . __( 'The site you were looking for, %s, does not exist.' ) . '</em></p>',
+				} else {
+					printf(
+						/* translators: %s: site address */
+						'<p><em>' . __( 'The site you were looking for, %s, does not exist.' ) . '</em></p>',
 						'<strong>' . $newblog . '</strong>'
 					);
+				}
 			}
 			break;
 	}
@@ -919,6 +1003,8 @@
  *
  * @since 3.0.0
  */
-do_action( 'after_signup_form' ); ?>
+do_action( 'after_signup_form' );
+?>
 
-<?php get_footer( 'wp-signup' );
+<?php
+get_footer( 'wp-signup' );