Make WordPress Core

Ticket #28351: 28351-3.diff

File 28351-3.diff, 49.2 KB (added by igmoweb, 10 years ago)
  • src/wp-signup.php

     
    5252                .mu_register form { margin-top: 2em; }
    5353                .mu_register .error { font-weight:700; padding:10px; color:#333333; background:#FFEBE8; border:1px solid #CC0000; }
    5454                .mu_register input[type="submit"],
    55                         .mu_register #blog_title,
    56                         .mu_register #user_email,
    57                         .mu_register #blogname,
    58                         .mu_register #user_name { width:100%; font-size: 24px; margin:5px 0; }
     55                .mu_register #blog_title,
     56                .mu_register #user_email,
     57                .mu_register #blogname,
     58                .mu_register #user_name { width:100%; font-size: 24px; margin:5px 0; }
    5959                .mu_register .prefix_address,
    60                         .mu_register .suffix_address {font-size: 18px;display:inline; }
     60                .mu_register .suffix_address {font-size: 18px;display:inline; }
    6161                .mu_register label { font-weight:700; font-size:15px; display:block; margin:10px 0; }
    6262                .mu_register label.checkbox { display:inline; }
    6363                .mu_register .mu_alert { font-weight:700; padding:10px; color:#333333; background:#ffffe0; border:1px solid #e6db55; }
     
    7676do_action( 'before_signup_form' );
    7777?>
    7878<div id="content" class="widecolumn">
    79 <div class="mu_register">
    80 <?php
    81 /**
    82  * Generates and displays the Signup and Create Site forms
    83  *
    84  * @since MU
    85  *
    86  * @param string $blogname The new site name
    87  * @param string $blog_title The new site title
    88  * @param array $errors
    89  */
    90 function show_blog_form( $blogname = '', $blog_title = '', $errors = '' ) {
    91         $current_site = get_current_site();
    92         // Blog name
    93         if ( !is_subdomain_install() )
    94                 echo '<label for="blogname">' . __('Site Name:') . '</label>';
    95         else
    96                 echo '<label for="blogname">' . __('Site Domain:') . '</label>';
     79        <div class="mu_register">
     80                <?php
     81                /**
     82                * Generates and displays the Signup and Create Site forms
     83                *
     84                * @since MU
     85                *
     86                * @param string $blogname The new site name
     87                * @param string $blog_title The new site title
     88                * @param array $errors
     89                */
     90                function show_blog_form( $blogname = '', $blog_title = '', $errors = '' ) {
     91                        $current_site = get_current_site();
     92                        // Blog name
     93                        if ( !is_subdomain_install() )
     94                                echo '<label for="blogname">' . __('Site Name:') . '</label>';
     95                        else
     96                                echo '<label for="blogname">' . __('Site Domain:') . '</label>';
    9797
    98         if ( $errmsg = $errors->get_error_message('blogname') ) { ?>
    99                 <p class="error"><?php echo $errmsg ?></p>
    100         <?php }
     98                        if ( $errmsg = $errors->get_error_message('blogname') ) { ?>
     99                                <p class="error"><?php echo $errmsg ?></p>
     100                        <?php }
    101101
    102         if ( !is_subdomain_install() )
    103                 echo '<span class="prefix_address">' . $current_site->domain . $current_site->path . '</span><input name="blogname" type="text" id="blogname" value="'. esc_attr($blogname) .'" maxlength="60" /><br />';
    104         else
    105                 echo '<input name="blogname" type="text" id="blogname" value="'.esc_attr($blogname).'" maxlength="60" /><span class="suffix_address">.' . ( $site_domain = preg_replace( '|^www\.|', '', $current_site->domain ) ) . '</span><br />';
     102                        if ( !is_subdomain_install() )
     103                                echo '<span class="prefix_address">' . $current_site->domain . $current_site->path . '</span><input name="blogname" type="text" id="blogname" value="'. esc_attr($blogname) .'" maxlength="60" /><br />';
     104                        else
     105                                echo '<input name="blogname" type="text" id="blogname" value="'.esc_attr($blogname).'" maxlength="60" /><span class="suffix_address">.' . ( $site_domain = preg_replace( '|^www\.|', '', $current_site->domain ) ) . '</span><br />';
    106106
    107         if ( !is_user_logged_in() ) {
    108                 if ( !is_subdomain_install() )
    109                         $site = $current_site->domain . $current_site->path . __( 'sitename' );
    110                 else
    111                         $site = __( 'domain' ) . '.' . $site_domain . $current_site->path;
    112                 echo '<p>(<strong>' . sprintf( __('Your address will be %s.'), $site ) . '</strong>) ' . __( 'Must be at least 4 characters, letters and numbers only. It cannot be changed, so choose carefully!' ) . '</p>';
    113         }
     107                        if ( !is_user_logged_in() ) {
     108                                if ( !is_subdomain_install() )
     109                                        $site = $current_site->domain . $current_site->path . __( 'sitename' );
     110                                else
     111                                        $site = __( 'domain' ) . '.' . $site_domain . $current_site->path;
     112                                echo '<p>(<strong>' . sprintf( __('Your address will be %s.'), $site ) . '</strong>) ' . apply_filters( 'signup_blogname_text', __( 'Must be at least 4 characters, letters and numbers only. It cannot be changed, so choose carefully!' ) ) . '</p>';
     113                        }
    114114
    115         // Blog Title
    116         ?>
    117         <label for="blog_title"><?php _e('Site Title:') ?></label>
    118         <?php if ( $errmsg = $errors->get_error_message('blog_title') ) { ?>
    119                 <p class="error"><?php echo $errmsg ?></p>
    120         <?php }
    121         echo '<input name="blog_title" type="text" id="blog_title" value="'.esc_attr($blog_title).'" />';
    122         ?>
     115                        // Blog Title
     116                        ?>
     117                        <label for="blog_title"><?php _e('Site Title:') ?></label>
     118                        <?php if ( $errmsg = $errors->get_error_message('blog_title') ) { ?>
     119                                <p class="error"><?php echo $errmsg ?></p>
     120                        <?php }
     121                        echo '<input name="blog_title" type="text" id="blog_title" value="'.esc_attr($blog_title).'" />';
     122                        ?>
    123123
    124         <div id="privacy">
    125         <p class="privacy-intro">
    126             <label for="blog_public_on"><?php _e('Privacy:') ?></label>
    127             <?php _e( 'Allow search engines to index this site.' ); ?>
    128             <br style="clear:both" />
    129             <label class="checkbox" for="blog_public_on">
    130                 <input type="radio" id="blog_public_on" name="blog_public" value="1" <?php if ( !isset( $_POST['blog_public'] ) || $_POST['blog_public'] == '1' ) { ?>checked="checked"<?php } ?> />
    131                 <strong><?php _e( 'Yes' ); ?></strong>
    132             </label>
    133             <label class="checkbox" for="blog_public_off">
    134                 <input type="radio" id="blog_public_off" name="blog_public" value="0" <?php if ( isset( $_POST['blog_public'] ) && $_POST['blog_public'] == '0' ) { ?>checked="checked"<?php } ?> />
    135                 <strong><?php _e( 'No' ); ?></strong>
    136             </label>
    137         </p>
    138         </div>
     124                        <div id="privacy">
     125                                <p class="privacy-intro">
     126                                        <label for="blog_public_on"><?php _e('Privacy:') ?></label>
     127                                        <?php _e( 'Allow search engines to index this site.' ); ?>
     128                                        <br style="clear:both" />
     129                                        <label class="checkbox" for="blog_public_on">
     130                                                <input type="radio" id="blog_public_on" name="blog_public" value="1" <?php if ( !isset( $_POST['blog_public'] ) || $_POST['blog_public'] == '1' ) { ?>checked="checked"<?php } ?> />
     131                                                <strong><?php _e( 'Yes' ); ?></strong>
     132                                        </label>
     133                                        <label class="checkbox" for="blog_public_off">
     134                                                <input type="radio" id="blog_public_off" name="blog_public" value="0" <?php if ( isset( $_POST['blog_public'] ) && $_POST['blog_public'] == '0' ) { ?>checked="checked"<?php } ?> />
     135                                                <strong><?php _e( 'No' ); ?></strong>
     136                                        </label>
     137                                </p>
     138                        </div>
    139139
    140         <?php
    141         /**
    142         * Fires after the site sign-up form.
    143         *
    144         * @since 3.0.0
    145         *
    146         * @param array $errors An array possibly containing 'blogname' or 'blog_title' errors.
    147         */
    148         do_action( 'signup_blogform', $errors );
    149 }
     140                        <?php
     141                        /**
     142                        * Fires after the site sign-up form.
     143                        *
     144                        * @since 3.0.0
     145                        *
     146                        * @param array $errors An array possibly containing 'blogname' or 'blog_title' errors.
     147                        */
     148                        do_action( 'signup_blogform', $errors );
     149                }
    150150
    151 /**
    152  * Validate the new site signup
    153  *
    154  * @since MU
    155  *
    156  * @return array Contains the new site data and error messages.
    157  */
    158 function validate_blog_form() {
    159         $user = '';
    160         if ( is_user_logged_in() )
    161                 $user = wp_get_current_user();
     151                /**
     152                * Validate the new site signup
     153                *
     154                * @since MU
     155                *
     156                * @return array Contains the new site data and error messages.
     157                */
     158                function validate_blog_form() {
     159                        $user = '';
     160                        if ( is_user_logged_in() )
     161                                $user = wp_get_current_user();
    162162
    163         return wpmu_validate_blog_signup($_POST['blogname'], $_POST['blog_title'], $user);
    164 }
     163                        return wpmu_validate_blog_signup($_POST['blogname'], $_POST['blog_title'], $user);
     164                }
    165165
    166 /**
    167  * Display user registration form
    168  *
    169  * @since MU
    170  *
    171  * @param string $user_name The entered username
    172  * @param string $user_email The entered email address
    173  * @param array $errors
    174  */
    175 function show_user_form($user_name = '', $user_email = '', $errors = '') {
    176         // User name
    177         echo '<label for="user_name">' . __('Username:') . '</label>';
    178         if ( $errmsg = $errors->get_error_message('user_name') ) {
    179                 echo '<p class="error">'.$errmsg.'</p>';
    180         }
    181         echo '<input name="user_name" type="text" id="user_name" value="'. esc_attr($user_name) .'" maxlength="60" /><br />';
    182         _e( '(Must be at least 4 characters, letters and numbers only.)' );
    183         ?>
     166                /**
     167                * Display user registration form
     168                *
     169                * @since MU
     170                *
     171                * @param string $user_name The entered username
     172                * @param string $user_email The entered email address
     173                * @param array $errors
     174                */
     175                function show_user_form($user_name = '', $user_email = '', $errors = '') {
     176                        // User name
     177                        echo '<label for="user_name">' . __('Username:') . '</label>';
     178                        if ( $errmsg = $errors->get_error_message('user_name') ) {
     179                                echo '<p class="error">'.$errmsg.'</p>';
     180                        }
     181                        echo '<input name="user_name" type="text" id="user_name" value="'. esc_attr($user_name) .'" maxlength="60" /><br />';
     182                        echo apply_filters( 'signup_username_text', __( '(Must be at least 4 characters, letters and numbers only.)' ) );
     183                        ?>
    184184
    185         <label for="user_email"><?php _e( 'Email&nbsp;Address:' ) ?></label>
    186         <?php if ( $errmsg = $errors->get_error_message('user_email') ) { ?>
    187                 <p class="error"><?php echo $errmsg ?></p>
    188         <?php } ?>
    189         <input name="user_email" type="email" id="user_email" value="<?php  echo esc_attr($user_email) ?>" maxlength="200" /><br /><?php _e('We send your registration email to this address. (Double-check your email address before continuing.)') ?>
    190         <?php
    191         if ( $errmsg = $errors->get_error_message('generic') ) {
    192                 echo '<p class="error">' . $errmsg . '</p>';
    193         }
    194         /**
    195         * Fires at the end of the user registration form on the site sign-up form.
    196         *
    197         * @since 3.0.0
    198         *
    199         * @param array $errors An array possibly containing 'user_name' or 'user_email' errors.
    200         */
    201         do_action( 'signup_extra_fields', $errors );
    202 }
     185                        <label for="user_email"><?php _e( 'Email&nbsp;Address:' ) ?></label>
     186                        <?php if ( $errmsg = $errors->get_error_message('user_email') ) { ?>
     187                                <p class="error"><?php echo $errmsg ?></p>
     188                        <?php } ?>
     189                        <input name="user_email" type="email" id="user_email" value="<?php  echo esc_attr($user_email) ?>" maxlength="200" /><br /><?php apply_filters( 'signup_email_text', __('We send your registration email to this address. (Double-check your email address before continuing.)') ) ?>
     190                        <?php
     191                        if ( $errmsg = $errors->get_error_message('generic') ) {
     192                                echo '<p class="error">' . $errmsg . '</p>';
     193                        }
     194                        /**
     195                        * Fires at the end of the user registration form on the site sign-up form.
     196                        *
     197                        * @since 3.0.0
     198                        *
     199                        * @param array $errors An array possibly containing 'user_name' or 'user_email' errors.
     200                        */
     201                        do_action( 'signup_extra_fields', $errors );
     202                }
    203203
    204 /**
    205  * Validate user signup name and email
    206  *
    207  * @since MU
    208  *
    209  * @return array Contains username, email, and error messages.
    210  */
    211 function validate_user_form() {
    212         return wpmu_validate_user_signup($_POST['user_name'], $_POST['user_email']);
    213 }
     204                /**
     205                * Validate user signup name and email
     206                *
     207                * @since MU
     208                *
     209                * @return array Contains username, email, and error messages.
     210                */
     211                function validate_user_form() {
     212                        return wpmu_validate_user_signup($_POST['user_name'], $_POST['user_email']);
     213                }
    214214
    215 /**
    216  * Allow returning users to sign up for another site
    217  *
    218  * @since MU
    219  *
    220  * @param string $blogname The new site name
    221  * @param string $blog_title The new blog title
    222  * @param array $errors
    223  */
    224 function signup_another_blog( $blogname = '', $blog_title = '', $errors = '' ) {
    225         $current_user = wp_get_current_user();
     215                /**
     216                * Allow returning users to sign up for another site
     217                *
     218                * @since MU
     219                *
     220                * @param string $blogname The new site name
     221                * @param string $blog_title The new blog title
     222                * @param array $errors
     223                */
     224                function signup_another_blog( $blogname = '', $blog_title = '', $errors = '' ) {
     225                        $current_user = wp_get_current_user();
    226226
    227         if ( ! is_wp_error($errors) ) {
    228                 $errors = new WP_Error();
    229         }
     227                        if ( ! is_wp_error($errors) ) {
     228                                $errors = new WP_Error();
     229                        }
    230230
    231         $signup_defaults = array(
    232                 'blogname'   => $blogname,
    233                 'blog_title' => $blog_title,
    234                 'errors'     => $errors
    235         );
     231                        $signup_defaults = array(
     232                                'blogname'   => $blogname,
     233                                'blog_title' => $blog_title,
     234                                'errors'     => $errors
     235                        );
    236236
    237         /**
    238         * Filter the default site sign-up variables.
    239         *
    240         * @since 3.0.0
    241         *
    242         * @param array $signup_defaults {
    243         *     An array of default site sign-up variables.
    244         *
    245         *     @type string $blogname   The site blogname.
    246         *     @type string $blog_title The site title.
    247         *     @type array  $errors     An array possibly containing 'blogname' or 'blog_title' errors.
    248         * }
    249         */
    250         $filtered_results = apply_filters( 'signup_another_blog_init', $signup_defaults );
     237                        /**
     238                        * Filter the default site sign-up variables.
     239                        *
     240                        * @since 3.0.0
     241                        *
     242                        * @param array $signup_defaults {
     243                        *     An array of default site sign-up variables.
     244                        *
     245                        *     @type string $blogname   The site blogname.
     246                        *     @type string $blog_title The site title.
     247                        *     @type array  $errors     An array possibly containing 'blogname' or 'blog_title' errors.
     248                        * }
     249                        */
     250                        $filtered_results = apply_filters( 'signup_another_blog_init', $signup_defaults );
    251251
    252         $blogname = $filtered_results['blogname'];
    253         $blog_title = $filtered_results['blog_title'];
    254         $errors = $filtered_results['errors'];
     252                        $blogname = $filtered_results['blogname'];
     253                        $blog_title = $filtered_results['blog_title'];
     254                        $errors = $filtered_results['errors'];
    255255
    256         echo '<h2>' . sprintf( __( 'Get <em>another</em> %s site in seconds' ), get_current_site()->site_name ) . '</h2>';
     256                        echo '<h2>' . sprintf( __( 'Get <em>another</em> %s site in seconds' ), get_current_site()->site_name ) . '</h2>';
    257257
    258         if ( $errors->get_error_code() ) {
    259                 echo '<p>' . __( 'There was a problem, please correct the form below and try again.' ) . '</p>';
    260         }
    261         ?>
    262         <p><?php printf( __( 'Welcome back, %s. By filling out the form below, you can <strong>add another site to your account</strong>. There is no limit to the number of sites you can have, so create to your heart&#8217;s content, but write responsibly!' ), $current_user->display_name ) ?></p>
     258                        if ( $errors->get_error_code() ) {
     259                                echo '<p>' . __( 'There was a problem, please correct the form below and try again.' ) . '</p>';
     260                        }
     261                        ?>
     262                        <p><?php printf( __( 'Welcome back, %s. By filling out the form below, you can <strong>add another site to your account</strong>. There is no limit to the number of sites you can have, so create to your heart&#8217;s content, but write responsibly!' ), $current_user->display_name ) ?></p>
    263263
    264         <?php
    265         $blogs = get_blogs_of_user($current_user->ID);
    266         if ( !empty($blogs) ) { ?>
     264                        <?php
     265                        $blogs = get_blogs_of_user($current_user->ID);
     266                        if ( !empty($blogs) ) { ?>
    267267
    268                         <p><?php _e( 'Sites you are already a member of:' ) ?></p>
    269                         <ul>
    270                                 <?php foreach ( $blogs as $blog ) {
    271                                         $home_url = get_home_url( $blog->userblog_id );
    272                                         echo '<li><a href="' . esc_url( $home_url ) . '">' . $home_url . '</a></li>';
    273                                 } ?>
    274                         </ul>
    275         <?php } ?>
     268                                <p><?php _e( 'Sites you are already a member of:' ) ?></p>
     269                                <ul>
     270                                        <?php foreach ( $blogs as $blog ) {
     271                                                $home_url = get_home_url( $blog->userblog_id );
     272                                                echo '<li><a href="' . esc_url( $home_url ) . '">' . $home_url . '</a></li>';
     273                                        } ?>
     274                                </ul>
     275                        <?php } ?>
    276276
    277         <p><?php _e( 'If you&#8217;re not going to use a great site domain, leave it for a new user. Now have at it!' ) ?></p>
    278         <form id="setupform" method="post" action="wp-signup.php">
    279                 <input type="hidden" name="stage" value="gimmeanotherblog" />
    280                 <?php
     277                        <p><?php _e( 'If you&#8217;re not going to use a great site domain, leave it for a new user. Now have at it!' ) ?></p>
     278                        <form id="setupform" method="post" action="wp-signup.php">
     279                                <input type="hidden" name="stage" value="gimmeanotherblog" />
     280                                <?php
     281                                /**
     282                                 * Hidden sign-up form fields output when creating another site or user.
     283                                 *
     284                                 * @since MU
     285                                 *
     286                                 * @param string $context A string describing the steps of the sign-up process. The value can be
     287                                 *                        'create-another-site', 'validate-user', or 'validate-site'.
     288                                 */
     289                                do_action( 'signup_hidden_fields', 'create-another-site' );
     290                                ?>
     291                                <?php show_blog_form($blogname, $blog_title, $errors); ?>
     292                                <p class="submit"><input type="submit" name="submit" class="submit" value="<?php esc_attr_e( 'Create Site' ) ?>" /></p>
     293                        </form>
     294                        <?php
     295                }
     296
    281297                /**
    282                  * Hidden sign-up form fields output when creating another site or user.
     298                 * Validate a new blog signup
    283299                 *
    284300                 * @since MU
    285301                 *
    286                  * @param string $context A string describing the steps of the sign-up process. The value can be
    287                  *                        'create-another-site', 'validate-user', or 'validate-site'.
     302                 * @return null|bool True if blog signup was validated, false if error.
     303                 *                   The function halts all execution if the user is not logged in.
    288304                 */
    289                 do_action( 'signup_hidden_fields', 'create-another-site' );
    290                 ?>
    291                 <?php show_blog_form($blogname, $blog_title, $errors); ?>
    292                 <p class="submit"><input type="submit" name="submit" class="submit" value="<?php esc_attr_e( 'Create Site' ) ?>" /></p>
    293         </form>
    294         <?php
    295 }
     305                function validate_another_blog_signup() {
     306                        global $wpdb, $blogname, $blog_title, $errors, $domain, $path;
     307                        $current_user = wp_get_current_user();
     308                        if ( ! is_user_logged_in() ) {
     309                                die();
     310                        }
    296311
    297 /**
    298  * Validate a new blog signup
    299  *
    300  * @since MU
    301  *
    302  * @return null|bool True if blog signup was validated, false if error.
    303  *                   The function halts all execution if the user is not logged in.
    304  */
    305 function validate_another_blog_signup() {
    306         global $wpdb, $blogname, $blog_title, $errors, $domain, $path;
    307         $current_user = wp_get_current_user();
    308         if ( ! is_user_logged_in() ) {
    309                 die();
    310         }
     312                        $result = validate_blog_form();
    311313
    312         $result = validate_blog_form();
     314                        // Extracted values set/overwrite globals.
     315                        $domain = $result['domain'];
     316                        $path = $result['path'];
     317                        $blogname = $result['blogname'];
     318                        $blog_title = $result['blog_title'];
     319                        $errors = $result['errors'];
    313320
    314         // Extracted values set/overwrite globals.
    315         $domain = $result['domain'];
    316         $path = $result['path'];
    317         $blogname = $result['blogname'];
    318         $blog_title = $result['blog_title'];
    319         $errors = $result['errors'];
     321                        if ( $errors->get_error_code() ) {
     322                                signup_another_blog($blogname, $blog_title, $errors);
     323                                return false;
     324                        }
    320325
    321         if ( $errors->get_error_code() ) {
    322                 signup_another_blog($blogname, $blog_title, $errors);
    323                 return false;
    324         }
     326                        $public = (int) $_POST['blog_public'];
    325327
    326         $public = (int) $_POST['blog_public'];
     328                        $blog_meta_defaults = array(
     329                                'lang_id' => 1,
     330                                'public'  => $public
     331                        );
    327332
    328         $blog_meta_defaults = array(
    329                 'lang_id' => 1,
    330                 'public'  => $public
    331         );
     333                        /**
     334                         * Filter the new site meta variables.
     335                         *
     336                         * @since MU
     337                         * @deprecated 3.0.0 Use the 'add_signup_meta' filter instead.
     338                         *
     339                         * @param array $blog_meta_defaults An array of default blog meta variables.
     340                         */
     341                        $meta_defaults = apply_filters( 'signup_create_blog_meta', $blog_meta_defaults );
     342                        /**
     343                         * Filter the new default site meta variables.
     344                         *
     345                         * @since 3.0.0
     346                         *
     347                         * @param array $meta {
     348                         *     An array of default site meta variables.
     349                         *
     350                         *     @type int $lang_id     The language ID.
     351                         *     @type int $blog_public Whether search engines should be discouraged from indexing the site. 1 for true, 0 for false.
     352                         * }
     353                         */
     354                        $meta = apply_filters( 'add_signup_meta', $meta_defaults );
    332355
    333         /**
    334          * Filter the new site meta variables.
    335          *
    336          * @since MU
    337          * @deprecated 3.0.0 Use the 'add_signup_meta' filter instead.
    338          *
    339          * @param array $blog_meta_defaults An array of default blog meta variables.
    340          */
    341         $meta_defaults = apply_filters( 'signup_create_blog_meta', $blog_meta_defaults );
    342         /**
    343          * Filter the new default site meta variables.
    344          *
    345          * @since 3.0.0
    346          *
    347          * @param array $meta {
    348          *     An array of default site meta variables.
    349          *
    350          *     @type int $lang_id     The language ID.
    351          *     @type int $blog_public Whether search engines should be discouraged from indexing the site. 1 for true, 0 for false.
    352          * }
    353          */
    354         $meta = apply_filters( 'add_signup_meta', $meta_defaults );
     356                        wpmu_create_blog( $domain, $path, $blog_title, $current_user->ID, $meta, $wpdb->siteid );
     357                        confirm_another_blog_signup($domain, $path, $blog_title, $current_user->user_login, $current_user->user_email, $meta);
     358                        return true;
     359                }
    355360
    356         wpmu_create_blog( $domain, $path, $blog_title, $current_user->ID, $meta, $wpdb->siteid );
    357         confirm_another_blog_signup($domain, $path, $blog_title, $current_user->user_login, $current_user->user_email, $meta);
    358         return true;
    359 }
     361                /**
     362                 * Confirm a new site signup
     363                 *
     364                 * @since MU
     365                 *
     366                 * @param string $domain The domain URL
     367                 * @param string $path The site root path
     368                 * @param string $user_name The username
     369                 * @param string $user_email The user's email address
     370                 * @param array $meta Any additional meta from the 'add_signup_meta' filter in validate_blog_signup()
     371                 */
     372                function confirm_another_blog_signup( $domain, $path, $blog_title, $user_name, $user_email = '', $meta = array() ) {
     373                        ?>
     374                        <h2><?php printf( __( 'The site %s is yours.' ), "<a href='http://{$domain}{$path}'>{$blog_title}</a>" ) ?></h2>
     375                        <p>
     376                                <?php printf( __( '<a href="http://%1$s">http://%2$s</a> is your new site. <a href="%3$s">Log in</a> as &#8220;%4$s&#8221; using your existing password.' ), $domain.$path, $domain.$path, "http://" . $domain.$path . "wp-login.php", $user_name ) ?>
     377                        </p>
     378                        <?php
     379                        /**
     380                         * Fires when the site or user sign-up process is complete.
     381                         *
     382                         * @since 3.0.0
     383                         */
     384                        do_action( 'signup_finished' );
     385                }
    360386
    361 /**
    362  * Confirm a new site signup
    363  *
    364  * @since MU
    365  *
    366  * @param string $domain The domain URL
    367  * @param string $path The site root path
    368  * @param string $user_name The username
    369  * @param string $user_email The user's email address
    370  * @param array $meta Any additional meta from the 'add_signup_meta' filter in validate_blog_signup()
    371  */
    372 function confirm_another_blog_signup( $domain, $path, $blog_title, $user_name, $user_email = '', $meta = array() ) {
    373         ?>
    374         <h2><?php printf( __( 'The site %s is yours.' ), "<a href='http://{$domain}{$path}'>{$blog_title}</a>" ) ?></h2>
    375         <p>
    376                 <?php printf( __( '<a href="http://%1$s">http://%2$s</a> is your new site. <a href="%3$s">Log in</a> as &#8220;%4$s&#8221; using your existing password.' ), $domain.$path, $domain.$path, "http://" . $domain.$path . "wp-login.php", $user_name ) ?>
    377         </p>
    378         <?php
    379         /**
    380          * Fires when the site or user sign-up process is complete.
    381          *
    382          * @since 3.0.0
    383          */
    384         do_action( 'signup_finished' );
    385 }
     387                /**
     388                 * Setup the new user signup process
     389                 *
     390                 * @since MU
     391                 *
     392                 * @param string $user_name The username
     393                 * @param string $user_email The user's email
     394                 * @param array $errors
     395                 */
     396                function signup_user( $user_name = '', $user_email = '', $errors = '' ) {
     397                        global $active_signup;
    386398
    387 /**
    388  * Setup the new user signup process
    389  *
    390  * @since MU
    391  *
    392  * @param string $user_name The username
    393  * @param string $user_email The user's email
    394  * @param array $errors
    395  */
    396 function signup_user( $user_name = '', $user_email = '', $errors = '' ) {
    397         global $active_signup;
     399                        if ( !is_wp_error($errors) )
     400                                $errors = new WP_Error();
    398401
    399         if ( !is_wp_error($errors) )
    400                 $errors = new WP_Error();
     402                        $signup_for = isset( $_POST[ 'signup_for' ] ) ? esc_html( $_POST[ 'signup_for' ] ) : 'blog';
    401403
    402         $signup_for = isset( $_POST[ 'signup_for' ] ) ? esc_html( $_POST[ 'signup_for' ] ) : 'blog';
     404                        $signup_user_defaults = array(
     405                                'user_name'  => $user_name,
     406                                'user_email' => $user_email,
     407                                'errors'     => $errors,
     408                        );
    403409
    404         $signup_user_defaults = array(
    405                 'user_name'  => $user_name,
    406                 'user_email' => $user_email,
    407                 'errors'     => $errors,
    408         );
     410                        /**
     411                         * Filter the default user variables used on the user sign-up form.
     412                         *
     413                         * @since 3.0.0
     414                         *
     415                         * @param array $signup_user_defaults {
     416                         *     An array of default user variables.
     417                         *
     418                         *     @type string $user_name  The user username.
     419                         *     @type string $user_email The user email address.
     420                         *     @type array  $errors     An array of possible errors relevant to the sign-up user.
     421                         * }
     422                         */
     423                        $filtered_results = apply_filters( 'signup_user_init', $signup_user_defaults );
     424                        $user_name = $filtered_results['user_name'];
     425                        $user_email = $filtered_results['user_email'];
     426                        $errors = $filtered_results['errors'];
    409427
    410         /**
    411          * Filter the default user variables used on the user sign-up form.
    412          *
    413          * @since 3.0.0
    414          *
    415          * @param array $signup_user_defaults {
    416          *     An array of default user variables.
    417          *
    418          *     @type string $user_name  The user username.
    419          *     @type string $user_email The user email address.
    420          *     @type array  $errors     An array of possible errors relevant to the sign-up user.
    421          * }
    422          */
    423         $filtered_results = apply_filters( 'signup_user_init', $signup_user_defaults );
    424         $user_name = $filtered_results['user_name'];
    425         $user_email = $filtered_results['user_email'];
    426         $errors = $filtered_results['errors'];
     428                        ?>
    427429
    428         ?>
     430                        <h2><?php printf( __( 'Get your own %s account in seconds' ), get_current_site()->site_name ) ?></h2>
     431                        <form id="setupform" method="post" action="wp-signup.php" novalidate="novalidate">
     432                                <input type="hidden" name="stage" value="validate-user-signup" />
     433                                <?php
     434                                /** This action is documented in wp-signup.php */
     435                                do_action( 'signup_hidden_fields', 'validate-user' );
     436                                ?>
     437                                <?php show_user_form($user_name, $user_email, $errors); ?>
    429438
    430         <h2><?php printf( __( 'Get your own %s account in seconds' ), get_current_site()->site_name ) ?></h2>
    431         <form id="setupform" method="post" action="wp-signup.php" novalidate="novalidate">
    432                 <input type="hidden" name="stage" value="validate-user-signup" />
    433                 <?php
    434                 /** This action is documented in wp-signup.php */
    435                 do_action( 'signup_hidden_fields', 'validate-user' );
    436                 ?>
    437                 <?php show_user_form($user_name, $user_email, $errors); ?>
     439                                <p>
     440                                        <?php if ( $active_signup == 'blog' ) { ?>
     441                                                <input id="signupblog" type="hidden" name="signup_for" value="blog" />
     442                                        <?php } elseif ( $active_signup == 'user' ) { ?>
     443                                                <input id="signupblog" type="hidden" name="signup_for" value="user" />
     444                                        <?php } else { ?>
     445                                                <input id="signupblog" type="radio" name="signup_for" value="blog" <?php checked( $signup_for, 'blog' ); ?> />
     446                                                <label class="checkbox" for="signupblog"><?php _e('Gimme a site!') ?></label>
     447                                                <br />
     448                                                <input id="signupuser" type="radio" name="signup_for" value="user" <?php checked( $signup_for, 'user' ); ?> />
     449                                                <label class="checkbox" for="signupuser"><?php _e('Just a username, please.') ?></label>
     450                                        <?php } ?>
     451                                </p>
    438452
    439                 <p>
    440                 <?php if ( $active_signup == 'blog' ) { ?>
    441                         <input id="signupblog" type="hidden" name="signup_for" value="blog" />
    442                 <?php } elseif ( $active_signup == 'user' ) { ?>
    443                         <input id="signupblog" type="hidden" name="signup_for" value="user" />
    444                 <?php } else { ?>
    445                         <input id="signupblog" type="radio" name="signup_for" value="blog" <?php checked( $signup_for, 'blog' ); ?> />
    446                         <label class="checkbox" for="signupblog"><?php _e('Gimme a site!') ?></label>
    447                         <br />
    448                         <input id="signupuser" type="radio" name="signup_for" value="user" <?php checked( $signup_for, 'user' ); ?> />
    449                         <label class="checkbox" for="signupuser"><?php _e('Just a username, please.') ?></label>
    450                 <?php } ?>
    451                 </p>
     453                                <p class="submit"><input type="submit" name="submit" class="submit" value="<?php esc_attr_e('Next') ?>" /></p>
     454                        </form>
     455                        <?php
     456                }
    452457
    453                 <p class="submit"><input type="submit" name="submit" class="submit" value="<?php esc_attr_e('Next') ?>" /></p>
    454         </form>
    455         <?php
    456 }
     458                /**
     459                 * Validate the new user signup
     460                 *
     461                 * @since MU
     462                 *
     463                 * @return bool True if new user signup was validated, false if error
     464                 */
     465                function validate_user_signup() {
     466                        $result = validate_user_form();
     467                        $user_name = $result['user_name'];
     468                        $user_email = $result['user_email'];
     469                        $errors = $result['errors'];
    457470
    458 /**
    459  * Validate the new user signup
    460  *
    461  * @since MU
    462  *
    463  * @return bool True if new user signup was validated, false if error
    464  */
    465 function validate_user_signup() {
    466         $result = validate_user_form();
    467         $user_name = $result['user_name'];
    468         $user_email = $result['user_email'];
    469         $errors = $result['errors'];
     471                        if ( $errors->get_error_code() ) {
     472                                signup_user($user_name, $user_email, $errors);
     473                                return false;
     474                        }
    470475
    471         if ( $errors->get_error_code() ) {
    472                 signup_user($user_name, $user_email, $errors);
    473                 return false;
    474         }
     476                        if ( 'blog' == $_POST['signup_for'] ) {
     477                                signup_blog($user_name, $user_email);
     478                                return false;
     479                        }
    475480
    476         if ( 'blog' == $_POST['signup_for'] ) {
    477                 signup_blog($user_name, $user_email);
    478                 return false;
    479         }
     481                        /** This filter is documented in wp-signup.php */
     482                        wpmu_signup_user( $user_name, $user_email, apply_filters( 'add_signup_meta', array() ) );
    480483
    481         /** This filter is documented in wp-signup.php */
    482         wpmu_signup_user( $user_name, $user_email, apply_filters( 'add_signup_meta', array() ) );
     484                        confirm_user_signup($user_name, $user_email);
     485                        return true;
     486                }
    483487
    484         confirm_user_signup($user_name, $user_email);
    485         return true;
    486 }
     488                /**
     489                 * New user signup confirmation
     490                 *
     491                 * @since MU
     492                 *
     493                 * @param string $user_name The username
     494                 * @param string $user_email The user's email address
     495                 */
     496                function confirm_user_signup( $user_name, $user_email ) {
     497                        $message =
     498                                "<h2>" . sprintf( __( '%s is your new username' ), $user_name ) . "</h2>
     499        <p>" . _( 'But, before you can start using your new username, <strong>you must activate it</strong>.' ) . "</p>
     500        <p>" . sprintf( __( 'Check your inbox at <strong>%s</strong> and click the link given.' ), $user_email ) . "</p>
     501        <p>" . _( 'If you do not activate your username within two days, you will have to sign up again.' ) . "</p>";
    487502
    488 /**
    489  * New user signup confirmation
    490  *
    491  * @since MU
    492  *
    493  * @param string $user_name The username
    494  * @param string $user_email The user's email address
    495  */
    496 function confirm_user_signup($user_name, $user_email) {
    497         ?>
    498         <h2><?php printf( __( '%s is your new username' ), $user_name) ?></h2>
    499         <p><?php _e( 'But, before you can start using your new username, <strong>you must activate it</strong>.' ) ?></p>
    500         <p><?php printf( __( 'Check your inbox at <strong>%s</strong> and click the link given.' ), $user_email ); ?></p>
    501         <p><?php _e( 'If you do not activate your username within two days, you will have to sign up again.' ); ?></p>
    502         <?php
    503         /** This action is documented in wp-signup.php */
    504         do_action( 'signup_finished' );
    505 }
     503                        /**
     504                         * Filter the user signup confirmation message
     505                         *
     506                         * @since 4.2
     507                         *
     508                         * @param string $message The default message
     509                         * @param string $user_name The username
     510                         * @param string $user_email The user's email address
     511                         */
     512                        echo apply_filters( 'confirm_user_signup', $message, $user_name, $user_email );
    506513
    507 /**
    508  * Setup the new site signup
    509  *
    510  * @since MU
    511  *
    512  * @param string $user_name The username
    513  * @param string $user_email The user's email address
    514  * @param string $blogname The site name
    515  * @param string $blog_title The site title
    516  * @param array $errors
    517  */
    518 function signup_blog($user_name = '', $user_email = '', $blogname = '', $blog_title = '', $errors = '') {
    519         if ( !is_wp_error($errors) )
    520                 $errors = new WP_Error();
     514                        /** This action is documented in wp-signup.php */
     515                        do_action( 'signup_finished' );
     516                }
    521517
    522         $signup_blog_defaults = array(
    523                 'user_name'  => $user_name,
    524                 'user_email' => $user_email,
    525                 'blogname'   => $blogname,
    526                 'blog_title' => $blog_title,
    527                 'errors'     => $errors
    528         );
     518                /**
     519                 * Setup the new site signup
     520                 *
     521                 * @since MU
     522                 *
     523                 * @param string $user_name The username
     524                 * @param string $user_email The user's email address
     525                 * @param string $blogname The site name
     526                 * @param string $blog_title The site title
     527                 * @param array $errors
     528                 */
     529                function signup_blog($user_name = '', $user_email = '', $blogname = '', $blog_title = '', $errors = '') {
     530                        if ( !is_wp_error($errors) )
     531                                $errors = new WP_Error();
    529532
    530         /**
    531          * Filter the default site creation variables for the site sign-up form.
    532          *
    533          * @since 3.0.0
    534          *
    535          * @param array $signup_blog_defaults {
    536          *     An array of default site creation variables.
    537          *
    538          *     @type string $user_name  The user username.
    539          *     @type string $user_email The user email address.
    540          *     @type string $blogname   The blogname.
    541          *     @type string $blog_title The title of the site.
    542          *     @type array  $errors     An array of possible errors relevant to new site creation variables.
    543          * }
    544          */
    545         $filtered_results = apply_filters( 'signup_blog_init', $signup_blog_defaults );
     533                        $signup_blog_defaults = array(
     534                                'user_name'  => $user_name,
     535                                'user_email' => $user_email,
     536                                'blogname'   => $blogname,
     537                                'blog_title' => $blog_title,
     538                                'errors'     => $errors
     539                        );
    546540
    547         $user_name = $filtered_results['user_name'];
    548         $user_email = $filtered_results['user_email'];
    549         $blogname = $filtered_results['blogname'];
    550         $blog_title = $filtered_results['blog_title'];
    551         $errors = $filtered_results['errors'];
     541                        /**
     542                         * Filter the default site creation variables for the site sign-up form.
     543                         *
     544                         * @since 3.0.0
     545                         *
     546                         * @param array $signup_blog_defaults {
     547                         *     An array of default site creation variables.
     548                         *
     549                         *     @type string $user_name  The user username.
     550                         *     @type string $user_email The user email address.
     551                         *     @type string $blogname   The blogname.
     552                         *     @type string $blog_title The title of the site.
     553                         *     @type array  $errors     An array of possible errors relevant to new site creation variables.
     554                         * }
     555                         */
     556                        $filtered_results = apply_filters( 'signup_blog_init', $signup_blog_defaults );
    552557
    553         if ( empty($blogname) )
    554                 $blogname = $user_name;
    555         ?>
    556         <form id="setupform" method="post" action="wp-signup.php">
    557                 <input type="hidden" name="stage" value="validate-blog-signup" />
    558                 <input type="hidden" name="user_name" value="<?php echo esc_attr($user_name) ?>" />
    559                 <input type="hidden" name="user_email" value="<?php echo esc_attr($user_email) ?>" />
    560                 <?php
    561                 /** This action is documented in wp-signup.php */
    562                 do_action( 'signup_hidden_fields', 'validate-site' );
    563                 ?>
    564                 <?php show_blog_form($blogname, $blog_title, $errors); ?>
    565                 <p class="submit"><input type="submit" name="submit" class="submit" value="<?php esc_attr_e('Signup') ?>" /></p>
    566         </form>
    567         <?php
    568 }
     558                        $user_name = $filtered_results['user_name'];
     559                        $user_email = $filtered_results['user_email'];
     560                        $blogname = $filtered_results['blogname'];
     561                        $blog_title = $filtered_results['blog_title'];
     562                        $errors = $filtered_results['errors'];
    569563
    570 /**
    571  * Validate new site signup
    572  *
    573  * @since MU
    574  *
    575  * @return bool True if the site signup was validated, false if error
    576  */
    577 function validate_blog_signup() {
    578         // Re-validate user info.
    579         $user_result = wpmu_validate_user_signup( $_POST['user_name'], $_POST['user_email'] );
    580         $user_name = $user_result['user_name'];
    581         $user_email = $user_result['user_email'];
    582         $user_errors = $user_result['errors'];
     564                        if ( empty($blogname) )
     565                                $blogname = $user_name;
     566                        ?>
     567                        <form id="setupform" method="post" action="wp-signup.php">
     568                                <input type="hidden" name="stage" value="validate-blog-signup" />
     569                                <input type="hidden" name="user_name" value="<?php echo esc_attr($user_name) ?>" />
     570                                <input type="hidden" name="user_email" value="<?php echo esc_attr($user_email) ?>" />
     571                                <?php
     572                                /** This action is documented in wp-signup.php */
     573                                do_action( 'signup_hidden_fields', 'validate-site' );
     574                                ?>
     575                                <?php show_blog_form($blogname, $blog_title, $errors); ?>
     576                                <p class="submit"><input type="submit" name="submit" class="submit" value="<?php esc_attr_e('Signup') ?>" /></p>
     577                        </form>
     578                        <?php
     579                }
    583580
    584         if ( $user_errors->get_error_code() ) {
    585                 signup_user( $user_name, $user_email, $user_errors );
    586                 return false;
    587         }
     581                /**
     582                 * Validate new site signup
     583                 *
     584                 * @since MU
     585                 *
     586                 * @return bool True if the site signup was validated, false if error
     587                 */
     588                function validate_blog_signup() {
     589                        // Re-validate user info.
     590                        $user_result = wpmu_validate_user_signup( $_POST['user_name'], $_POST['user_email'] );
     591                        $user_name = $user_result['user_name'];
     592                        $user_email = $user_result['user_email'];
     593                        $user_errors = $user_result['errors'];
    588594
    589         $result = wpmu_validate_blog_signup( $_POST['blogname'], $_POST['blog_title'] );
    590         $domain = $result['domain'];
    591         $path = $result['path'];
    592         $blogname = $result['blogname'];
    593         $blog_title = $result['blog_title'];
    594         $errors = $result['errors'];
     595                        if ( $user_errors->get_error_code() ) {
     596                                signup_user( $user_name, $user_email, $user_errors );
     597                                return false;
     598                        }
    595599
    596         if ( $errors->get_error_code() ) {
    597                 signup_blog($user_name, $user_email, $blogname, $blog_title, $errors);
    598                 return false;
    599         }
     600                        $result = wpmu_validate_blog_signup( $_POST['blogname'], $_POST['blog_title'] );
     601                        $domain = $result['domain'];
     602                        $path = $result['path'];
     603                        $blogname = $result['blogname'];
     604                        $blog_title = $result['blog_title'];
     605                        $errors = $result['errors'];
    600606
    601         $public = (int) $_POST['blog_public'];
    602         $signup_meta = array ('lang_id' => 1, 'public' => $public);
     607                        if ( $errors->get_error_code() ) {
     608                                signup_blog($user_name, $user_email, $blogname, $blog_title, $errors);
     609                                return false;
     610                        }
    603611
    604         /** This filter is documented in wp-signup.php */
    605         $meta = apply_filters( 'add_signup_meta', $signup_meta );
     612                        $public = (int) $_POST['blog_public'];
     613                        $signup_meta = array ('lang_id' => 1, 'public' => $public);
    606614
    607         wpmu_signup_blog($domain, $path, $blog_title, $user_name, $user_email, $meta);
    608         confirm_blog_signup($domain, $path, $blog_title, $user_name, $user_email, $meta);
    609         return true;
    610 }
     615                        /** This filter is documented in wp-signup.php */
     616                        $meta = apply_filters( 'add_signup_meta', $signup_meta );
    611617
    612 /**
    613  * New site signup confirmation
    614  *
    615  * @since MU
    616  *
    617  * @param string $domain The domain URL
    618  * @param string $path The site root path
    619  * @param string $blog_title The new site title
    620  * @param string $user_name The user's username
    621  * @param string $user_email The user's email address
    622  * @param array $meta Any additional meta from the 'add_signup_meta' filter in validate_blog_signup()
    623  */
    624 function confirm_blog_signup( $domain, $path, $blog_title, $user_name = '', $user_email = '', $meta = array() ) {
    625         ?>
    626         <h2><?php printf( __( 'Congratulations! Your new site, %s, is almost ready.' ), "<a href='http://{$domain}{$path}'>{$blog_title}</a>" ) ?></h2>
     618                        wpmu_signup_blog($domain, $path, $blog_title, $user_name, $user_email, $meta);
     619                        confirm_blog_signup($domain, $path, $blog_title, $user_name, $user_email, $meta);
     620                        return true;
     621                }
    627622
    628         <p><?php _e( 'But, before you can start using your site, <strong>you must activate it</strong>.' ) ?></p>
    629         <p><?php printf( __( 'Check your inbox at <strong>%s</strong> and click the link given.' ),  $user_email) ?></p>
    630         <p><?php _e( 'If you do not activate your site within two days, you will have to sign up again.' ); ?></p>
    631         <h2><?php _e( 'Still waiting for your email?' ); ?></h2>
    632         <p>
    633                 <?php _e( 'If you haven&#8217;t received your email yet, there are a number of things you can do:' ) ?>
    634                 <ul id="noemail-tips">
    635                         <li><p><strong><?php _e( 'Wait a little longer. Sometimes delivery of email can be delayed by processes outside of our control.' ) ?></strong></p></li>
    636                         <li><p><?php _e( 'Check the junk or spam folder of your email client. Sometime emails wind up there by mistake.' ) ?></p></li>
    637                         <li><?php printf( __( 'Have you entered your email correctly? You have entered %s, if it&#8217;s incorrect, you will not receive your email.' ), $user_email ) ?></li>
     623                /**
     624                 * New site signup confirmation
     625                 *
     626                 * @since MU
     627                 *
     628                 * @param string $domain The domain URL
     629                 * @param string $path The site root path
     630                 * @param string $blog_title The new site title
     631                 * @param string $user_name The user's username
     632                 * @param string $user_email The user's email address
     633                 * @param array $meta Any additional meta from the 'add_signup_meta' filter in validate_blog_signup()
     634                 */
     635                function confirm_blog_signup( $domain, $path, $blog_title, $user_name = '', $user_email = '', $meta = array() ) {
     636                        $message =
     637                                "<h2>" . sprintf( __( 'Congratulations! Your new site, %s, is almost ready.' ), "<a href='http://{$domain}{$path}'>{$blog_title}</a>" ) . "</h2>
     638        <p>" . _( 'But, before you can start using your site, <strong>you must activate it</strong>.' ) . "</p>
     639        <p>" . sprintf( __( 'Check your inbox at <strong>%s</strong> and click the link given.' ),  $user_email ) . "</p>
     640        <p>" . _( 'If you do not activate your site within two days, you will have to sign up again.' ) . "</p>
     641        <h2>" . _( 'Still waiting for your email?' ) . "</h2>
     642        <p>" .
     643                                _( 'If you haven&#8217;t received your email yet, there are a number of things you can do:' )
     644                                . "<ul id='noemail-tips'>
     645                        <li><p><strong>" . _( 'Wait a little longer. Sometimes delivery of email can be delayed by processes outside of our control.' ) . "</strong></p></li>
     646                        <li><p>" . _( 'Check the junk or spam folder of your email client. Sometime emails wind up there by mistake.' ) . "</p></li>
     647                        <li>" . sprintf( __( 'Have you entered your email correctly? You have entered %s, if it&#8217;s incorrect, you will not receive your email.' ), $user_email ) . "</li>
    638648                </ul>
    639         </p>
    640         <?php
    641         /** This action is documented in wp-signup.php */
    642         do_action( 'signup_finished' );
    643 }
     649        </p>";
    644650
    645 // Main
    646 $active_signup = get_site_option( 'registration', 'none' );
    647 /**
    648  * Filter the type of site sign-up.
    649  *
    650  * @since 3.0.0
    651  *
    652  * @param string $active_signup String that returns registration type. The value can be
    653  *                              'all', 'none', 'blog', or 'user'.
    654  */
    655 $active_signup = apply_filters( 'wpmu_active_signup', $active_signup );
     651                        /**
     652                         * Filter the blog signup confirmation message
     653                         *
     654                         * @since 4.2
     655                         *
     656                         * @param string $message The domain URL
     657                         * @param string $domain The domain URL
     658                         * @param string $path The site root path
     659                         * @param string $blog_title The new site title
     660                         * @param string $user_name, The username
     661                         * @param string $user_email The user's email address
     662                         * @param array $meta Any additional meta from the 'add_signup_meta' filter in validate_blog_signup()
     663                         */
     664                        echo apply_filters( 'confirm_blog_signup', $message, $domain, $path, $blog_title, $user_name, $user_email, $meta );
     665                        /** This action is documented in wp-signup.php */
     666                        do_action( 'signup_finished' );
     667                }
    656668
    657 // Make the signup type translatable.
    658 $i18n_signup['all'] = _x('all', 'Multisite active signup type');
    659 $i18n_signup['none'] = _x('none', 'Multisite active signup type');
    660 $i18n_signup['blog'] = _x('blog', 'Multisite active signup type');
    661 $i18n_signup['user'] = _x('user', 'Multisite active signup type');
     669                // Main
     670                $active_signup = get_site_option( 'registration', 'none' );
     671                /**
     672                 * Filter the type of site sign-up.
     673                 *
     674                 * @since 3.0.0
     675                 *
     676                 * @param string $active_signup String that returns registration type. The value can be
     677                 *                              'all', 'none', 'blog', or 'user'.
     678                 */
     679                $active_signup = apply_filters( 'wpmu_active_signup', $active_signup );
    662680
    663 if ( is_super_admin() )
    664         echo '<div class="mu_alert">' . sprintf( __( 'Greetings Site Administrator! You are currently allowing &#8220;%s&#8221; registrations. To change or disable registration go to your <a href="%s">Options page</a>.' ), $i18n_signup[$active_signup], esc_url( network_admin_url( 'settings.php' ) ) ) . '</div>';
     681                // Make the signup type translatable.
     682                $i18n_signup['all'] = _x('all', 'Multisite active signup type');
     683                $i18n_signup['none'] = _x('none', 'Multisite active signup type');
     684                $i18n_signup['blog'] = _x('blog', 'Multisite active signup type');
     685                $i18n_signup['user'] = _x('user', 'Multisite active signup type');
    665686
    666 $newblogname = isset($_GET['new']) ? strtolower(preg_replace('/^-|-$|[^-a-zA-Z0-9]/', '', $_GET['new'])) : null;
     687                if ( is_super_admin() )
     688                        echo '<div class="mu_alert">' . sprintf( __( 'Greetings Site Administrator! You are currently allowing &#8220;%s&#8221; registrations. To change or disable registration go to your <a href="%s">Options page</a>.' ), $i18n_signup[$active_signup], esc_url( network_admin_url( 'settings.php' ) ) ) . '</div>';
    667689
    668 $current_user = wp_get_current_user();
    669 if ( $active_signup == 'none' ) {
    670         _e( 'Registration has been disabled.' );
    671 } elseif ( $active_signup == 'blog' && !is_user_logged_in() ) {
    672         $login_url = site_url( 'wp-login.php?redirect_to=' . urlencode( network_site_url( 'wp-signup.php' ) ) );
    673         echo sprintf( __( 'You must first <a href="%s">log in</a>, and then you can create a new site.' ), $login_url );
    674 } else {
    675         $stage = isset( $_POST['stage'] ) ?  $_POST['stage'] : 'default';
    676         switch ( $stage ) {
    677                 case 'validate-user-signup' :
    678                         if ( $active_signup == 'all' || $_POST[ 'signup_for' ] == 'blog' && $active_signup == 'blog' || $_POST[ 'signup_for' ] == 'user' && $active_signup == 'user' )
    679                                 validate_user_signup();
    680                         else
    681                                 _e( 'User registration has been disabled.' );
    682                 break;
    683                 case 'validate-blog-signup':
    684                         if ( $active_signup == 'all' || $active_signup == 'blog' )
    685                                 validate_blog_signup();
    686                         else
    687                                 _e( 'Site registration has been disabled.' );
    688                         break;
    689                 case 'gimmeanotherblog':
    690                         validate_another_blog_signup();
    691                         break;
    692                 case 'default':
    693                 default :
    694                         $user_email = isset( $_POST[ 'user_email' ] ) ? $_POST[ 'user_email' ] : '';
    695                         /**
    696                          * Fires when the site sign-up form is sent.
    697                          *
    698                          * @since 3.0.0
    699                          */
    700                         do_action( 'preprocess_signup_form' );
    701                         if ( is_user_logged_in() && ( $active_signup == 'all' || $active_signup == 'blog' ) )
    702                                 signup_another_blog($newblogname);
    703                         elseif ( ! is_user_logged_in() && ( $active_signup == 'all' || $active_signup == 'user' ) )
    704                                 signup_user( $newblogname, $user_email );
    705                         elseif ( ! is_user_logged_in() && ( $active_signup == 'blog' ) )
    706                                 _e( 'Sorry, new registrations are not allowed at this time.' );
    707                         else
    708                                 _e( 'You are logged in already. No need to register again!' );
     690                $newblogname = isset($_GET['new']) ? strtolower(preg_replace('/^-|-$|[^-a-zA-Z0-9]/', '', $_GET['new'])) : null;
    709691
    710                         if ( $newblogname ) {
    711                                 $newblog = get_blogaddress_by_name( $newblogname );
     692                $current_user = wp_get_current_user();
     693                if ( $active_signup == 'none' ) {
     694                        _e( 'Registration has been disabled.' );
     695                } elseif ( $active_signup == 'blog' && !is_user_logged_in() ) {
     696                        $login_url = site_url( 'wp-login.php?redirect_to=' . urlencode( network_site_url( 'wp-signup.php' ) ) );
     697                        echo sprintf( __( 'You must first <a href="%s">log in</a>, and then you can create a new site.' ), $login_url );
     698                } else {
     699                        $stage = isset( $_POST['stage'] ) ?  $_POST['stage'] : 'default';
     700                        switch ( $stage ) {
     701                                case 'validate-user-signup' :
     702                                        if ( $active_signup == 'all' || $_POST[ 'signup_for' ] == 'blog' && $active_signup == 'blog' || $_POST[ 'signup_for' ] == 'user' && $active_signup == 'user' )
     703                                                validate_user_signup();
     704                                        else
     705                                                _e( 'User registration has been disabled.' );
     706                                        break;
     707                                case 'validate-blog-signup':
     708                                        if ( $active_signup == 'all' || $active_signup == 'blog' )
     709                                                validate_blog_signup();
     710                                        else
     711                                                _e( 'Site registration has been disabled.' );
     712                                        break;
     713                                case 'gimmeanotherblog':
     714                                        validate_another_blog_signup();
     715                                        break;
     716                                case 'default':
     717                                default :
     718                                        $user_email = isset( $_POST[ 'user_email' ] ) ? $_POST[ 'user_email' ] : '';
     719                                        /**
     720                                         * Fires when the site sign-up form is sent.
     721                                         *
     722                                         * @since 3.0.0
     723                                         */
     724                                        do_action( 'preprocess_signup_form' );
     725                                        if ( is_user_logged_in() && ( $active_signup == 'all' || $active_signup == 'blog' ) )
     726                                                signup_another_blog($newblogname);
     727                                        elseif ( ! is_user_logged_in() && ( $active_signup == 'all' || $active_signup == 'user' ) )
     728                                                signup_user( $newblogname, $user_email );
     729                                        elseif ( ! is_user_logged_in() && ( $active_signup == 'blog' ) )
     730                                                _e( 'Sorry, new registrations are not allowed at this time.' );
     731                                        else
     732                                                _e( 'You are logged in already. No need to register again!' );
    712733
    713                                 if ( $active_signup == 'blog' || $active_signup == 'all' )
    714                                         printf( '<p><em>' . __( 'The site you were looking for, <strong>%s</strong>, does not exist, but you can create it now!' ) . '</em></p>', $newblog );
    715                                 else
    716                                         printf( '<p><em>' . __( 'The site you were looking for, <strong>%s</strong>, does not exist.' ) . '</em></p>', $newblog );
     734                                        if ( $newblogname ) {
     735                                                $newblog = get_blogaddress_by_name( $newblogname );
     736
     737                                                if ( $active_signup == 'blog' || $active_signup == 'all' )
     738                                                        printf( '<p><em>' . __( 'The site you were looking for, <strong>%s</strong>, does not exist, but you can create it now!' ) . '</em></p>', $newblog );
     739                                                else
     740                                                        printf( '<p><em>' . __( 'The site you were looking for, <strong>%s</strong>, does not exist.' ) . '</em></p>', $newblog );
     741                                        }
     742                                        break;
    717743                        }
    718                         break;
    719         }
    720 }
    721 ?>
     744                }
     745                ?>
     746        </div>
    722747</div>
    723 </div>
    724748<?php
    725749/**
    726750 * Fires after the sign-up forms, before wp_footer.