wp/wp-activate.php
changeset 16 a86126ab1dd4
parent 9 177826044cd9
child 18 be944660c56a
equal deleted inserted replaced
15:3d4e9c994f10 16:a86126ab1dd4
     7  */
     7  */
     8 
     8 
     9 define( 'WP_INSTALLING', true );
     9 define( 'WP_INSTALLING', true );
    10 
    10 
    11 /** Sets up the WordPress Environment. */
    11 /** Sets up the WordPress Environment. */
    12 require( dirname( __FILE__ ) . '/wp-load.php' );
    12 require __DIR__ . '/wp-load.php';
    13 
    13 
    14 require( dirname( __FILE__ ) . '/wp-blog-header.php' );
    14 require __DIR__ . '/wp-blog-header.php';
    15 
    15 
    16 if ( ! is_multisite() ) {
    16 if ( ! is_multisite() ) {
    17 	wp_redirect( wp_registration_url() );
    17 	wp_redirect( wp_registration_url() );
    18 	die();
    18 	die();
    19 }
    19 }
    35 }
    35 }
    36 
    36 
    37 if ( $key ) {
    37 if ( $key ) {
    38 	$redirect_url = remove_query_arg( 'key' );
    38 	$redirect_url = remove_query_arg( 'key' );
    39 
    39 
    40 	if ( $redirect_url !== remove_query_arg( false ) ) {
    40 	if ( remove_query_arg( false ) !== $redirect_url ) {
    41 		setcookie( $activate_cookie, $key, 0, $activate_path, COOKIE_DOMAIN, is_ssl(), true );
    41 		setcookie( $activate_cookie, $key, 0, $activate_path, COOKIE_DOMAIN, is_ssl(), true );
    42 		wp_safe_redirect( $redirect_url );
    42 		wp_safe_redirect( $redirect_url );
    43 		exit;
    43 		exit;
    44 	} else {
    44 	} else {
    45 		$result = wpmu_activate_signup( $key );
    45 		$result = wpmu_activate_signup( $key );
    46 	}
    46 	}
    47 }
    47 }
    48 
    48 
    49 if ( $result === null && isset( $_COOKIE[ $activate_cookie ] ) ) {
    49 if ( null === $result && isset( $_COOKIE[ $activate_cookie ] ) ) {
    50 	$key    = $_COOKIE[ $activate_cookie ];
    50 	$key    = $_COOKIE[ $activate_cookie ];
    51 	$result = wpmu_activate_signup( $key );
    51 	$result = wpmu_activate_signup( $key );
    52 	setcookie( $activate_cookie, ' ', time() - YEAR_IN_SECONDS, $activate_path, COOKIE_DOMAIN, is_ssl(), true );
    52 	setcookie( $activate_cookie, ' ', time() - YEAR_IN_SECONDS, $activate_path, COOKIE_DOMAIN, is_ssl(), true );
    53 }
    53 }
    54 
    54 
    55 if ( $result === null || ( is_wp_error( $result ) && 'invalid_key' === $result->get_error_code() ) ) {
    55 if ( null === $result || ( is_wp_error( $result ) && 'invalid_key' === $result->get_error_code() ) ) {
    56 	status_header( 404 );
    56 	status_header( 404 );
    57 } elseif ( is_wp_error( $result ) ) {
    57 } elseif ( is_wp_error( $result ) ) {
    58 	$error_code = $result->get_error_code();
    58 	$error_code = $result->get_error_code();
    59 
    59 
    60 	if ( ! in_array( $error_code, $valid_error_codes ) ) {
    60 	if ( ! in_array( $error_code, $valid_error_codes, true ) ) {
    61 		status_header( 400 );
    61 		status_header( 400 );
    62 	}
    62 	}
    63 }
    63 }
    64 
    64 
    65 nocache_headers();
    65 nocache_headers();
    66 
    66 
    67 if ( is_object( $wp_object_cache ) ) {
    67 if ( is_object( $wp_object_cache ) ) {
    68 	$wp_object_cache->cache_enabled = false;
    68 	$wp_object_cache->cache_enabled = false;
    69 }
    69 }
    70 
    70 
    71 // Fix for page title
    71 // Fix for page title.
    72 $wp_query->is_404 = false;
    72 $wp_query->is_404 = false;
    73 
    73 
    74 /**
    74 /**
    75  * Fires before the Site Activation page is loaded.
    75  * Fires before the Site Activation page is loaded.
    76  *
    76  *
   115 }
   115 }
   116 add_action( 'wp_head', 'wpmu_activate_stylesheet' );
   116 add_action( 'wp_head', 'wpmu_activate_stylesheet' );
   117 add_action( 'wp_head', 'wp_sensitive_page_meta' );
   117 add_action( 'wp_head', 'wp_sensitive_page_meta' );
   118 
   118 
   119 get_header( 'wp-activate' );
   119 get_header( 'wp-activate' );
       
   120 
       
   121 $blog_details = get_blog_details();
   120 ?>
   122 ?>
   121 
   123 
   122 <div id="signup-content" class="widecolumn">
   124 <div id="signup-content" class="widecolumn">
   123 	<div class="wp-activate-container">
   125 	<div class="wp-activate-container">
   124 	<?php if ( ! $key ) { ?>
   126 	<?php if ( ! $key ) { ?>
   125 
   127 
   126 		<h2><?php _e( 'Activation Key Required' ); ?></h2>
   128 		<h2><?php _e( 'Activation Key Required' ); ?></h2>
   127 		<form name="activateform" id="activateform" method="post" action="<?php echo network_site_url( 'wp-activate.php' ); ?>">
   129 		<form name="activateform" id="activateform" method="post" action="<?php echo network_site_url( $blog_details->path . 'wp-activate.php' ); ?>">
   128 			<p>
   130 			<p>
   129 				<label for="key"><?php _e( 'Activation Key:' ); ?></label>
   131 				<label for="key"><?php _e( 'Activation Key:' ); ?></label>
   130 				<br /><input type="text" name="key" id="key" value="" size="50" />
   132 				<br /><input type="text" name="key" id="key" value="" size="50" />
   131 			</p>
   133 			</p>
   132 			<p class="submit">
   134 			<p class="submit">
   134 			</p>
   136 			</p>
   135 		</form>
   137 		</form>
   136 
   138 
   137 		<?php
   139 		<?php
   138 	} else {
   140 	} else {
   139 		if ( is_wp_error( $result ) && in_array( $result->get_error_code(), $valid_error_codes ) ) {
   141 		if ( is_wp_error( $result ) && in_array( $result->get_error_code(), $valid_error_codes, true ) ) {
   140 			$signup = $result->get_error_data();
   142 			$signup = $result->get_error_data();
   141 			?>
   143 			?>
   142 			<h2><?php _e( 'Your account is now active!' ); ?></h2>
   144 			<h2><?php _e( 'Your account is now active!' ); ?></h2>
   143 			<?php
   145 			<?php
   144 			echo '<p class="lead-in">';
   146 			echo '<p class="lead-in">';
   145 			if ( $signup->domain . $signup->path == '' ) {
   147 			if ( '' === $signup->domain . $signup->path ) {
   146 				printf(
   148 				printf(
   147 					/* translators: 1: login URL, 2: username, 3: user email, 4: lost password URL */
   149 					/* translators: 1: Login URL, 2: Username, 3: User email address, 4: Lost password URL. */
   148 					__( '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>.' ),
   150 					__( '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>.' ),
   149 					network_site_url( 'wp-login.php', 'login' ),
   151 					network_site_url( $blog_details->path . 'wp-login.php', 'login' ),
   150 					$signup->user_login,
   152 					$signup->user_login,
   151 					$signup->user_email,
   153 					$signup->user_email,
   152 					wp_lostpassword_url()
   154 					wp_lostpassword_url()
   153 				);
   155 				);
   154 			} else {
   156 			} else {
   155 				printf(
   157 				printf(
   156 					/* translators: 1: site URL, 2: username, 3: user email, 4: lost password URL */
   158 					/* translators: 1: Site URL, 2: Username, 3: User email address, 4: Lost password URL. */
   157 					__( '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>.' ),
   159 					__( '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>.' ),
   158 					sprintf( '<a href="http://%1$s">%1$s</a>', $signup->domain ),
   160 					sprintf( '<a href="http://%1$s%2$s">%1$s%2$s</a>', $signup->domain, $blog_details->path ),
   159 					$signup->user_login,
   161 					$signup->user_login,
   160 					$signup->user_email,
   162 					$signup->user_email,
   161 					wp_lostpassword_url()
   163 					wp_lostpassword_url()
   162 				);
   164 				);
   163 			}
   165 			}
   164 			echo '</p>';
   166 			echo '</p>';
   165 		} elseif ( $result === null || is_wp_error( $result ) ) {
   167 		} elseif ( null === $result || is_wp_error( $result ) ) {
   166 			?>
   168 			?>
   167 			<h2><?php _e( 'An error occurred during the activation' ); ?></h2>
   169 			<h2><?php _e( 'An error occurred during the activation' ); ?></h2>
   168 			<?php if ( is_wp_error( $result ) ) : ?>
   170 			<?php if ( is_wp_error( $result ) ) : ?>
   169 				<p><?php echo $result->get_error_message(); ?></p>
   171 				<p><?php echo $result->get_error_message(); ?></p>
   170 			<?php endif; ?>
   172 			<?php endif; ?>
   179 			<p><span class="h3"><?php _e( 'Username:' ); ?></span> <?php echo $user->user_login; ?></p>
   181 			<p><span class="h3"><?php _e( 'Username:' ); ?></span> <?php echo $user->user_login; ?></p>
   180 			<p><span class="h3"><?php _e( 'Password:' ); ?></span> <?php echo $result['password']; ?></p>
   182 			<p><span class="h3"><?php _e( 'Password:' ); ?></span> <?php echo $result['password']; ?></p>
   181 			</div>
   183 			</div>
   182 
   184 
   183 			<?php
   185 			<?php
   184 			if ( $url && $url != network_home_url( '', 'http' ) ) :
   186 			if ( $url && network_home_url( '', 'http' ) !== $url ) :
   185 				switch_to_blog( (int) $result['blog_id'] );
   187 				switch_to_blog( (int) $result['blog_id'] );
   186 				$login_url = wp_login_url();
   188 				$login_url = wp_login_url();
   187 				restore_current_blog();
   189 				restore_current_blog();
   188 				?>
   190 				?>
   189 				<p class="view">
   191 				<p class="view">
   190 				<?php
   192 				<?php
   191 					/* translators: 1: site URL, 2: login URL */
   193 					/* translators: 1: Site URL, 2: Login URL. */
   192 					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 ) );
   194 					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 ) );
   193 				?>
   195 				?>
   194 				</p>
   196 				</p>
   195 			<?php else : ?>
   197 			<?php else : ?>
   196 				<p class="view">
   198 				<p class="view">
   197 				<?php
   199 				<?php
   198 					/* translators: 1: login URL, 2: network home URL */
   200 					printf(
   199 					printf( __( 'Your account is now activated. <a href="%1$s">Log in</a> or go back to the <a href="%2$s">homepage</a>.' ), network_site_url( 'wp-login.php', 'login' ), network_home_url() );
   201 						/* translators: 1: Login URL, 2: Network home URL. */
       
   202 						__( 'Your account is now activated. <a href="%1$s">Log in</a> or go back to the <a href="%2$s">homepage</a>.' ),
       
   203 						network_site_url( $blog_details->path . 'wp-login.php', 'login' ),
       
   204 						network_home_url( $blog_details->path )
       
   205 					);
   200 				?>
   206 				?>
   201 				</p>
   207 				</p>
   202 				<?php
   208 				<?php
   203 				endif;
   209 				endif;
   204 		}
   210 		}