wp/wp-activate.php
changeset 21 48c4eec2b7e6
parent 18 be944660c56a
equal deleted inserted replaced
20:7b1b88e27a20 21:48c4eec2b7e6
    85  *
    85  *
    86  * @since MU (3.0.0)
    86  * @since MU (3.0.0)
    87  */
    87  */
    88 function do_activate_header() {
    88 function do_activate_header() {
    89 	/**
    89 	/**
    90 	 * Fires before the Site Activation page is loaded.
    90 	 * Fires within the `<head>` section of the Site Activation page.
    91 	 *
    91 	 *
    92 	 * Fires on the {@see 'wp_head'} action.
    92 	 * Fires on the {@see 'wp_head'} action.
    93 	 *
    93 	 *
    94 	 * @since 3.0.0
    94 	 * @since 3.0.0
    95 	 */
    95 	 */
   103  * @since MU (3.0.0)
   103  * @since MU (3.0.0)
   104  */
   104  */
   105 function wpmu_activate_stylesheet() {
   105 function wpmu_activate_stylesheet() {
   106 	?>
   106 	?>
   107 	<style type="text/css">
   107 	<style type="text/css">
   108 		form { margin-top: 2em; }
   108 		.wp-activate-container { width: 90%; margin: 0 auto; }
   109 		#submit, #key { width: 90%; font-size: 24px; }
   109 		.wp-activate-container form { margin-top: 2em; }
   110 		#language { margin-top: .5em; }
   110 		#submit, #key { width: 100%; font-size: 24px; box-sizing: border-box; }
   111 		.error { background: #f66; }
   111 		#language { margin-top: 0.5em; }
       
   112 		.wp-activate-container .error { background: #f66; color: #333; }
   112 		span.h3 { padding: 0 8px; font-size: 1.3em; font-weight: 600; }
   113 		span.h3 { padding: 0 8px; font-size: 1.3em; font-weight: 600; }
   113 	</style>
   114 	</style>
   114 	<?php
   115 	<?php
   115 }
   116 }
   116 add_action( 'wp_head', 'wpmu_activate_stylesheet' );
   117 add_action( 'wp_head', 'wpmu_activate_stylesheet' );
   117 add_action( 'wp_head', 'wp_strict_cross_origin_referrer' );
   118 add_action( 'wp_head', 'wp_strict_cross_origin_referrer' );
   118 add_filter( 'wp_robots', 'wp_robots_sensitive_page' );
   119 add_filter( 'wp_robots', 'wp_robots_sensitive_page' );
   119 
   120 
   120 get_header( 'wp-activate' );
   121 get_header( 'wp-activate' );
   121 
   122 
   122 $blog_details = get_blog_details();
   123 $blog_details = get_site();
   123 ?>
   124 ?>
   124 
   125 
   125 <div id="signup-content" class="widecolumn">
   126 <div id="signup-content" class="widecolumn">
   126 	<div class="wp-activate-container">
   127 	<div class="wp-activate-container">
   127 	<?php if ( ! $key ) { ?>
   128 	<?php if ( ! $key ) { ?>
   128 
   129 
   129 		<h2><?php _e( 'Activation Key Required' ); ?></h2>
   130 		<h2><?php _e( 'Activation Key Required' ); ?></h2>
   130 		<form name="activateform" id="activateform" method="post" action="<?php echo network_site_url( $blog_details->path . 'wp-activate.php' ); ?>">
   131 		<form name="activateform" id="activateform" method="post" action="<?php echo esc_url( network_site_url( $blog_details->path . 'wp-activate.php' ) ); ?>">
   131 			<p>
   132 			<p>
   132 				<label for="key"><?php _e( 'Activation Key:' ); ?></label>
   133 				<label for="key"><?php _e( 'Activation Key:' ); ?></label>
   133 				<br /><input type="text" name="key" id="key" value="" size="50" />
   134 				<br /><input type="text" name="key" id="key" value="" size="50" autofocus="autofocus" />
   134 			</p>
   135 			</p>
   135 			<p class="submit">
   136 			<p class="submit">
   136 				<input id="submit" type="submit" name="Submit" class="submit" value="<?php esc_attr_e( 'Activate' ); ?>" />
   137 				<input id="submit" type="submit" name="Submit" class="submit" value="<?php esc_attr_e( 'Activate' ); ?>" />
   137 			</p>
   138 			</p>
   138 		</form>
   139 		</form>
   147 			echo '<p class="lead-in">';
   148 			echo '<p class="lead-in">';
   148 			if ( '' === $signup->domain . $signup->path ) {
   149 			if ( '' === $signup->domain . $signup->path ) {
   149 				printf(
   150 				printf(
   150 					/* translators: 1: Login URL, 2: Username, 3: User email address, 4: Lost password URL. */
   151 					/* translators: 1: Login URL, 2: Username, 3: User email address, 4: Lost password URL. */
   151 					__( 'Your account has been activated. You may now <a href="%1$s">log in</a> to the site using your chosen username of &#8220;%2$s&#8221;. Please check your email inbox at %3$s for your password and login instructions. If you do not receive an email, please check your junk or spam folder. If you still do not receive an email within an hour, you can <a href="%4$s">reset your password</a>.' ),
   152 					__( 'Your account has been activated. You may now <a href="%1$s">log in</a> to the site using your chosen username of &#8220;%2$s&#8221;. Please check your email inbox at %3$s for your password and login instructions. If you do not receive an email, please check your junk or spam folder. If you still do not receive an email within an hour, you can <a href="%4$s">reset your password</a>.' ),
   152 					network_site_url( $blog_details->path . 'wp-login.php', 'login' ),
   153 					esc_url( network_site_url( $blog_details->path . 'wp-login.php', 'login' ) ),
   153 					$signup->user_login,
   154 					esc_html( $signup->user_login ),
   154 					$signup->user_email,
   155 					esc_html( $signup->user_email ),
   155 					wp_lostpassword_url()
   156 					esc_url( wp_lostpassword_url() )
   156 				);
   157 				);
   157 			} else {
   158 			} else {
   158 				printf(
   159 				printf(
   159 					/* translators: 1: Site URL, 2: Username, 3: User email address, 4: Lost password URL. */
   160 					/* translators: 1: Site URL, 2: Username, 3: User email address, 4: Lost password URL. */
   160 					__( 'Your site at %1$s is active. You may now log in to your site using your chosen username of &#8220;%2$s&#8221;. Please check your email inbox at %3$s for your password and login instructions. If you do not receive an email, please check your junk or spam folder. If you still do not receive an email within an hour, you can <a href="%4$s">reset your password</a>.' ),
   161 					__( 'Your site at %1$s is active. You may now log in to your site using your chosen username of &#8220;%2$s&#8221;. Please check your email inbox at %3$s for your password and login instructions. If you do not receive an email, please check your junk or spam folder. If you still do not receive an email within an hour, you can <a href="%4$s">reset your password</a>.' ),
   161 					sprintf( '<a href="http://%1$s%2$s">%1$s%2$s</a>', $signup->domain, $blog_details->path ),
   162 					sprintf( '<a href="http://%1$s">%1$s</a>', esc_url( $signup->domain . $blog_details->path ) ),
   162 					$signup->user_login,
   163 					esc_html( $signup->user_login ),
   163 					$signup->user_email,
   164 					esc_html( $signup->user_email ),
   164 					wp_lostpassword_url()
   165 					esc_url( wp_lostpassword_url() )
   165 				);
   166 				);
   166 			}
   167 			}
   167 			echo '</p>';
   168 			echo '</p>';
   168 		} elseif ( null === $result || is_wp_error( $result ) ) {
   169 		} elseif ( null === $result || is_wp_error( $result ) ) {
   169 			?>
   170 			?>
   170 			<h2><?php _e( 'An error occurred during the activation' ); ?></h2>
   171 			<h2><?php _e( 'An error occurred during the activation' ); ?></h2>
   171 			<?php if ( is_wp_error( $result ) ) : ?>
   172 			<?php if ( is_wp_error( $result ) ) : ?>
   172 				<p><?php echo $result->get_error_message(); ?></p>
   173 				<p><?php echo esc_html( $result->get_error_message() ); ?></p>
   173 			<?php endif; ?>
   174 			<?php endif; ?>
   174 			<?php
   175 			<?php
   175 		} else {
   176 		} else {
   176 			$url  = isset( $result['blog_id'] ) ? get_home_url( (int) $result['blog_id'] ) : '';
   177 			$url  = isset( $result['blog_id'] ) ? esc_url( get_home_url( (int) $result['blog_id'] ) ) : '';
   177 			$user = get_userdata( (int) $result['user_id'] );
   178 			$user = get_userdata( (int) $result['user_id'] );
   178 			?>
   179 			?>
   179 			<h2><?php _e( 'Your account is now active!' ); ?></h2>
   180 			<h2><?php _e( 'Your account is now active!' ); ?></h2>
   180 
   181 
   181 			<div id="signup-welcome">
   182 			<div id="signup-welcome">
   182 			<p><span class="h3"><?php _e( 'Username:' ); ?></span> <?php echo $user->user_login; ?></p>
   183 			<p><span class="h3"><?php _e( 'Username:' ); ?></span> <?php echo esc_html( $user->user_login ); ?></p>
   183 			<p><span class="h3"><?php _e( 'Password:' ); ?></span> <?php echo $result['password']; ?></p>
   184 			<p><span class="h3"><?php _e( 'Password:' ); ?></span> <?php echo esc_html( $result['password'] ); ?></p>
   184 			</div>
   185 			</div>
   185 
   186 
   186 			<?php
   187 			<?php
   187 			if ( $url && network_home_url( '', 'http' ) !== $url ) :
   188 			if ( $url && network_home_url( '', 'http' ) !== $url ) :
   188 				switch_to_blog( (int) $result['blog_id'] );
   189 				switch_to_blog( (int) $result['blog_id'] );
   190 				restore_current_blog();
   191 				restore_current_blog();
   191 				?>
   192 				?>
   192 				<p class="view">
   193 				<p class="view">
   193 				<?php
   194 				<?php
   194 					/* translators: 1: Site URL, 2: Login URL. */
   195 					/* translators: 1: Site URL, 2: Login URL. */
   195 					printf( __( 'Your account is now activated. <a href="%1$s">View your site</a> or <a href="%2$s">Log in</a>' ), $url, esc_url( $login_url ) );
   196 					printf( __( 'Your account is now activated. <a href="%1$s">View your site</a> or <a href="%2$s">Log in</a>' ), esc_url( $url ), esc_url( $login_url ) );
   196 				?>
   197 				?>
   197 				</p>
   198 				</p>
   198 			<?php else : ?>
   199 			<?php else : ?>
   199 				<p class="view">
   200 				<p class="view">
   200 				<?php
   201 				<?php
   201 					printf(
   202 					printf(
   202 						/* translators: 1: Login URL, 2: Network home URL. */
   203 						/* translators: 1: Login URL, 2: Network home URL. */
   203 						__( 'Your account is now activated. <a href="%1$s">Log in</a> or go back to the <a href="%2$s">homepage</a>.' ),
   204 						__( 'Your account is now activated. <a href="%1$s">Log in</a> or go back to the <a href="%2$s">homepage</a>.' ),
   204 						network_site_url( $blog_details->path . 'wp-login.php', 'login' ),
   205 						esc_url( network_site_url( $blog_details->path . 'wp-login.php', 'login' ) ),
   205 						network_home_url( $blog_details->path )
   206 						esc_url( network_home_url( $blog_details->path ) )
   206 					);
   207 					);
   207 				?>
   208 				?>
   208 				</p>
   209 				</p>
   209 				<?php
   210 				<?php
   210 				endif;
   211 				endif;
   211 		}
   212 		}
   212 	}
   213 	}
   213 	?>
   214 	?>
   214 	</div>
   215 	</div>
   215 </div>
   216 </div>
   216 <script type="text/javascript">
       
   217 	var key_input = document.getElementById('key');
       
   218 	key_input && key_input.focus();
       
   219 </script>
       
   220 <?php
   217 <?php
   221 get_footer( 'wp-activate' );
   218 get_footer( 'wp-activate' );