Make WordPress Core


Ignore:
Timestamp:
08/17/2018 01:50:26 AM (6 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/includes/class-wp-comments-list-table.php

    r42871 r43571  
    159159        $total_comments = get_comments(
    160160            array_merge(
    161                 $args, array(
     161                $args,
     162                array(
    162163                    'count'  => true,
    163164                    'offset' => 0,
     
    225226
    226227            /* translators: %s: current user's comments count */
    227             'mine' => _nx_noop(
     228            'mine'      => _nx_noop(
    228229                'Mine <span class="count">(%s)</span>',
    229230                'Mine <span class="count">(%s)</span>',
     
    278279            if ( 'mine' === $status ) {
    279280                $current_user_id    = get_current_user_id();
    280                 $num_comments->mine = get_comments( array(
    281                     'user_id' => $current_user_id,
    282                     'count'   => true,
    283                 ) );
    284                 $link = add_query_arg( 'user_id', $current_user_id, $link );
     281                $num_comments->mine = get_comments(
     282                    array(
     283                        'user_id' => $current_user_id,
     284                        'count'   => true,
     285                    )
     286                );
     287                $link               = add_query_arg( 'user_id', $current_user_id, $link );
    285288            } else {
    286289                $link = remove_query_arg( 'user_id', $link );
     
    368371            $has_items = $this->has_items();
    369372        }
    370 ?>
     373        ?>
    371374        <div class="alignleft actions">
    372 <?php
    373 if ( 'top' === $which ) {
    374 ?>
     375        <?php
     376        if ( 'top' === $which ) {
     377            ?>
    375378    <label class="screen-reader-text" for="filter-by-comment-type"><?php _e( 'Filter by comment type' ); ?></label>
    376379    <select id="filter-by-comment-type" name="comment_type">
    377380        <option value=""><?php _e( 'All comment types' ); ?></option>
    378 <?php
    379         /**
    380          * Filters the comment types dropdown menu.
    381          *
    382          * @since 2.7.0
    383          *
    384          * @param string[] $comment_types An array of comment types. Accepts 'Comments', 'Pings'.
    385          */
    386         $comment_types = apply_filters(
    387             'admin_comment_types_dropdown', array(
    388                 'comment' => __( 'Comments' ),
    389                 'pings'   => __( 'Pings' ),
    390             )
    391         );
    392 
    393 foreach ( $comment_types as $type => $label ) {
    394     echo "\t" . '<option value="' . esc_attr( $type ) . '"' . selected( $comment_type, $type, false ) . ">$label</option>\n";
    395 }
    396     ?>
     381            <?php
     382                /**
     383                 * Filters the comment types dropdown menu.
     384                 *
     385                 * @since 2.7.0
     386                 *
     387                 * @param string[] $comment_types An array of comment types. Accepts 'Comments', 'Pings'.
     388                 */
     389                $comment_types = apply_filters(
     390                    'admin_comment_types_dropdown',
     391                    array(
     392                        'comment' => __( 'Comments' ),
     393                        'pings'   => __( 'Pings' ),
     394                    )
     395                );
     396
     397            foreach ( $comment_types as $type => $label ) {
     398                echo "\t" . '<option value="' . esc_attr( $type ) . '"' . selected( $comment_type, $type, false ) . ">$label</option>\n";
     399            }
     400            ?>
    397401    </select>
    398 <?php
    399     /**
    400     * Fires just before the Filter submit button for comment types.
    401     *
    402     * @since 3.5.0
    403     */
    404     do_action( 'restrict_manage_comments' );
    405     submit_button( __( 'Filter' ), '', 'filter_action', false, array( 'id' => 'post-query-submit' ) );
    406 }
    407 
    408 if ( ( 'spam' === $comment_status || 'trash' === $comment_status ) && current_user_can( 'moderate_comments' ) && $has_items ) {
    409     wp_nonce_field( 'bulk-destroy', '_destroy_nonce' );
    410     $title = ( 'spam' === $comment_status ) ? esc_attr__( 'Empty Spam' ) : esc_attr__( 'Empty Trash' );
    411     submit_button( $title, 'apply', 'delete_all', false );
    412 }
     402            <?php
     403            /**
     404            * Fires just before the Filter submit button for comment types.
     405            *
     406            * @since 3.5.0
     407            */
     408            do_action( 'restrict_manage_comments' );
     409            submit_button( __( 'Filter' ), '', 'filter_action', false, array( 'id' => 'post-query-submit' ) );
     410        }
     411
     412        if ( ( 'spam' === $comment_status || 'trash' === $comment_status ) && current_user_can( 'moderate_comments' ) && $has_items ) {
     413            wp_nonce_field( 'bulk-destroy', '_destroy_nonce' );
     414            $title = ( 'spam' === $comment_status ) ? esc_attr__( 'Empty Spam' ) : esc_attr__( 'Empty Trash' );
     415            submit_button( $title, 'apply', 'delete_all', false );
     416        }
    413417        /**
    414418         * Fires after the Filter submit button for comment types.
     
    491495        $this->screen->render_screen_reader_content( 'heading_list' );
    492496
    493 ?>
     497        ?>
    494498<table class="wp-list-table <?php echo implode( ' ', $this->get_table_classes() ); ?>">
    495499    <thead>
     
    517521
    518522</table>
    519 <?php
     523        <?php
    520524
    521525        $this->display_tablenav( 'bottom' );
     
    677681    public function column_cb( $comment ) {
    678682        if ( $this->user_can ) {
    679         ?>
     683            ?>
    680684        <label class="screen-reader-text" for="cb-select-<?php echo $comment->comment_ID; ?>"><?php _e( 'Select comment' ); ?></label>
    681685        <input id="cb-select-<?php echo $comment->comment_ID; ?>" type="checkbox" name="delete_comments[]" value="<?php echo $comment->comment_ID; ?>" />
    682         <?php
     686            <?php
    683687        }
    684688    }
     
    710714            /** This filter is documented in wp-admin/includes/comment.php */
    711715            $comment_content = apply_filters( 'comment_edit_pre', $comment->comment_content );
    712         ?>
     716            ?>
    713717        <div id="inline-<?php echo $comment->comment_ID; ?>" class="hidden">
    714718            <textarea class="comment" rows="1" cols="1"><?php echo esc_textarea( $comment_content ); ?></textarea>
     
    718722            <div class="comment_status"><?php echo $comment->comment_approved; ?></div>
    719723        </div>
    720         <?php
     724            <?php
    721725        }
    722726    }
     
    760764                        's'    => $author_ip,
    761765                        'mode' => 'detail',
    762                     ), admin_url( 'edit-comments.php' )
     766                    ),
     767                    admin_url( 'edit-comments.php' )
    763768                );
    764769                if ( 'spam' === $comment_status ) {
Note: See TracChangeset for help on using the changeset viewer.