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/comment.php

    r42343 r43571  
    111111        $nonce_action .= $comment_id;
    112112
    113     ?>
     113        ?>
    114114    <div class="wrap">
    115115
    116116    <h1><?php echo esc_html( $title ); ?></h1>
    117117
    118 <?php
    119 switch ( $action ) {
    120     case 'spam':
    121         $caution_msg = __( 'You are about to mark the following comment as spam:' );
    122         $button      = _x( 'Mark as Spam', 'comment' );
    123         break;
    124     case 'trash':
    125         $caution_msg = __( 'You are about to move the following comment to the Trash:' );
    126         $button      = __( 'Move to Trash' );
    127         break;
    128     case 'delete':
    129         $caution_msg = __( 'You are about to delete the following comment:' );
    130         $button      = __( 'Permanently Delete Comment' );
    131         break;
    132     default:
    133         $caution_msg = __( 'You are about to approve the following comment:' );
    134         $button      = __( 'Approve Comment' );
    135         break;
    136 }
    137 
    138 if ( $comment->comment_approved != '0' ) { // if not unapproved
    139     $message = '';
    140     switch ( $comment->comment_approved ) {
    141         case '1':
    142             $message = __( 'This comment is currently approved.' );
    143             break;
    144         case 'spam':
    145             $message = __( 'This comment is currently marked as spam.' );
    146             break;
    147         case 'trash':
    148             $message = __( 'This comment is currently in the Trash.' );
    149             break;
    150     }
    151     if ( $message ) {
    152         echo '<div id="message" class="notice notice-info"><p>' . $message . '</p></div>';
    153     }
    154 }
    155 ?>
     118        <?php
     119        switch ( $action ) {
     120            case 'spam':
     121                $caution_msg = __( 'You are about to mark the following comment as spam:' );
     122                $button      = _x( 'Mark as Spam', 'comment' );
     123                break;
     124            case 'trash':
     125                $caution_msg = __( 'You are about to move the following comment to the Trash:' );
     126                $button      = __( 'Move to Trash' );
     127                break;
     128            case 'delete':
     129                $caution_msg = __( 'You are about to delete the following comment:' );
     130                $button      = __( 'Permanently Delete Comment' );
     131                break;
     132            default:
     133                $caution_msg = __( 'You are about to approve the following comment:' );
     134                $button      = __( 'Approve Comment' );
     135                break;
     136        }
     137
     138        if ( $comment->comment_approved != '0' ) { // if not unapproved
     139            $message = '';
     140            switch ( $comment->comment_approved ) {
     141                case '1':
     142                    $message = __( 'This comment is currently approved.' );
     143                    break;
     144                case 'spam':
     145                    $message = __( 'This comment is currently marked as spam.' );
     146                    break;
     147                case 'trash':
     148                    $message = __( 'This comment is currently in the Trash.' );
     149                    break;
     150            }
     151            if ( $message ) {
     152                echo '<div id="message" class="notice notice-info"><p>' . $message . '</p></div>';
     153            }
     154        }
     155        ?>
    156156<div id="message" class="notice notice-warning"><p><strong><?php _e( 'Caution:' ); ?></strong> <?php echo $caution_msg; ?></p></div>
    157157
     
    161161<td><?php comment_author( $comment ); ?></td>
    162162</tr>
    163 <?php if ( get_comment_author_email( $comment ) ) { ?>
     163        <?php if ( get_comment_author_email( $comment ) ) { ?>
    164164<tr>
    165165<th scope="row"><?php _e( 'Email' ); ?></th>
     
    167167</tr>
    168168<?php } ?>
    169 <?php if ( get_comment_author_url( $comment ) ) { ?>
     169        <?php if ( get_comment_author_url( $comment ) ) { ?>
    170170<tr>
    171171<th scope="row"><?php _e( 'URL' ); ?></th>
     
    176176    <th scope="row"><?php /* translators: column name or table row header */ _e( 'In Response To' ); ?></th>
    177177    <td>
    178     <?php
     178        <?php
    179179        $post_id = $comment->comment_post_ID;
    180     if ( current_user_can( 'edit_post', $post_id ) ) {
    181         $post_link  = "<a href='" . esc_url( get_edit_post_link( $post_id ) ) . "'>";
    182         $post_link .= esc_html( get_the_title( $post_id ) ) . '</a>';
    183     } else {
    184         $post_link = esc_html( get_the_title( $post_id ) );
    185     }
     180        if ( current_user_can( 'edit_post', $post_id ) ) {
     181            $post_link  = "<a href='" . esc_url( get_edit_post_link( $post_id ) ) . "'>";
     182            $post_link .= esc_html( get_the_title( $post_id ) ) . '</a>';
     183        } else {
     184            $post_link = esc_html( get_the_title( $post_id ) );
     185        }
    186186        echo $post_link;
    187187
    188     if ( $comment->comment_parent ) {
    189         $parent      = get_comment( $comment->comment_parent );
    190         $parent_link = esc_url( get_comment_link( $parent ) );
    191         $name        = get_comment_author( $parent );
    192         printf(
    193             /* translators: %s: comment link */
    194             ' | ' . __( 'In reply to %s.' ),
    195             '<a href="' . $parent_link . '">' . $name . '</a>'
    196         );
    197     }
    198     ?>
     188        if ( $comment->comment_parent ) {
     189            $parent      = get_comment( $comment->comment_parent );
     190            $parent_link = esc_url( get_comment_link( $parent ) );
     191            $name        = get_comment_author( $parent );
     192            printf(
     193                /* translators: %s: comment link */
     194                ' | ' . __( 'In reply to %s.' ),
     195                '<a href="' . $parent_link . '">' . $name . '</a>'
     196            );
     197        }
     198        ?>
    199199    </td>
    200200    </tr>
     
    202202    <th scope="row"><?php _e( 'Submitted on' ); ?></th>
    203203    <td>
    204     <?php
     204        <?php
    205205        /* translators: 1: comment date, 2: comment time */
    206206        $submitted = sprintf(
     
    210210            get_comment_date( __( 'g:i a' ), $comment )
    211211        );
    212     if ( 'approved' === wp_get_comment_status( $comment ) && ! empty( $comment->comment_post_ID ) ) {
    213         echo '<a href="' . esc_url( get_comment_link( $comment ) ) . '">' . $submitted . '</a>';
    214     } else {
    215         echo $submitted;
    216     }
     212        if ( 'approved' === wp_get_comment_status( $comment ) && ! empty( $comment->comment_post_ID ) ) {
     213            echo '<a href="' . esc_url( get_comment_link( $comment ) ) . '">' . $submitted . '</a>';
     214        } else {
     215            echo $submitted;
     216        }
    217217        ?>
    218218        </td>
     
    221221    <th scope="row"><?php /* translators: field name in comment form */ _ex( 'Comment', 'noun' ); ?></th>
    222222    <td class="comment-content">
    223     <?php comment_text( $comment ); ?>
     223        <?php comment_text( $comment ); ?>
    224224    <p class="edit-comment"><a href="<?php echo admin_url( "comment.php?action=editcomment&amp;c={$comment->comment_ID}" ); ?>"><?php esc_html_e( 'Edit' ); ?></a></p>
    225225    </td>
     
    230230
    231231    <p>
    232     <?php submit_button( $button, 'primary', 'submit', false ); ?>
     232        <?php submit_button( $button, 'primary', 'submit', false ); ?>
    233233    <a href="<?php echo admin_url( 'edit-comments.php' ); ?>" class="button-cancel"><?php esc_html_e( 'Cancel' ); ?></a>
    234234    </p>
    235235
    236     <?php wp_nonce_field( $nonce_action ); ?>
     236        <?php wp_nonce_field( $nonce_action ); ?>
    237237    <input type="hidden" name="action" value="<?php echo esc_attr( $formaction ); ?>" />
    238238    <input type="hidden" name="c" value="<?php echo esc_attr( $comment->comment_ID ); ?>" />
     
    241241
    242242    </div>
    243     <?php
     243        <?php
    244244        break;
    245245
     
    291291                        'trashed' => '1',
    292292                        'ids'     => $comment_id,
    293                     ), $redir
     293                    ),
     294                    $redir
    294295                );
    295296                break;
     
    304305                        'spammed' => '1',
    305306                        'ids'     => $comment_id,
    306                     ), $redir
     307                    ),
     308                    $redir
    307309                );
    308310                break;
Note: See TracChangeset for help on using the changeset viewer.