Make WordPress Core


Ignore:
Timestamp:
08/17/2018 01:50:26 AM (8 years ago)
Author:
pento
Message:

Coding Standards: Upgrade WPCS to 1.0.0

WPCS 1.0.0 includes a bunch of new auto-fixers, which drops the number of coding standards issues across WordPress significantly. Prior to running the auto-fixers, there were 15,312 issues detected. With this commit, we now drop to 4,769 issues.

This change includes three notable additions:

  • Multiline function calls must now put each parameter on a new line.
  • Auto-formatting files is now part of the grunt precommit script.
  • Auto-fixable coding standards issues will now cause Travis failures.

Fixes #44600.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-login.php

    r43569 r43571  
    255255        // Don't allow interim logins to navigate away from the page.
    256256        if ( ! $interim_login ) :
    257         ?>
     257                ?>
    258258        <p id="backtoblog"><a href="<?php echo esc_url( home_url( '/' ) ); ?>">
    259         <?php
     259                <?php
    260260                /* translators: %s: site title */
    261261                printf( _x( '&larr; Back to %s', 'site' ), get_bloginfo( 'title', 'display' ) );
    262         ?>
     262                ?>
    263263        </a></p>
    264         <?php the_privacy_policy_link( '<div class="privacy-policy-page-link">', '</div>' ); ?>
     264                <?php the_privacy_policy_link( '<div class="privacy-policy-page-link">', '</div>' ); ?>
    265265        <?php endif; ?>
    266266
     
    292292 */
    293293function wp_shake_js() {
    294 ?>
     294        ?>
    295295<script type="text/javascript">
    296296addLoadEvent = function(func){if(typeof jQuery!="undefined")jQuery(document).ready(func);else if(typeof wpOnload!='function'){wpOnload=func;}else{var oldonload=wpOnload;wpOnload=function(){oldonload();func();}}};
     
    300300addLoadEvent(function(){ var p=new Array(15,30,15,0,-15,-30,-15,0);p=p.concat(p.concat(p));var i=document.forms[0].id;g(i).position='relative';shake(i,p,20);});
    301301</script>
    302 <?php
     302        <?php
    303303}
    304304
     
    604604                }
    605605
    606         ?>
     606                ?>
    607607
    608608        <form name="lostpasswordform" id="lostpasswordform" action="<?php echo esc_url( network_site_url( 'wp-login.php?action=lostpassword', 'login_post' ) ); ?>" method="post">
     
    611611                <input type="text" name="user_login" id="user_login" class="input" value="<?php echo esc_attr( $user_login ); ?>" size="20" autocapitalize="off" /></label>
    612612        </p>
    613         <?php
    614         /**
    615         * Fires inside the lostpassword form tags, before the hidden fields.
    616         *
    617         * @since 2.1.0
    618         */
    619         do_action( 'lostpassword_form' );
    620         ?>
     613                <?php
     614                /**
     615                * Fires inside the lostpassword form tags, before the hidden fields.
     616                *
     617                * @since 2.1.0
     618                */
     619                do_action( 'lostpassword_form' );
     620                ?>
    621621                <input type="hidden" name="redirect_to" value="<?php echo esc_attr( $redirect_to ); ?>" />
    622622                <p class="submit"><input type="submit" name="wp-submit" id="wp-submit" class="button button-primary button-large" value="<?php esc_attr_e( 'Get New Password' ); ?>" /></p>
     
    625625        <p id="nav">
    626626        <a href="<?php echo esc_url( wp_login_url() ); ?>"><?php _e( 'Log in' ); ?></a>
    627         <?php
    628         if ( get_option( 'users_can_register' ) ) :
    629                 $registration_url = sprintf( '<a href="%s">%s</a>', esc_url( wp_registration_url() ), __( 'Register' ) );
    630 
    631                 echo esc_html( $login_link_separator );
    632 
    633                 /** This filter is documented in wp-includes/general-template.php */
    634                 echo apply_filters( 'register', $registration_url );
     627                <?php
     628                if ( get_option( 'users_can_register' ) ) :
     629                        $registration_url = sprintf( '<a href="%s">%s</a>', esc_url( wp_registration_url() ), __( 'Register' ) );
     630
     631                        echo esc_html( $login_link_separator );
     632
     633                        /** This filter is documented in wp-includes/general-template.php */
     634                        echo apply_filters( 'register', $registration_url );
    635635        endif;
    636         ?>
     636                ?>
    637637        </p>
    638638
    639         <?php
    640         login_footer( 'user_login' );
    641 
    642         if ( $switched_locale ) {
    643                 restore_previous_locale();
    644         }
     639                <?php
     640                login_footer( 'user_login' );
     641
     642                if ( $switched_locale ) {
     643                        restore_previous_locale();
     644                }
    645645
    646646                break;
     
    706706                login_header( __( 'Reset Password' ), '<p class="message reset-pass">' . __( 'Enter your new password below.' ) . '</p>', $errors );
    707707
    708         ?>
     708                ?>
    709709        <form name="resetpassform" id="resetpassform" action="<?php echo esc_url( network_site_url( 'wp-login.php?action=resetpass', 'login_post' ) ); ?>" method="post" autocomplete="off">
    710710        <input type="hidden" id="user_login" value="<?php echo esc_attr( $rp_login ); ?>" autocomplete="off" />
     
    740740        <br class="clear" />
    741741
    742         <?php
    743         /**
    744         * Fires following the 'Strength indicator' meter in the user password reset form.
    745         *
    746         * @since 3.9.0
    747         *
    748         * @param WP_User $user User object of the user whose password is being reset.
    749         */
    750         do_action( 'resetpass_form', $user );
    751         ?>
     742                <?php
     743                /**
     744                * Fires following the 'Strength indicator' meter in the user password reset form.
     745                *
     746                * @since 3.9.0
     747                *
     748                * @param WP_User $user User object of the user whose password is being reset.
     749                */
     750                do_action( 'resetpass_form', $user );
     751                ?>
    752752        <input type="hidden" name="rp_key" value="<?php echo esc_attr( $rp_key ); ?>" />
    753753        <p class="submit"><input type="submit" name="wp-submit" id="wp-submit" class="button button-primary button-large" value="<?php esc_attr_e( 'Reset Password' ); ?>" /></p>
     
    756756        <p id="nav">
    757757        <a href="<?php echo esc_url( wp_login_url() ); ?>"><?php _e( 'Log in' ); ?></a>
    758         <?php
    759         if ( get_option( 'users_can_register' ) ) :
    760                 $registration_url = sprintf( '<a href="%s">%s</a>', esc_url( wp_registration_url() ), __( 'Register' ) );
    761 
    762                 echo esc_html( $login_link_separator );
    763 
    764                 /** This filter is documented in wp-includes/general-template.php */
    765                 echo apply_filters( 'register', $registration_url );
     758                <?php
     759                if ( get_option( 'users_can_register' ) ) :
     760                        $registration_url = sprintf( '<a href="%s">%s</a>', esc_url( wp_registration_url() ), __( 'Register' ) );
     761
     762                        echo esc_html( $login_link_separator );
     763
     764                        /** This filter is documented in wp-includes/general-template.php */
     765                        echo apply_filters( 'register', $registration_url );
    766766        endif;
    767         ?>
     767                ?>
    768768        </p>
    769769
    770         <?php
    771         login_footer( 'user_pass' );
    772 
    773         if ( $switched_locale ) {
    774                 restore_previous_locale();
    775         }
     770                <?php
     771                login_footer( 'user_pass' );
     772
     773                if ( $switched_locale ) {
     774                        restore_previous_locale();
     775                }
    776776
    777777                break;
     
    825825                $redirect_to = apply_filters( 'registration_redirect', $registration_redirect );
    826826                login_header( __( 'Registration Form' ), '<p class="message register">' . __( 'Register For This Site' ) . '</p>', $errors );
    827         ?>
     827                ?>
    828828        <form name="registerform" id="registerform" action="<?php echo esc_url( site_url( 'wp-login.php?action=register', 'login_post' ) ); ?>" method="post" novalidate="novalidate">
    829829        <p>
     
    835835                <input type="email" name="user_email" id="user_email" class="input" value="<?php echo esc_attr( wp_unslash( $user_email ) ); ?>" size="25" /></label>
    836836        </p>
    837         <?php
    838         /**
    839         * Fires following the 'Email' field in the user registration form.
    840         *
    841         * @since 2.1.0
    842         */
    843         do_action( 'register_form' );
    844         ?>
     837                <?php
     838                /**
     839                * Fires following the 'Email' field in the user registration form.
     840                *
     841                * @since 2.1.0
     842                */
     843                do_action( 'register_form' );
     844                ?>
    845845        <p id="reg_passmail"><?php _e( 'Registration confirmation will be emailed to you.' ); ?></p>
    846846        <br class="clear" />
     
    851851        <p id="nav">
    852852        <a href="<?php echo esc_url( wp_login_url() ); ?>"><?php _e( 'Log in' ); ?></a>
    853         <?php echo esc_html( $login_link_separator ); ?>
     853                <?php echo esc_html( $login_link_separator ); ?>
    854854        <a href="<?php echo esc_url( wp_lostpassword_url() ); ?>"><?php _e( 'Lost your password?' ); ?></a>
    855855        </p>
    856856
    857         <?php
    858         login_footer( 'user_login' );
    859 
    860         if ( $switched_locale ) {
    861                 restore_previous_locale();
    862         }
     857                <?php
     858                login_footer( 'user_login' );
     859
     860                if ( $switched_locale ) {
     861                        restore_previous_locale();
     862                }
    863863
    864864                break;
    865865
    866         case 'confirmaction' :
     866        case 'confirmaction':
    867867                if ( ! isset( $_GET['request_id'] ) ) {
    868868                        wp_die( __( 'Invalid request.' ) );
     
    944944                                /* translators: 1: Browser cookie documentation URL, 2: Support forums URL */
    945945                                $user = new WP_Error(
    946                                         'test_cookie', sprintf(
     946                                        'test_cookie',
     947                                        sprintf(
    947948                                                __( '<strong>ERROR</strong>: Cookies are blocked due to unexpected output. For help, please see <a href="%1$s">this documentation</a> or try the <a href="%2$s">support forums</a>.' ),
    948                                                 __( 'https://codex.wordpress.org/Cookies' ), __( 'https://wordpress.org/support/' )
     949                                                __( 'https://codex.wordpress.org/Cookies' ),
     950                                                __( 'https://wordpress.org/support/' )
    949951                                        )
    950952                                );
     
    953955                                /* translators: %s: Browser cookie documentation URL */
    954956                                $user = new WP_Error(
    955                                         'test_cookie', sprintf(
     957                                        'test_cookie',
     958                                        sprintf(
    956959                                                __( '<strong>ERROR</strong>: Cookies are blocked or not supported by your browser. You must <a href="%s">enable cookies</a> to use WordPress.' ),
    957960                                                __( 'https://codex.wordpress.org/Cookies' )
     
    978981                                $interim_login = 'success';
    979982                                login_header( '', $message );
    980                         ?>
     983                                ?>
    981984                                </div>
    982985                                <?php
    983986                                /** This action is documented in wp-login.php */
    984987                                do_action( 'login_footer' );
    985                         ?>
     988                                ?>
    986989                                <?php if ( $customize_login ) : ?>
    987990                                <script type="text/javascript">setTimeout( function(){ new wp.customize.Messenger({ url: '<?php echo wp_customize_url(); ?>', channel: 'login' }).send('login') }, 1000 );</script>
    988991                        <?php endif; ?>
    989992                                </body></html>
    990         <?php
    991           exit;
     993                                <?php
     994                                exit;
    992995                        }
    993996
     
    10631066                        $aria_describedby_error = '';
    10641067                }
    1065         ?>
     1068                ?>
    10661069
    10671070        <form name="loginform" id="loginform" action="<?php echo esc_url( site_url( 'wp-login.php', 'login_post' ) ); ?>" method="post">
     
    10741077                <input type="password" name="pwd" id="user_pass"<?php echo $aria_describedby_error; ?> class="input" value="" size="20" /></label>
    10751078        </p>
    1076         <?php
    1077         /**
    1078         * Fires following the 'Password' field in the login form.
    1079         *
    1080         * @since 2.1.0
    1081         */
    1082         do_action( 'login_form' );
    1083         ?>
     1079                <?php
     1080                /**
     1081                * Fires following the 'Password' field in the login form.
     1082                *
     1083                * @since 2.1.0
     1084                */
     1085                do_action( 'login_form' );
     1086                ?>
    10841087        <p class="forgetmenot"><label for="rememberme"><input name="rememberme" type="checkbox" id="rememberme" value="forever" <?php checked( $rememberme ); ?> /> <?php esc_html_e( 'Remember Me' ); ?></label></p>
    10851088        <p class="submit">
    10861089                <input type="submit" name="wp-submit" id="wp-submit" class="button button-primary button-large" value="<?php esc_attr_e( 'Log In' ); ?>" />
    1087         <?php   if ( $interim_login ) { ?>
     1090                <?php   if ( $interim_login ) { ?>
    10881091                <input type="hidden" name="interim-login" value="1" />
    10891092        <?php   } else { ?>
    10901093                <input type="hidden" name="redirect_to" value="<?php echo esc_attr( $redirect_to ); ?>" />
    10911094        <?php } ?>
    1092         <?php if ( $customize_login ) : ?>
     1095                <?php if ( $customize_login ) : ?>
    10931096                <input type="hidden" name="customize-login" value="1" />
    10941097        <?php endif; ?>
     
    10971100        </form>
    10981101
    1099         <?php if ( ! $interim_login ) { ?>
     1102                <?php if ( ! $interim_login ) { ?>
    11001103        <p id="nav">
    1101         <?php
    1102         if ( ! isset( $_GET['checkemail'] ) || ! in_array( $_GET['checkemail'], array( 'confirm', 'newpass' ) ) ) :
    1103                 if ( get_option( 'users_can_register' ) ) :
    1104                         $registration_url = sprintf( '<a href="%s">%s</a>', esc_url( wp_registration_url() ), __( 'Register' ) );
    1105 
    1106                         /** This filter is documented in wp-includes/general-template.php */
    1107                         echo apply_filters( 'register', $registration_url );
    1108 
    1109                         echo esc_html( $login_link_separator );
    1110                 endif;
    1111                 ?>
     1104                        <?php
     1105                        if ( ! isset( $_GET['checkemail'] ) || ! in_array( $_GET['checkemail'], array( 'confirm', 'newpass' ) ) ) :
     1106                                if ( get_option( 'users_can_register' ) ) :
     1107                                        $registration_url = sprintf( '<a href="%s">%s</a>', esc_url( wp_registration_url() ), __( 'Register' ) );
     1108
     1109                                        /** This filter is documented in wp-includes/general-template.php */
     1110                                        echo apply_filters( 'register', $registration_url );
     1111
     1112                                        echo esc_html( $login_link_separator );
     1113                                endif;
     1114                                ?>
    11121115                <a href="<?php echo esc_url( wp_lostpassword_url() ); ?>"><?php _e( 'Lost your password?' ); ?></a>
    1113         <?php endif; ?>
     1116                        <?php endif; ?>
    11141117        </p>
    11151118        <?php } ?>
     
    11181121        function wp_attempt_focus(){
    11191122        setTimeout( function(){ try{
    1120         <?php if ( $user_login ) { ?>
     1123                <?php if ( $user_login ) { ?>
    11211124        d = document.getElementById('user_pass');
    11221125        d.value = '';
     
    11261129        if( d.value != '' )
    11271130        d.value = '';
    1128         <?php
     1131                <?php
    11291132}
    11301133}
     
    11361139        }
    11371140
    1138         <?php
    1139         /**
    1140         * Filters whether to print the call to `wp_attempt_focus()` on the login screen.
    1141         *
    1142         * @since 4.8.0
    1143         *
    1144         * @param bool $print Whether to print the function call. Default true.
    1145         */
    1146         if ( apply_filters( 'enable_login_autofocus', true ) && ! $error ) {
    1147 ?>
     1141                <?php
     1142                /**
     1143                * Filters whether to print the call to `wp_attempt_focus()` on the login screen.
     1144                *
     1145                * @since 4.8.0
     1146                *
     1147                * @param bool $print Whether to print the function call. Default true.
     1148                */
     1149                if ( apply_filters( 'enable_login_autofocus', true ) && ! $error ) {
     1150                        ?>
    11481151        wp_attempt_focus();
    1149         <?php } ?>
     1152                <?php } ?>
    11501153        if(typeof wpOnload=='function')wpOnload();
    1151         <?php if ( $interim_login ) { ?>
     1154                <?php if ( $interim_login ) { ?>
    11521155        (function(){
    11531156        try {
     
    11621165        </script>
    11631166
    1164         <?php
    1165         login_footer();
    1166 
    1167         if ( $switched_locale ) {
    1168                 restore_previous_locale();
    1169         }
     1167                <?php
     1168                login_footer();
     1169
     1170                if ( $switched_locale ) {
     1171                        restore_previous_locale();
     1172                }
    11701173
    11711174                break;
Note: See TracChangeset for help on using the changeset viewer.