Parsed: 127490

<?php


/** Sets up the WordPress Environment. */
require __DIR__ . '/wp-load.php';

add_filter( 'wp_robots', 'wp_robots_no_robots' );

require __DIR__ . '/wp-blog-header.php';

nocache_headers();

if ( is_array( get_site_option( 'illegal_names' ) ) && isset( $_GET['new'] ) && in_array( $_GET['new'], get_site_option( 'illegal_names' ), true ) ) {
  wp_redirect( network_home_url() );
  die();
}

/* function do_signup_header() – Prints signup_header via wp_head */
add_action( 'wp_head', 'do_signup_header' )  <;

if ( ! is_multisite() ) {
  wp_redirect( wp_registration_url() );
  die();
}

if ( ! is_main_site() ) {
  wp_redirect( network_site_url( 'wp-signup.php' ) );
  die();
}

// Fix for page title.
$wp_query->is_404 = false;


/**
 * Fires before the Site Sign-up page is loaded.
 *
 * @since 4.4.0
 */
do_action( 'before_signup_header' );

/* function wpmu_signup_stylesheet() – Prints styles for front-end Multisite signup pages */
add_action( 'wp_head', 'wpmu_signup_stylesheet' )  <;

get_header( 'wp-signup' );


/**
 * Fires before the site Sign-up form.
 *
 * @since 3.0.0
 */
do_action( 'before_signup_form' );
?>
<div id="signup-content" class="widecolumn">
<div class="mu_register wp-signup-container" role="main">
<?php
/* function show_blog_form() – Generates and displays the Sign-up and Create Site forms. */

/* function validate_blog_form() – Validate the new site signup */

/* function show_user_form() – Displays the fields for the new user account registration form. */

/* function validate_user_form() – Validate user signup name and email */

/* function signup_another_blog() – Shows a form for returning users to sign up for another site. */

/* function validate_another_blog_signup() – Validate a new site signup for an existing user. */

/* function confirm_another_blog_signup() – Confirm a new site signup. */

/* function signup_user() – Setup the new user signup process */

/* function validate_user_signup() – Validate the new user signup */

/* function confirm_user_signup() – New user signup confirmation */

/* function signup_blog() – Shows a form for a user or visitor to sign up for a new site. */

/* function validate_blog_signup() – Validate new site signup */

/* function confirm_blog_signup() – Shows a message confirming that the new site has been registered and is awaiting activation. */

/* function signup_get_available_languages() – Retrieves languages available during the site/user sign-up process. */

// Main.
$active_signup = get_site_option( 'registration', 'none' );


/**
 * Filters the type of site sign-up.
 *
 * @since 3.0.0
 *
 * @param string $active_signup String that returns registration type. The value can be
 *                              'all', 'none', 'blog', or 'user'.
 */
$active_signup = apply_filters( 'wpmu_active_signup', $active_signup );

if ( current_user_can( 'manage_network' ) ) {
  echo '<div class="mu_alert">';
  _e( 'Greetings Network Administrator!' );
  echo ' ';

  switch ( $active_signup ) {
    case 'none':
      _e( 'The network currently disallows registrations.' );
      break;
    case 'blog':
      _e( 'The network currently allows site registrations.' );
      break;
    case 'user':
      _e( 'The network currently allows user registrations.' );
      break;
    default:
      _e( 'The network currently allows both site and user registrations.' );
      break;
  }

  echo ' ';

  /* translators: %s: URL to Network Settings screen. */
  printf( __( 'To change or disable registration go to your <a href="%s">Options page</a>.' ), esc_url( network_admin_url( 'settings.php' ) ) );
  echo '</div>';
}

$newblogname = isset( $_GET['new'] ) ? strtolower( preg_replace( '/^-|-$|[^-a-zA-Z0-9]/', '', $_GET['new'] ) ) : null;

$current_user = wp_get_current_user();
if ( 'none' === $active_signup ) {
  _e( 'Registration has been disabled.' );
} elseif ( 'blog' === $active_signup && ! is_user_logged_in() ) {
  $login_url = wp_login_url( network_site_url( 'wp-signup.php' ) );
  /* translators: %s: Login URL. */
  printf( __( 'You must first <a href="%s">log in</a>, and then you can create a new site.' ), $login_url );
} else {
  $stage = isset( $_POST['stage'] ) ? $_POST['stage'] : 'default';
  switch ( $stage ) {
    case 'validate-user-signup':
      if ( 'all' === $active_signup
        || ( 'blog' === $_POST['signup_for'] && 'blog' === $active_signup )
        || ( 'user' === $_POST['signup_for'] && 'user' === $active_signup )
      ) {
        validate_user_signup();
      } else {
        _e( 'User registration has been disabled.' );
      }
      break;
    case 'validate-blog-signup':
      if ( 'all' === $active_signup || 'blog' === $active_signup ) {
        validate_blog_signup();
      } else {
        _e( 'Site registration has been disabled.' );
      }
      break;
    case 'gimmeanotherblog':
      validate_another_blog_signup();
      break;
    case 'default':
    default:
      $user_email = isset( $_POST['user_email'] ) ? $_POST['user_email'] : '';
      
/**
 * Fires when the site sign-up form is sent.
 *
 * @since 3.0.0
 */
      do_action( 'preprocess_signup_form' );
      if ( is_user_logged_in() && ( 'all' === $active_signup || 'blog' === $active_signup ) ) {
        signup_another_blog( $newblogname );
      } elseif ( ! is_user_logged_in() && ( 'all' === $active_signup || 'user' === $active_signup ) ) {
        signup_user( $newblogname, $user_email );
      } elseif ( ! is_user_logged_in() && ( 'blog' === $active_signup ) ) {
        _e( 'Sorry, new registrations are not allowed at this time.' );
      } else {
        _e( 'You are logged in already. No need to register again!' );
      }

      if ( $newblogname ) {
        $newblog = get_blogaddress_by_name( $newblogname );

        if ( 'blog' === $active_signup || 'all' === $active_signup ) {
          printf(
            /* translators: %s: Site address. */
            '<p>' . __( 'The site you were looking for, %s, does not exist, but you can create it now!' ) . '</p>',
            '<strong>' . $newblog . '</strong>'
          );
        } else {
          printf(
            /* translators: %s: Site address. */
            '<p>' . __( 'The site you were looking for, %s, does not exist.' ) . '</p>',
            '<strong>' . $newblog . '</strong>'
          );
        }
      }
      break;
  }
}
?>
</div>
</div>
<?php

/**
 * Fires after the sign-up forms, before wp_footer.
 *
 * @since 3.0.0
 */
do_action( 'after_signup_form' );
?>

<?php
get_footer( 'wp-signup' );