[ Index ]

PHP Cross Reference of WordPress

title

Body

[close]

/ -> wp-activate.php (source)

   1  <?php
   2  /**
   3   * Confirms that the activation key that is sent in an email after a user signs
   4   * up for a new site matches the key for that user and then displays confirmation.
   5   *
   6   * @package WordPress
   7   */
   8  
   9  define( 'WP_INSTALLING', true );
  10  
  11  /** Sets up the WordPress Environment. */
  12  require( dirname( __FILE__ ) . '/wp-load.php' );
  13  
  14  require( dirname( __FILE__ ) . '/wp-blog-header.php' );
  15  
  16  if ( ! is_multisite() ) {
  17      wp_redirect( wp_registration_url() );
  18      die();
  19  }
  20  
  21  nocache_headers();
  22  
  23  if ( is_object( $wp_object_cache ) ) {
  24      $wp_object_cache->cache_enabled = false;
  25  }
  26  
  27  // Fix for page title
  28  $wp_query->is_404 = false;
  29  
  30  /**
  31   * Fires before the Site Activation page is loaded.
  32   *
  33   * @since 3.0.0
  34   */
  35  do_action( 'activate_header' );
  36  
  37  /**
  38   * Adds an action hook specific to this page.
  39   *
  40   * Fires on {@see 'wp_head'}.
  41   *
  42   * @since MU (3.0.0)
  43   */
  44  function do_activate_header() {
  45      /**
  46       * Fires before the Site Activation page is loaded.
  47       *
  48       * Fires on the {@see 'wp_head'} action.
  49       *
  50       * @since 3.0.0
  51       */
  52      do_action( 'activate_wp_head' );
  53  }
  54  add_action( 'wp_head', 'do_activate_header' );
  55  
  56  /**
  57   * Loads styles specific to this page.
  58   *
  59   * @since MU (3.0.0)
  60   */
  61  function wpmu_activate_stylesheet() {
  62      ?>
  63      <style type="text/css">
  64          form { margin-top: 2em; }
  65          #submit, #key { width: 90%; font-size: 24px; }
  66          #language { margin-top: .5em; }
  67          .error { background: #f66; }
  68          span.h3 { padding: 0 8px; font-size: 1.3em; font-weight: 600; }
  69      </style>
  70      <?php
  71  }
  72  add_action( 'wp_head', 'wpmu_activate_stylesheet' );
  73  
  74  get_header( 'wp-activate' );
  75  ?>
  76  
  77  <div id="signup-content" class="widecolumn">
  78      <div class="wp-activate-container">
  79      <?php if ( empty( $_GET['key'] ) && empty( $_POST['key'] ) ) { ?>
  80  
  81          <h2><?php _e( 'Activation Key Required' ); ?></h2>
  82          <form name="activateform" id="activateform" method="post" action="<?php echo network_site_url( 'wp-activate.php' ); ?>">
  83              <p>
  84                  <label for="key"><?php _e( 'Activation Key:' ); ?></label>
  85                  <br /><input type="text" name="key" id="key" value="" size="50" />
  86              </p>
  87              <p class="submit">
  88                  <input id="submit" type="submit" name="Submit" class="submit" value="<?php esc_attr_e( 'Activate' ); ?>" />
  89              </p>
  90          </form>
  91  
  92      <?php
  93  } else {
  94  
  95      $key    = ! empty( $_GET['key'] ) ? $_GET['key'] : $_POST['key'];
  96      $result = wpmu_activate_signup( $key );
  97      if ( is_wp_error( $result ) ) {
  98          if ( 'already_active' == $result->get_error_code() || 'blog_taken' == $result->get_error_code() ) {
  99              $signup = $result->get_error_data();
 100              ?>
 101              <h2><?php _e( 'Your account is now active!' ); ?></h2>
 102                  <?php
 103                  echo '<p class="lead-in">';
 104                  if ( $signup->domain . $signup->path == '' ) {
 105                      printf(
 106                          /* translators: 1: login URL, 2: username, 3: user email, 4: lost password URL */
 107                          __( '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>.' ),
 108                          network_site_url( 'wp-login.php', 'login' ),
 109                          $signup->user_login,
 110                          $signup->user_email,
 111                          wp_lostpassword_url()
 112                      );
 113                  } else {
 114                      printf(
 115                          /* translators: 1: site URL, 2: username, 3: user email, 4: lost password URL */
 116                          __( '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>.' ),
 117                          sprintf( '<a href="http://%1$s">%1$s</a>', $signup->domain ),
 118                          $signup->user_login,
 119                          $signup->user_email,
 120                          wp_lostpassword_url()
 121                      );
 122                  }
 123                  echo '</p>';
 124          } else {
 125              ?>
 126              <h2><?php _e( 'An error occurred during the activation' ); ?></h2>
 127                  <p><?php echo $result->get_error_message(); ?></p>
 128                  <?php
 129          }
 130      } else {
 131          $url  = isset( $result['blog_id'] ) ? get_home_url( (int) $result['blog_id'] ) : '';
 132          $user = get_userdata( (int) $result['user_id'] );
 133          ?>
 134          <h2><?php _e( 'Your account is now active!' ); ?></h2>
 135  
 136              <div id="signup-welcome">
 137              <p><span class="h3"><?php _e( 'Username:' ); ?></span> <?php echo $user->user_login; ?></p>
 138              <p><span class="h3"><?php _e( 'Password:' ); ?></span> <?php echo $result['password']; ?></p>
 139              </div>
 140  
 141              <?php
 142              if ( $url && $url != network_home_url( '', 'http' ) ) :
 143                  switch_to_blog( (int) $result['blog_id'] );
 144                  $login_url = wp_login_url();
 145                  restore_current_blog();
 146                  ?>
 147                  <p class="view">
 148                  <?php
 149                      /* translators: 1: site URL, 2: login URL */
 150                      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 ) );
 151                  ?>
 152                  </p>
 153              <?php else : ?>
 154                  <p class="view">
 155                  <?php
 156                      /* translators: 1: login URL, 2: network home URL */
 157                      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() );
 158                  ?>
 159                  </p>
 160              <?php
 161              endif;
 162      }
 163  }
 164      ?>
 165      </div>
 166  </div>
 167  <script type="text/javascript">
 168      var key_input = document.getElementById('key');
 169      key_input && key_input.focus();
 170  </script>
 171  <?php
 172  get_footer( 'wp-activate' );


Generated: Sat May 26 01:00:05 2018 Cross-referenced by PHPXref 0.7.1