2010-01-06 02:50:12 -05:00
< ? php
2012-08-05 20:59:34 -04:00
/**
* Confirms that the activation key that is sent in an email after a user signs
2016-01-27 22:35:27 -05:00
* up for a new site matches the key for that user and then displays confirmation .
2012-11-17 10:11:29 -05:00
*
2012-08-05 20:59:34 -04:00
* @ package WordPress
*/
2011-04-17 17:31:38 -04:00
define ( 'WP_INSTALLING' , true );
2010-01-06 02:50:12 -05:00
/** Sets up the WordPress Environment. */
2020-02-06 01:33:11 -05:00
require __DIR__ . '/wp-load.php' ;
2010-01-06 02:50:12 -05:00
2020-02-06 01:33:11 -05:00
require __DIR__ . '/wp-blog-header.php' ;
2010-01-26 16:39:06 -05:00
2017-11-30 18:11:00 -05:00
if ( ! is_multisite () ) {
2015-09-15 13:11:35 -04:00
wp_redirect ( wp_registration_url () );
2010-01-26 16:39:06 -05:00
die ();
}
2018-12-12 19:23:24 -05:00
$valid_error_codes = array ( 'already_active' , 'blog_taken' );
list ( $activate_path ) = explode ( '?' , wp_unslash ( $_SERVER [ 'REQUEST_URI' ] ) );
$activate_cookie = 'wp-activate-' . COOKIEHASH ;
$key = '' ;
$result = null ;
2018-12-12 20:26:24 -05:00
if ( isset ( $_GET [ 'key' ] ) && isset ( $_POST [ 'key' ] ) && $_GET [ 'key' ] !== $_POST [ 'key' ] ) {
wp_die ( __ ( 'A key value mismatch has been detected. Please follow the link provided in your activation email.' ), __ ( 'An error occurred during the activation' ), 400 );
} elseif ( ! empty ( $_GET [ 'key' ] ) ) {
2018-12-12 19:23:24 -05:00
$key = $_GET [ 'key' ];
} elseif ( ! empty ( $_POST [ 'key' ] ) ) {
$key = $_POST [ 'key' ];
}
if ( $key ) {
$redirect_url = remove_query_arg ( 'key' );
2020-01-08 19:55:05 -05:00
if ( remove_query_arg ( false ) !== $redirect_url ) {
2018-12-12 19:23:24 -05:00
setcookie ( $activate_cookie , $key , 0 , $activate_path , COOKIE_DOMAIN , is_ssl (), true );
wp_safe_redirect ( $redirect_url );
exit ;
} else {
$result = wpmu_activate_signup ( $key );
}
}
2020-01-08 19:55:05 -05:00
if ( null === $result && isset ( $_COOKIE [ $activate_cookie ] ) ) {
2018-12-12 19:23:24 -05:00
$key = $_COOKIE [ $activate_cookie ];
$result = wpmu_activate_signup ( $key );
setcookie ( $activate_cookie , ' ' , time () - YEAR_IN_SECONDS , $activate_path , COOKIE_DOMAIN , is_ssl (), true );
}
2020-01-08 19:55:05 -05:00
if ( null === $result || ( is_wp_error ( $result ) && 'invalid_key' === $result -> get_error_code () ) ) {
2018-12-12 19:23:24 -05:00
status_header ( 404 );
} elseif ( is_wp_error ( $result ) ) {
$error_code = $result -> get_error_code ();
2020-04-04 23:02:11 -04:00
if ( ! in_array ( $error_code , $valid_error_codes , true ) ) {
2018-12-12 19:23:24 -05:00
status_header ( 400 );
}
}
2018-05-01 18:08:20 -04:00
nocache_headers ();
2017-11-30 18:11:00 -05:00
if ( is_object ( $wp_object_cache ) ) {
2010-01-06 02:50:12 -05:00
$wp_object_cache -> cache_enabled = false ;
2017-11-30 18:11:00 -05:00
}
2010-01-06 02:50:12 -05:00
2020-01-28 19:45:18 -05:00
// Fix for page title.
2013-10-04 10:12:11 -04:00
$wp_query -> is_404 = false ;
2013-09-21 01:21:09 -04:00
/**
* Fires before the Site Activation page is loaded .
*
2013-12-24 13:57:12 -05:00
* @ since 3.0 . 0
2013-09-21 01:21:09 -04:00
*/
2011-04-17 17:31:38 -04:00
do_action ( 'activate_header' );
2010-01-06 02:50:12 -05:00
2012-08-05 20:59:34 -04:00
/**
2016-05-23 13:07:28 -04:00
* Adds an action hook specific to this page .
*
* Fires on { @ see 'wp_head' } .
2012-11-17 10:11:29 -05:00
*
2017-08-01 16:44:43 -04:00
* @ since MU ( 3.0 . 0 )
2012-08-05 20:59:34 -04:00
*/
2010-02-12 19:33:47 -05:00
function do_activate_header () {
2016-05-23 13:07:28 -04:00
/**
* Fires before the Site Activation page is loaded .
*
* Fires on the { @ see 'wp_head' } action .
2017-11-30 18:11:00 -05:00
*
* @ since 3.0 . 0
*/
do_action ( 'activate_wp_head' );
2010-02-12 19:33:47 -05:00
}
add_action ( 'wp_head' , 'do_activate_header' );
2012-08-05 20:59:34 -04:00
/**
* Loads styles specific to this page .
2012-11-17 10:11:29 -05:00
*
2017-08-01 16:44:43 -04:00
* @ since MU ( 3.0 . 0 )
2012-08-05 20:59:34 -04:00
*/
2010-01-06 02:50:12 -05:00
function wpmu_activate_stylesheet () {
?>
2010-01-15 17:11:12 -05:00
< style type = " text/css " >
2022-09-16 19:13:10 -04:00
. wp - activate - container { width : 90 % ; margin : 0 auto ; }
. wp - activate - container form { margin - top : 2 em ; }
#submit, #key { width: 100%; font-size: 24px; box-sizing: border-box; }
#language { margin-top: 0.5em; }
. wp - activate - container . error { background : #f66; color: #333; }
2018-04-30 03:05:21 -04:00
span . h3 { padding : 0 8 px ; font - size : 1.3 em ; font - weight : 600 ; }
2010-01-06 02:50:12 -05:00
</ style >
< ? php
}
add_action ( 'wp_head' , 'wpmu_activate_stylesheet' );
Robots: Introduce Robots API.
This changeset introduces a filter-based Robots API, providing central control over the `robots` meta tag.
* Introduces `wp_robots()` function which should be called anywhere a `robots` meta tag should be included.
* Introduces `wp_robots` filter which allows adding or modifying directives for the `robots` meta tag. The `wp_robots()` function is entirely filter-based, i.e. if no filter is added to `wp_robots`, no directives will be present, and therefore the entire `robots` meta tag will be omitted.
* Introduces the following `wp_robots` filter functions which replace similar existing functions that were manually rendering a `robots` meta tag:
* `wp_robots_noindex()` replaces `noindex()`, which has been deprecated.
* `wp_robots_no_robots()` replaces `wp_no_robots()`, which has been deprecated.
* `wp_robots_sensitive_page()` replaces `wp_sensitive_page_meta()`, which has been deprecated. Its rendering of the `referrer` meta tag has been moved to another new function `wp_strict_cross_origin_referrer()`.
Migration to the new functions is straightforward. For example, a call to `add_action( 'wp_head', 'wp_no_robots' )` should be replaced with `add_filter( 'wp_robots', 'wp_robots_no_robots' )`.
Plugins and themes that render their own `robots` meta tags are encouraged to switch to rely on the `wp_robots` filter in order to use the central management layer now provided by WordPress core.
Props adamsilverstein, flixos90, timothyblynjacobs, westonruter.
See #51511.
Built from https://develop.svn.wordpress.org/trunk@49992
git-svn-id: http://core.svn.wordpress.org/trunk@49693 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2021-01-20 20:37:00 -05:00
add_action ( 'wp_head' , 'wp_strict_cross_origin_referrer' );
add_filter ( 'wp_robots' , 'wp_robots_sensitive_page' );
2010-01-06 02:50:12 -05:00
2015-10-05 18:36:24 -04:00
get_header ( 'wp-activate' );
2020-07-28 13:20:06 -04:00
$blog_details = get_blog_details ();
2010-01-06 02:50:12 -05:00
?>
2015-09-14 22:09:24 -04:00
< div id = " signup-content " class = " widecolumn " >
2015-10-03 17:51:25 -04:00
< div class = " wp-activate-container " >
2018-12-12 19:23:24 -05:00
< ? php if ( ! $key ) { ?>
2010-01-15 17:11:12 -05:00
2017-11-30 18:11:00 -05:00
< h2 >< ? php _e ( 'Activation Key Required' ); ?> </h2>
2020-07-28 13:20:06 -04:00
< form name = " activateform " id = " activateform " method = " post " action = " <?php echo network_site_url( $blog_details->path . 'wp-activate.php' ); ?> " >
2010-01-06 02:50:12 -05:00
< p >
2017-11-30 18:11:00 -05:00
< label for = " key " >< ? php _e ( 'Activation Key:' ); ?> </label>
2022-09-16 19:13:10 -04:00
< br />< input type = " text " name = " key " id = " key " value = " " size = " 50 " autofocus = " autofocus " />
2010-01-06 02:50:12 -05:00
</ p >
2010-12-25 16:12:48 -05:00
< p class = " submit " >
2017-11-30 18:11:00 -05:00
< input id = " submit " type = " submit " name = " Submit " class = " submit " value = " <?php esc_attr_e( 'Activate' ); ?> " />
2010-12-25 16:12:48 -05:00
</ p >
2010-01-06 02:50:12 -05:00
</ form >
2010-01-15 17:11:12 -05:00
2018-08-15 02:22:26 -04:00
< ? php
2019-01-12 01:41:52 -05:00
} else {
2020-04-04 23:02:11 -04:00
if ( is_wp_error ( $result ) && in_array ( $result -> get_error_code (), $valid_error_codes , true ) ) {
2019-01-12 01:41:52 -05:00
$signup = $result -> get_error_data ();
?>
2018-12-12 19:23:24 -05:00
< h2 >< ? php _e ( 'Your account is now active!' ); ?> </h2>
< ? php
echo '<p class="lead-in">' ;
2020-01-08 19:55:05 -05:00
if ( '' === $signup -> domain . $signup -> path ) {
2018-12-12 19:23:24 -05:00
printf (
2019-09-02 20:41:05 -04:00
/* translators: 1: Login URL, 2: Username, 3: User email address, 4: Lost password URL. */
2018-12-12 19:23:24 -05:00
__ ( 'Your account has been activated. You may now <a href="%1$s">log in</a> to the site using your chosen username of “%2$s”. 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>.' ),
2020-07-28 13:20:06 -04:00
network_site_url ( $blog_details -> path . 'wp-login.php' , 'login' ),
2018-12-12 19:23:24 -05:00
$signup -> user_login ,
$signup -> user_email ,
wp_lostpassword_url ()
);
2018-08-15 02:22:26 -04:00
} else {
2018-12-12 19:23:24 -05:00
printf (
2019-09-02 20:41:05 -04:00
/* translators: 1: Site URL, 2: Username, 3: User email address, 4: Lost password URL. */
2018-12-12 19:23:24 -05:00
__ ( 'Your site at %1$s is active. You may now log in to your site using your chosen username of “%2$s”. 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>.' ),
2020-07-28 13:20:06 -04:00
sprintf ( '<a href="http://%1$s%2$s">%1$s%2$s</a>' , $signup -> domain , $blog_details -> path ),
2018-12-12 19:23:24 -05:00
$signup -> user_login ,
$signup -> user_email ,
wp_lostpassword_url ()
);
2018-08-15 02:22:26 -04:00
}
2018-12-12 19:23:24 -05:00
echo '</p>' ;
2020-01-08 19:55:05 -05:00
} elseif ( null === $result || is_wp_error ( $result ) ) {
2019-01-12 01:41:52 -05:00
?>
2018-12-12 19:23:24 -05:00
< h2 >< ? php _e ( 'An error occurred during the activation' ); ?> </h2>
< ? php if ( is_wp_error ( $result ) ) : ?>
< p >< ? php echo $result -> get_error_message (); ?> </p>
< ? php endif ; ?>
< ? php
2019-01-12 01:41:52 -05:00
} else {
$url = isset ( $result [ 'blog_id' ] ) ? get_home_url ( ( int ) $result [ 'blog_id' ] ) : '' ;
$user = get_userdata ( ( int ) $result [ 'user_id' ] );
?>
2018-08-15 02:22:26 -04:00
< h2 >< ? php _e ( 'Your account is now active!' ); ?> </h2>
2010-01-15 17:11:12 -05:00
2010-01-06 02:50:12 -05:00
< div id = " signup-welcome " >
2017-11-30 18:11:00 -05:00
< p >< span class = " h3 " >< ? php _e ( 'Username:' ); ?> </span> <?php echo $user->user_login; ?></p>
< p >< span class = " h3 " >< ? php _e ( 'Password:' ); ?> </span> <?php echo $result['password']; ?></p>
2010-01-06 02:50:12 -05:00
</ div >
2010-01-15 17:11:12 -05:00
2017-11-30 18:11:00 -05:00
< ? php
2020-01-08 19:55:05 -05:00
if ( $url && network_home_url ( '' , 'http' ) !== $url ) :
2016-01-27 22:35:27 -05:00
switch_to_blog ( ( int ) $result [ 'blog_id' ] );
$login_url = wp_login_url ();
restore_current_blog ();
2015-10-02 20:34:25 -04:00
?>
2017-11-30 18:11:00 -05:00
< p class = " view " >
< ? php
2019-09-02 20:41:05 -04:00
/* translators: 1: Site URL, 2: Login URL. */
2016-05-24 17:02:28 -04:00
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 ) );
2017-11-30 18:11:00 -05:00
?>
</ p >
< ? php else : ?>
< p class = " view " >
< ? php
2020-07-28 13:20:06 -04:00
printf (
/* translators: 1: Login URL, 2: Network home URL. */
__ ( '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 ( $blog_details -> path . 'wp-login.php' , 'login' ),
network_home_url ( $blog_details -> path )
);
2017-11-30 18:11:00 -05:00
?>
</ p >
2019-01-12 01:41:52 -05:00
< ? php
endif ;
}
2010-01-06 02:50:12 -05:00
}
2019-01-12 01:41:52 -05:00
?>
2015-10-03 17:51:25 -04:00
</ div >
2010-01-06 02:50:12 -05:00
</ div >
2017-11-30 18:11:00 -05:00
< ? php
get_footer ( 'wp-activate' );