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


Generated: Sat Dec 16 01:00:03 2017 Cross-referenced by PHPXref 0.7.1