2010-01-06 08:50:12 +01:00
< ? php
2012-08-06 02:59:34 +02:00
/**
* Confirms that the activation key that is sent in an email after a user signs
2016-01-28 04:35:27 +01:00
* up for a new site matches the key for that user and then displays confirmation .
2012-11-17 16:11:29 +01:00
*
2012-08-06 02:59:34 +02:00
* @ package WordPress
*/
2011-04-17 23:31:38 +02:00
define ( 'WP_INSTALLING' , true );
2010-01-06 08:50:12 +01:00
/** Sets up the WordPress Environment. */
2020-02-06 07:33:11 +01:00
require __DIR__ . '/wp-load.php' ;
2010-01-06 08:50:12 +01:00
2020-02-06 07:33:11 +01:00
require __DIR__ . '/wp-blog-header.php' ;
2010-01-26 22:39:06 +01:00
2017-12-01 00:11:00 +01:00
if ( ! is_multisite () ) {
2015-09-15 19:11:35 +02:00
wp_redirect ( wp_registration_url () );
2010-01-26 22:39:06 +01:00
die ();
}
2018-12-13 01:23:24 +01: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-13 02:26:24 +01: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-13 01:23:24 +01:00
$key = $_GET [ 'key' ];
} elseif ( ! empty ( $_POST [ 'key' ] ) ) {
$key = $_POST [ 'key' ];
}
if ( $key ) {
$redirect_url = remove_query_arg ( 'key' );
2020-01-09 01:55:05 +01:00
if ( remove_query_arg ( false ) !== $redirect_url ) {
2018-12-13 01:23:24 +01: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-09 01:55:05 +01:00
if ( null === $result && isset ( $_COOKIE [ $activate_cookie ] ) ) {
2018-12-13 01:23:24 +01: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-09 01:55:05 +01:00
if ( null === $result || ( is_wp_error ( $result ) && 'invalid_key' === $result -> get_error_code () ) ) {
2018-12-13 01:23:24 +01:00
status_header ( 404 );
} elseif ( is_wp_error ( $result ) ) {
$error_code = $result -> get_error_code ();
2020-04-05 05:02:11 +02:00
if ( ! in_array ( $error_code , $valid_error_codes , true ) ) {
2018-12-13 01:23:24 +01:00
status_header ( 400 );
}
}
2018-05-02 00:08:20 +02:00
nocache_headers ();
2017-12-01 00:11:00 +01:00
if ( is_object ( $wp_object_cache ) ) {
2010-01-06 08:50:12 +01:00
$wp_object_cache -> cache_enabled = false ;
2017-12-01 00:11:00 +01:00
}
2010-01-06 08:50:12 +01:00
2020-01-29 01:45:18 +01:00
// Fix for page title.
2013-10-04 16:12:11 +02:00
$wp_query -> is_404 = false ;
2013-09-21 07:21:09 +02:00
/**
* Fires before the Site Activation page is loaded .
*
2013-12-24 19:57:12 +01:00
* @ since 3.0 . 0
2013-09-21 07:21:09 +02:00
*/
2011-04-17 23:31:38 +02:00
do_action ( 'activate_header' );
2010-01-06 08:50:12 +01:00
2012-08-06 02:59:34 +02:00
/**
2016-05-23 19:07:28 +02:00
* Adds an action hook specific to this page .
*
* Fires on { @ see 'wp_head' } .
2012-11-17 16:11:29 +01:00
*
2017-08-01 22:44:43 +02:00
* @ since MU ( 3.0 . 0 )
2012-08-06 02:59:34 +02:00
*/
2010-02-13 01:33:47 +01:00
function do_activate_header () {
2016-05-23 19:07:28 +02:00
/**
2023-05-12 23:35:21 +02:00
* Fires within the `<head>` section of the Site Activation page .
2016-05-23 19:07:28 +02:00
*
* Fires on the { @ see 'wp_head' } action .
2017-12-01 00:11:00 +01:00
*
* @ since 3.0 . 0
*/
do_action ( 'activate_wp_head' );
2010-02-13 01:33:47 +01:00
}
add_action ( 'wp_head' , 'do_activate_header' );
2012-08-06 02:59:34 +02:00
/**
* Loads styles specific to this page .
2012-11-17 16:11:29 +01:00
*
2017-08-01 22:44:43 +02:00
* @ since MU ( 3.0 . 0 )
2012-08-06 02:59:34 +02:00
*/
2010-01-06 08:50:12 +01:00
function wpmu_activate_stylesheet () {
?>
2010-01-15 23:11:12 +01:00
< style type = " text/css " >
2022-09-17 01:13:10 +02: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 09:05:21 +02:00
span . h3 { padding : 0 8 px ; font - size : 1.3 em ; font - weight : 600 ; }
2010-01-06 08:50:12 +01: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-21 02:37:00 +01:00
add_action ( 'wp_head' , 'wp_strict_cross_origin_referrer' );
add_filter ( 'wp_robots' , 'wp_robots_sensitive_page' );
2010-01-06 08:50:12 +01:00
2015-10-06 00:36:24 +02:00
get_header ( 'wp-activate' );
2020-07-28 19:20:06 +02:00
2023-03-10 16:49:18 +01:00
$blog_details = get_site ();
2010-01-06 08:50:12 +01:00
?>
2015-09-15 04:09:24 +02:00
< div id = " signup-content " class = " widecolumn " >
2015-10-03 23:51:25 +02:00
< div class = " wp-activate-container " >
2018-12-13 01:23:24 +01:00
< ? php if ( ! $key ) { ?>
2010-01-15 23:11:12 +01:00
2017-12-01 00:11:00 +01:00
< h2 >< ? php _e ( 'Activation Key Required' ); ?> </h2>
2023-12-04 23:07:27 +01:00
< form name = " activateform " id = " activateform " method = " post " action = " <?php echo esc_url( network_site_url( $blog_details->path . 'wp-activate.php' ) ); ?> " >
2010-01-06 08:50:12 +01:00
< p >
2017-12-01 00:11:00 +01:00
< label for = " key " >< ? php _e ( 'Activation Key:' ); ?> </label>
2022-09-17 01:13:10 +02:00
< br />< input type = " text " name = " key " id = " key " value = " " size = " 50 " autofocus = " autofocus " />
2010-01-06 08:50:12 +01:00
</ p >
2010-12-25 22:12:48 +01:00
< p class = " submit " >
2017-12-01 00:11:00 +01:00
< input id = " submit " type = " submit " name = " Submit " class = " submit " value = " <?php esc_attr_e( 'Activate' ); ?> " />
2010-12-25 22:12:48 +01:00
</ p >
2010-01-06 08:50:12 +01:00
</ form >
2010-01-15 23:11:12 +01:00
2018-08-15 08:22:26 +02:00
< ? php
2019-01-12 07:41:52 +01:00
} else {
2020-04-05 05:02:11 +02:00
if ( is_wp_error ( $result ) && in_array ( $result -> get_error_code (), $valid_error_codes , true ) ) {
2019-01-12 07:41:52 +01:00
$signup = $result -> get_error_data ();
?>
2018-12-13 01:23:24 +01:00
< h2 >< ? php _e ( 'Your account is now active!' ); ?> </h2>
< ? php
echo '<p class="lead-in">' ;
2020-01-09 01:55:05 +01:00
if ( '' === $signup -> domain . $signup -> path ) {
2018-12-13 01:23:24 +01:00
printf (
2019-09-03 02:41:05 +02:00
/* translators: 1: Login URL, 2: Username, 3: User email address, 4: Lost password URL. */
2018-12-13 01:23:24 +01: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 19:20:06 +02:00
network_site_url ( $blog_details -> path . 'wp-login.php' , 'login' ),
2018-12-13 01:23:24 +01:00
$signup -> user_login ,
$signup -> user_email ,
wp_lostpassword_url ()
);
2018-08-15 08:22:26 +02:00
} else {
2018-12-13 01:23:24 +01:00
printf (
2019-09-03 02:41:05 +02:00
/* translators: 1: Site URL, 2: Username, 3: User email address, 4: Lost password URL. */
2018-12-13 01:23:24 +01: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 19:20:06 +02:00
sprintf ( '<a href="http://%1$s%2$s">%1$s%2$s</a>' , $signup -> domain , $blog_details -> path ),
2018-12-13 01:23:24 +01:00
$signup -> user_login ,
$signup -> user_email ,
wp_lostpassword_url ()
);
2018-08-15 08:22:26 +02:00
}
2018-12-13 01:23:24 +01:00
echo '</p>' ;
2020-01-09 01:55:05 +01:00
} elseif ( null === $result || is_wp_error ( $result ) ) {
2019-01-12 07:41:52 +01:00
?>
2018-12-13 01:23:24 +01: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 07:41:52 +01:00
} else {
$url = isset ( $result [ 'blog_id' ] ) ? get_home_url ( ( int ) $result [ 'blog_id' ] ) : '' ;
$user = get_userdata ( ( int ) $result [ 'user_id' ] );
?>
2018-08-15 08:22:26 +02:00
< h2 >< ? php _e ( 'Your account is now active!' ); ?> </h2>
2010-01-15 23:11:12 +01:00
2010-01-06 08:50:12 +01:00
< div id = " signup-welcome " >
2017-12-01 00:11:00 +01: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 08:50:12 +01:00
</ div >
2010-01-15 23:11:12 +01:00
2017-12-01 00:11:00 +01:00
< ? php
2020-01-09 01:55:05 +01:00
if ( $url && network_home_url ( '' , 'http' ) !== $url ) :
2016-01-28 04:35:27 +01:00
switch_to_blog ( ( int ) $result [ 'blog_id' ] );
$login_url = wp_login_url ();
restore_current_blog ();
2015-10-03 02:34:25 +02:00
?>
2017-12-01 00:11:00 +01:00
< p class = " view " >
< ? php
2019-09-03 02:41:05 +02:00
/* translators: 1: Site URL, 2: Login URL. */
2016-05-24 23:02:28 +02: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-12-01 00:11:00 +01:00
?>
</ p >
< ? php else : ?>
< p class = " view " >
< ? php
2020-07-28 19:20:06 +02: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-12-01 00:11:00 +01:00
?>
</ p >
2019-01-12 07:41:52 +01:00
< ? php
endif ;
}
2010-01-06 08:50:12 +01:00
}
2019-01-12 07:41:52 +01:00
?>
2015-10-03 23:51:25 +02:00
</ div >
2010-01-06 08:50:12 +01:00
</ div >
2017-12-01 00:11:00 +01:00
< ? php
get_footer ( 'wp-activate' );