Make WordPress Core


Ignore:
Timestamp:
11/30/2017 11:09:33 PM (8 years ago)
Author:
pento
Message:

Code is Poetry.
WordPress' code just... wasn't.
This is now dealt with.

Props jrf, pento, netweb, GaryJ, jdgrimes, westonruter, Greg Sherwood from PHPCS, and everyone who's ever contributed to WPCS and PHPCS.
Fixes #41057.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/class-walker-comment.php

    r41688 r42343  
    3636     * @todo Decouple this
    3737     */
    38     public $db_fields = array ('parent' => 'comment_parent', 'id' => 'comment_ID');
     38    public $db_fields = array(
     39        'parent' => 'comment_parent',
     40        'id'     => 'comment_ID',
     41    );
    3942
    4043    /**
     
    127130     */
    128131    public function display_element( $element, &$children_elements, $max_depth, $depth, $args, &$output ) {
    129         if ( !$element )
     132        if ( ! $element ) {
    130133            return;
     134        }
    131135
    132136        $id_field = $this->db_fields['id'];
    133         $id = $element->$id_field;
     137        $id       = $element->$id_field;
    134138
    135139        parent::display_element( $element, $children_elements, $max_depth, $depth, $args, $output );
     
    140144         * of the list.
    141145         */
    142         if ( $max_depth <= $depth + 1 && isset( $children_elements[$id]) ) {
    143             foreach ( $children_elements[ $id ] as $child )
     146        if ( $max_depth <= $depth + 1 && isset( $children_elements[ $id ] ) ) {
     147            foreach ( $children_elements[ $id ] as $child ) {
    144148                $this->display_element( $child, $children_elements, $max_depth, $depth, $args, $output );
     149            }
    145150
    146151            unset( $children_elements[ $id ] );
     
    168173        $depth++;
    169174        $GLOBALS['comment_depth'] = $depth;
    170         $GLOBALS['comment'] = $comment;
    171 
    172         if ( !empty( $args['callback'] ) ) {
     175        $GLOBALS['comment']       = $comment;
     176
     177        if ( ! empty( $args['callback'] ) ) {
    173178            ob_start();
    174179            call_user_func( $args['callback'], $comment, $args, $depth );
     
    206211     */
    207212    public function end_el( &$output, $comment, $depth = 0, $args = array() ) {
    208         if ( !empty( $args['end-callback'] ) ) {
     213        if ( ! empty( $args['end-callback'] ) ) {
    209214            ob_start();
    210215            call_user_func( $args['end-callback'], $comment, $args, $depth );
     
    212217            return;
    213218        }
    214         if ( 'div' == $args['style'] )
     219        if ( 'div' == $args['style'] ) {
    215220            $output .= "</div><!-- #comment-## -->\n";
    216         else
     221        } else {
    217222            $output .= "</li><!-- #comment-## -->\n";
     223        }
    218224    }
    219225
     
    252258    protected function comment( $comment, $depth, $args ) {
    253259        if ( 'div' == $args['style'] ) {
    254             $tag = 'div';
     260            $tag       = 'div';
    255261            $add_below = 'comment';
    256262        } else {
    257             $tag = 'li';
     263            $tag       = 'li';
    258264            $add_below = 'div-comment';
    259265        }
     
    264270        <?php endif; ?>
    265271        <div class="comment-author vcard">
    266             <?php if ( 0 != $args['avatar_size'] ) echo get_avatar( $comment, $args['avatar_size'] ); ?>
     272            <?php
     273            if ( 0 != $args['avatar_size'] ) {
     274                echo get_avatar( $comment, $args['avatar_size'] );}
     275?>
    267276            <?php
    268277                /* translators: %s: comment author link */
    269                 printf( __( '%s <span class="says">says:</span>' ),
     278                printf(
     279                    __( '%s <span class="says">says:</span>' ),
    270280                    sprintf( '<cite class="fn">%s</cite>', get_comment_author_link( $comment ) )
    271281                );
     
    273283        </div>
    274284        <?php if ( '0' == $comment->comment_approved ) : ?>
    275         <em class="comment-awaiting-moderation"><?php _e( 'Your comment is awaiting moderation.' ) ?></em>
     285        <em class="comment-awaiting-moderation"><?php _e( 'Your comment is awaiting moderation.' ); ?></em>
    276286        <br />
    277287        <?php endif; ?>
     
    280290            <?php
    281291                /* translators: 1: comment date, 2: comment time */
    282                 printf( __( '%1$s at %2$s' ), get_comment_date( '', $comment ),  get_comment_time() ); ?></a><?php edit_comment_link( __( '(Edit)' ), '&nbsp;&nbsp;', '' );
     292                printf( __( '%1$s at %2$s' ), get_comment_date( '', $comment ), get_comment_time() );
     293                ?>
     294                </a>
     295                <?php
     296                edit_comment_link( __( '(Edit)' ), '&nbsp;&nbsp;', '' );
    283297            ?>
    284298        </div>
    285299
    286         <?php comment_text( $comment, array_merge( $args, array( 'add_below' => $add_below, 'depth' => $depth, 'max_depth' => $args['max_depth'] ) ) ); ?>
    287 
    288300        <?php
    289         comment_reply_link( array_merge( $args, array(
    290             'add_below' => $add_below,
    291             'depth'     => $depth,
    292             'max_depth' => $args['max_depth'],
    293             'before'    => '<div class="reply">',
    294             'after'     => '</div>'
    295         ) ) );
     301        comment_text(
     302            $comment, array_merge(
     303                $args, array(
     304                    'add_below' => $add_below,
     305                    'depth'     => $depth,
     306                    'max_depth' => $args['max_depth'],
     307                )
     308            )
     309        );
     310?>
     311
     312        <?php
     313        comment_reply_link(
     314            array_merge(
     315                $args, array(
     316                    'add_below' => $add_below,
     317                    'depth'     => $depth,
     318                    'max_depth' => $args['max_depth'],
     319                    'before'    => '<div class="reply">',
     320                    'after'     => '</div>',
     321                )
     322            )
     323        );
    296324        ?>
    297325
     
    320348                <footer class="comment-meta">
    321349                    <div class="comment-author vcard">
    322                         <?php if ( 0 != $args['avatar_size'] ) echo get_avatar( $comment, $args['avatar_size'] ); ?>
     350                        <?php
     351                        if ( 0 != $args['avatar_size'] ) {
     352                            echo get_avatar( $comment, $args['avatar_size'] );}
     353?>
    323354                        <?php
    324355                            /* translators: %s: comment author link */
    325                             printf( __( '%s <span class="says">says:</span>' ),
     356                            printf(
     357                                __( '%s <span class="says">says:</span>' ),
    326358                                sprintf( '<b class="fn">%s</b>', get_comment_author_link( $comment ) )
    327359                            );
     
    351383
    352384                <?php
    353                 comment_reply_link( array_merge( $args, array(
    354                     'add_below' => 'div-comment',
    355                     'depth'     => $depth,
    356                     'max_depth' => $args['max_depth'],
    357                     'before'    => '<div class="reply">',
    358                     'after'     => '</div>'
    359                 ) ) );
     385                comment_reply_link(
     386                    array_merge(
     387                        $args, array(
     388                            'add_below' => 'div-comment',
     389                            'depth'     => $depth,
     390                            'max_depth' => $args['max_depth'],
     391                            'before'    => '<div class="reply">',
     392                            'after'     => '</div>',
     393                        )
     394                    )
     395                );
    360396                ?>
    361397            </article><!-- .comment-body -->
Note: See TracChangeset for help on using the changeset viewer.