Make WordPress Core

Ticket #43405: wp-signup.diff

File wp-signup.diff, 9.2 KB (added by GaryJ, 7 years ago)
  • src/wp-signup.php

    diff --git src/wp-signup.php src/wp-signup.php
    index cecaf989e5..377ccf67d7 100644
    function show_blog_form( $blogname = '', $blog_title = '', $errors = '' ) { 
    108108                echo '<label for="blogname">' . __( 'Site Domain:' ) . '</label>';
    109109        }
    110110
    111         if ( $errmsg = $errors->get_error_message( 'blogname' ) ) {
     111        $errmsg = $errors->get_error_message( 'blogname' );
     112        if ( $errmsg ) {
    112113        ?>
    113114                <p class="error"><?php echo $errmsg; ?></p>
    114115        <?php
    function show_blog_form( $blogname = '', $blog_title = '', $errors = '' ) { 
    117118        if ( ! is_subdomain_install() ) {
    118119                echo '<span class="prefix_address">' . $current_network->domain . $current_network->path . '</span><input name="blogname" type="text" id="blogname" value="' . esc_attr( $blogname ) . '" maxlength="60" /><br />';
    119120        } else {
    120                 echo '<input name="blogname" type="text" id="blogname" value="' . esc_attr( $blogname ) . '" maxlength="60" /><span class="suffix_address">.' . ( $site_domain = preg_replace( '|^www\.|', '', $current_network->domain ) ) . '</span><br />';
     121                $site_domain = preg_replace( '|^www\.|', '', $current_network->domain );
     122                echo '<input name="blogname" type="text" id="blogname" value="' . esc_attr( $blogname ) . '" maxlength="60" /><span class="suffix_address">.' . ( $site_domain ) . '</span><br />';
    121123        }
    122124
    123125        if ( ! is_user_logged_in() ) {
    function show_blog_form( $blogname = '', $blog_title = '', $errors = '' ) { 
    134136        // Blog Title
    135137        ?>
    136138        <label for="blog_title"><?php _e( 'Site Title:' ); ?></label>
    137         <?php if ( $errmsg = $errors->get_error_message( 'blog_title' ) ) { ?>
    138                 <p class="error"><?php echo $errmsg; ?></p>
    139139        <?php
    140 }
     140        $errmsg = $errors->get_error_message( 'blog_title' );
     141        if ( $errmsg ) {
     142                ?>
     143                <p class="error"><?php echo $errmsg; ?></p>
     144                <?php
     145        }
    141146        echo '<input name="blog_title" type="text" id="blog_title" value="' . esc_attr( $blog_title ) . '" />';
    142147        ?>
    143148
    function show_blog_form( $blogname = '', $blog_title = '', $errors = '' ) { 
    176181        <?php
    177182                endif; // Languages.
    178183
    179                 $blog_public_on_checked = $blog_public_off_checked = '';
     184                $blog_public_on_checked  = '';
     185                $blog_public_off_checked = '';
    180186        if ( isset( $_POST['blog_public'] ) && '0' == $_POST['blog_public'] ) {
    181187                $blog_public_off_checked = 'checked="checked"';
    182188        } else {
    function show_user_form( $user_name = '', $user_email = '', $errors = '' ) { 
    243249
    244250        // User name
    245251        echo '<label for="user_name">' . __( 'Username:' ) . '</label>';
    246         if ( $errmsg = $errors->get_error_message( 'user_name' ) ) {
     252        $errmsg = $errors->get_error_message( 'user_name' );
     253        if ( $errmsg ) {
    247254                echo '<p class="error">' . $errmsg . '</p>';
    248255        }
    249256        echo '<input name="user_name" type="text" id="user_name" value="' . esc_attr( $user_name ) . '" autocapitalize="none" autocorrect="off" maxlength="60" /><br />';
    function show_user_form( $user_name = '', $user_email = '', $errors = '' ) { 
    251258        ?>
    252259
    253260        <label for="user_email"><?php _e( 'Email&nbsp;Address:' ); ?></label>
    254         <?php if ( $errmsg = $errors->get_error_message( 'user_email' ) ) { ?>
     261        <?php
     262        $errmsg = $errors->get_error_message( 'user_email' );
     263        if ( $errmsg ) {
     264                ?>
    255265                <p class="error"><?php echo $errmsg; ?></p>
    256266        <?php } ?>
    257267        <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.)' ); ?>
    258268        <?php
    259         if ( $errmsg = $errors->get_error_message( 'generic' ) ) {
     269        $errmsg = $errors->get_error_message( 'generic' );
     270        if ( $errmsg ) {
    260271                echo '<p class="error">' . $errmsg . '</p>';
    261272        }
    262273        /**
    function signup_another_blog( $blogname = '', $blog_title = '', $errors = '' ) { 
    321332        $blog_title = $filtered_results['blog_title'];
    322333        $errors     = $filtered_results['errors'];
    323334
     335        /* translators: %s: site name */
    324336        echo '<h2>' . sprintf( __( 'Get <em>another</em> %s site in seconds' ), get_network()->site_name ) . '</h2>';
    325337
    326338        if ( $errors->get_error_code() ) {
    327339                echo '<p>' . __( 'There was a problem, please correct the form below and try again.' ) . '</p>';
    328340        }
    329341        ?>
    330         <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>
     342        <p>
     343        <?php
     344        printf(
     345                /* translators: %s: display name */
     346                __( '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!' ),
     347                $current_user->display_name
     348        );
     349        ?>
     350        </p>
    331351
    332352        <?php
    333353        $blogs = get_blogs_of_user( $current_user->ID );
    function validate_another_blog_signup() { 
    383403        $result = validate_blog_form();
    384404
    385405        // Extracted values set/overwrite globals.
     406        // phpcs:disable WordPress.Variables.GlobalVariables.OverrideProhibited
    386407        $domain     = $result['domain'];
    387408        $path       = $result['path'];
    388409        $blogname   = $result['blogname'];
    389410        $blog_title = $result['blog_title'];
    390411        $errors     = $result['errors'];
     412        // phpcs:enable WordPress.Variables.GlobalVariables.OverrideProhibited
    391413
    392414        if ( $errors->get_error_code() ) {
    393415                signup_another_blog( $blogname, $blog_title, $errors );
    function signup_user( $user_name = '', $user_email = '', $errors = '' ) { 
    573595                <?php show_user_form( $user_name, $user_email, $errors ); ?>
    574596
    575597                <p>
    576                 <?php if ( $active_signup == 'blog' ) { ?>
     598                <?php if ( 'blog' === $active_signup ) { ?>
    577599                        <input id="signupblog" type="hidden" name="signup_for" value="blog" />
    578                 <?php } elseif ( $active_signup == 'user' ) { ?>
     600                <?php } elseif ( 'user' === $active_signup ) { ?>
    579601                        <input id="signupblog" type="hidden" name="signup_for" value="user" />
    580602                <?php } else { ?>
    581603                        <input id="signupblog" type="radio" name="signup_for" value="blog" <?php checked( $signup_for, 'blog' ); ?> />
    if ( current_user_can( 'manage_network' ) ) { 
    898920$newblogname = isset( $_GET['new'] ) ? strtolower( preg_replace( '/^-|-$|[^-a-zA-Z0-9]/', '', $_GET['new'] ) ) : null;
    899921
    900922$current_user = wp_get_current_user();
    901 if ( $active_signup == 'none' ) {
     923if ( 'none' === $active_signup ) {
    902924        _e( 'Registration has been disabled.' );
    903 } elseif ( $active_signup == 'blog' && ! is_user_logged_in() ) {
     925} elseif ( 'blog' === $active_signup && ! is_user_logged_in() ) {
    904926        $login_url = wp_login_url( network_site_url( 'wp-signup.php' ) );
    905927        /* translators: %s: login URL */
    906928        printf( __( 'You must first <a href="%s">log in</a>, and then you can create a new site.' ), $login_url );
    if ( $active_signup == 'none' ) { 
    908930        $stage = isset( $_POST['stage'] ) ? $_POST['stage'] : 'default';
    909931        switch ( $stage ) {
    910932                case 'validate-user-signup':
    911                         if ( $active_signup == 'all' || $_POST['signup_for'] == 'blog' && $active_signup == 'blog' || $_POST['signup_for'] == 'user' && $active_signup == 'user' ) {
     933                        if ( 'all' === $active_signup || 'blog' === $_POST['signup_for'] && 'blog' === $active_signup || 'user' === $_POST['signup_for'] && 'user' === $active_signup ) {
    912934                                validate_user_signup();
    913935                        } else {
    914936                                _e( 'User registration has been disabled.' );
    915937                        }
    916938                        break;
    917939                case 'validate-blog-signup':
    918                         if ( $active_signup == 'all' || $active_signup == 'blog' ) {
     940                        if ( 'all' === $active_signup || 'blog' === $active_signup ) {
    919941                                validate_blog_signup();
    920942                        } else {
    921943                                _e( 'Site registration has been disabled.' );
    if ( $active_signup == 'none' ) { 
    933955                         * @since 3.0.0
    934956                         */
    935957                        do_action( 'preprocess_signup_form' );
    936                         if ( is_user_logged_in() && ( $active_signup == 'all' || $active_signup == 'blog' ) ) {
     958                        if ( is_user_logged_in() && ( 'all' === $active_signup || 'blog' === $active_signup ) ) {
    937959                                signup_another_blog( $newblogname );
    938                         } elseif ( ! is_user_logged_in() && ( $active_signup == 'all' || $active_signup == 'user' ) ) {
     960                        } elseif ( ! is_user_logged_in() && ( 'all' === $active_signup || 'user' === $active_signup ) ) {
    939961                                signup_user( $newblogname, $user_email );
    940                         } elseif ( ! is_user_logged_in() && ( $active_signup == 'blog' ) ) {
     962                        } elseif ( ! is_user_logged_in() && ( 'blog' === $active_signup ) ) {
    941963                                _e( 'Sorry, new registrations are not allowed at this time.' );
    942964                        } else {
    943965                                _e( 'You are logged in already. No need to register again!' );
    if ( $active_signup == 'none' ) { 
    946968                        if ( $newblogname ) {
    947969                                $newblog = get_blogaddress_by_name( $newblogname );
    948970
    949                                 if ( $active_signup == 'blog' || $active_signup == 'all' ) {
    950                                         /* translators: %s: site address */
     971                                if ( 'blog' === $active_signup || 'all' === $active_signup ) {
    951972                                        printf(
     973                                                /* translators: %s: site address */
    952974                                                '<p><em>' . __( 'The site you were looking for, %s, does not exist, but you can create it now!' ) . '</em></p>',
    953975                                                '<strong>' . $newblog . '</strong>'
    954976                                        );
    955                                 } else {                  /* translators: %s: site address */
     977                                } else {
    956978                                        printf(
     979                                                /* translators: %s: site address*/
    957980                                                '<p><em>' . __( 'The site you were looking for, %s, does not exist.' ) . '</em></p>',
    958981                                                '<strong>' . $newblog . '</strong>'
    959982                                        );