Make WordPress Core


Ignore:
Timestamp:
08/17/2018 01:50:26 AM (7 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-admin/users.php

    r42875 r43571  
    207207                'delete_count' => $delete_count,
    208208                'update'       => $update,
    209             ), $redirect
     209            ),
     210            $redirect
    210211        );
    211212        wp_redirect( $redirect );
     
    246247
    247248        include( ABSPATH . 'wp-admin/admin-header.php' );
    248     ?>
     249        ?>
    249250    <form method="post" name="updateusers" id="updateusers">
    250     <?php wp_nonce_field( 'delete-users' ); ?>
    251 <?php echo $referer; ?>
     251        <?php wp_nonce_field( 'delete-users' ); ?>
     252        <?php echo $referer; ?>
    252253
    253254<div class="wrap">
    254255<h1><?php _e( 'Delete Users' ); ?></h1>
    255 <?php if ( isset( $_REQUEST['error'] ) ) : ?>
     256        <?php if ( isset( $_REQUEST['error'] ) ) : ?>
    256257    <div class="error">
    257258        <p><strong><?php _e( 'ERROR:' ); ?></strong> <?php _e( 'Please select an option.' ); ?></p>
    258259    </div>
    259 <?php endif; ?>
    260 
    261 <?php if ( 1 == count( $userids ) ) : ?>
     260        <?php endif; ?>
     261
     262        <?php if ( 1 == count( $userids ) ) : ?>
    262263    <p><?php _e( 'You have specified this user for deletion:' ); ?></p>
    263 <?php else : ?>
     264        <?php else : ?>
    264265    <p><?php _e( 'You have specified these users for deletion:' ); ?></p>
    265 <?php endif; ?>
     266        <?php endif; ?>
    266267
    267268<ul>
    268 <?php
    269     $go_delete = 0;
    270 foreach ( $userids as $id ) {
    271     $user = get_userdata( $id );
    272     if ( $id == $current_user->ID ) {
    273         /* translators: 1: user id, 2: user login */
    274         echo '<li>' . sprintf( __( 'ID #%1$s: %2$s <strong>The current user will not be deleted.</strong>' ), $id, $user->user_login ) . "</li>\n";
    275     } else {
    276         /* translators: 1: user id, 2: user login */
    277         echo '<li><input type="hidden" name="users[]" value="' . esc_attr( $id ) . '" />' . sprintf( __( 'ID #%1$s: %2$s' ), $id, $user->user_login ) . "</li>\n";
    278         $go_delete++;
    279     }
    280 }
    281     ?>
     269        <?php
     270        $go_delete = 0;
     271        foreach ( $userids as $id ) {
     272            $user = get_userdata( $id );
     273            if ( $id == $current_user->ID ) {
     274                /* translators: 1: user id, 2: user login */
     275                echo '<li>' . sprintf( __( 'ID #%1$s: %2$s <strong>The current user will not be deleted.</strong>' ), $id, $user->user_login ) . "</li>\n";
     276            } else {
     277                /* translators: 1: user id, 2: user login */
     278                echo '<li><input type="hidden" name="users[]" value="' . esc_attr( $id ) . '" />' . sprintf( __( 'ID #%1$s: %2$s' ), $id, $user->user_login ) . "</li>\n";
     279                $go_delete++;
     280            }
     281        }
     282        ?>
    282283    </ul>
    283     <?php
    284     if ( $go_delete ) :
    285 
    286         if ( ! $users_have_content ) :
    287     ?>
     284        <?php
     285        if ( $go_delete ) :
     286
     287            if ( ! $users_have_content ) :
     288                ?>
    288289            <input type="hidden" name="delete_option" value="delete" />
    289         <?php else : ?>
     290            <?php else : ?>
    290291        <?php if ( 1 == $go_delete ) : ?>
    291292            <fieldset><p><legend><?php _e( 'What should be done with content owned by this user?' ); ?></legend></p>
     
    321322     */
    322323    do_action( 'delete_user_form', $current_user, $userids );
    323     ?>
     324?>
    324325    <input type="hidden" name="action" value="dodelete" />
    325     <?php submit_button( __( 'Confirm Deletion' ), 'primary' ); ?>
     326            <?php submit_button( __( 'Confirm Deletion' ), 'primary' ); ?>
    326327    <?php else : ?>
    327328    <p><?php _e( 'There are no valid users selected for deletion.' ); ?></p>
     
    329330    </div>
    330331    </form>
    331     <?php
     332        <?php
    332333
    333334        break;
     
    388389
    389390        include( ABSPATH . 'wp-admin/admin-header.php' );
    390     ?>
     391        ?>
    391392    <form method="post" name="updateusers" id="updateusers">
    392     <?php wp_nonce_field( 'remove-users' ); ?>
    393 <?php echo $referer; ?>
     393        <?php wp_nonce_field( 'remove-users' ); ?>
     394        <?php echo $referer; ?>
    394395
    395396<div class="wrap">
    396397<h1><?php _e( 'Remove Users from Site' ); ?></h1>
    397398
    398 <?php if ( 1 == count( $userids ) ) : ?>
     399        <?php if ( 1 == count( $userids ) ) : ?>
    399400    <p><?php _e( 'You have specified this user for removal:' ); ?></p>
    400 <?php else : ?>
     401        <?php else : ?>
    401402    <p><?php _e( 'You have specified these users for removal:' ); ?></p>
    402 <?php endif; ?>
     403        <?php endif; ?>
    403404
    404405<ul>
    405 <?php
    406     $go_remove = false;
    407 foreach ( $userids as $id ) {
    408     $id   = (int) $id;
    409     $user = get_userdata( $id );
    410     if ( ! current_user_can( 'remove_user', $id ) ) {
    411         /* translators: 1: user id, 2: user login */
    412         echo '<li>' . sprintf( __( 'ID #%1$s: %2$s <strong>Sorry, you are not allowed to remove this user.</strong>' ), $id, $user->user_login ) . "</li>\n";
    413     } else {
    414         /* translators: 1: user id, 2: user login */
    415         echo "<li><input type=\"hidden\" name=\"users[]\" value=\"{$id}\" />" . sprintf( __( 'ID #%1$s: %2$s' ), $id, $user->user_login ) . "</li>\n";
    416         $go_remove = true;
    417     }
    418 }
    419     ?>
     406        <?php
     407        $go_remove = false;
     408        foreach ( $userids as $id ) {
     409            $id   = (int) $id;
     410            $user = get_userdata( $id );
     411            if ( ! current_user_can( 'remove_user', $id ) ) {
     412                /* translators: 1: user id, 2: user login */
     413                echo '<li>' . sprintf( __( 'ID #%1$s: %2$s <strong>Sorry, you are not allowed to remove this user.</strong>' ), $id, $user->user_login ) . "</li>\n";
     414            } else {
     415                /* translators: 1: user id, 2: user login */
     416                echo "<li><input type=\"hidden\" name=\"users[]\" value=\"{$id}\" />" . sprintf( __( 'ID #%1$s: %2$s' ), $id, $user->user_login ) . "</li>\n";
     417                $go_remove = true;
     418            }
     419        }
     420        ?>
    420421    </ul>
    421     <?php if ( $go_remove ) : ?>
     422        <?php if ( $go_remove ) : ?>
    422423        <input type="hidden" name="action" value="doremove" />
    423         <?php submit_button( __( 'Confirm Removal' ), 'primary' ); ?>
     424            <?php submit_button( __( 'Confirm Removal' ), 'primary' ); ?>
    424425    <?php else : ?>
    425426    <p><?php _e( 'There are no valid users selected for removal.' ); ?></p>
     
    427428    </div>
    428429    </form>
    429     <?php
     430        <?php
    430431
    431432        break;
     
    477478                            esc_url(
    478479                                add_query_arg(
    479                                     'wp_http_referer', urlencode( wp_unslash( $_SERVER['REQUEST_URI'] ) ),
     480                                    'wp_http_referer',
     481                                    urlencode( wp_unslash( $_SERVER['REQUEST_URI'] ) ),
    480482                                    self_admin_url( 'user-edit.php?user_id=' . $user_id )
    481483                                )
     
    506508            }
    507509        endif;
    508     ?>
    509 
    510     <?php if ( isset( $errors ) && is_wp_error( $errors ) ) : ?>
     510        ?>
     511
     512        <?php if ( isset( $errors ) && is_wp_error( $errors ) ) : ?>
    511513        <div class="error">
    512514            <ul>
     
    518520            </ul>
    519521        </div>
    520     <?php
     522            <?php
    521523    endif;
    522524
     
    530532    <div class="wrap">
    531533    <h1 class="wp-heading-inline">
    532 <?php
    533 echo esc_html( $title );
    534 ?>
     534        <?php
     535        echo esc_html( $title );
     536        ?>
    535537</h1>
    536538
    537 <?php
    538 if ( current_user_can( 'create_users' ) ) {
    539 ?>
     539        <?php
     540        if ( current_user_can( 'create_users' ) ) {
     541            ?>
    540542    <a href="<?php echo admin_url( 'user-new.php' ); ?>" class="page-title-action"><?php echo esc_html_x( 'Add New', 'user' ); ?></a>
    541543<?php } elseif ( is_multisite() && current_user_can( 'promote_users' ) ) { ?>
    542544    <a href="<?php echo admin_url( 'user-new.php' ); ?>" class="page-title-action"><?php echo esc_html_x( 'Add Existing', 'user' ); ?></a>
    543 <?php
     545            <?php
    544546}
    545547
     
    552554<hr class="wp-header-end">
    553555
    554 <?php $wp_list_table->views(); ?>
     556        <?php $wp_list_table->views(); ?>
    555557
    556558<form method="get">
    557559
    558 <?php $wp_list_table->search_box( __( 'Search Users' ), 'user' ); ?>
    559 
    560 <?php if ( ! empty( $_REQUEST['role'] ) ) { ?>
     560        <?php $wp_list_table->search_box( __( 'Search Users' ), 'user' ); ?>
     561
     562        <?php if ( ! empty( $_REQUEST['role'] ) ) { ?>
    561563<input type="hidden" name="role" value="<?php echo esc_attr( $_REQUEST['role'] ); ?>" />
    562564<?php } ?>
    563565
    564 <?php $wp_list_table->display(); ?>
     566        <?php $wp_list_table->display(); ?>
    565567</form>
    566568
    567569<br class="clear" />
    568570</div>
    569 <?php
     571        <?php
    570572        break;
    571573
Note: See TracChangeset for help on using the changeset viewer.