WordPress.org

Make WordPress Core


Ignore:
Timestamp:
08/17/2018 01:50:26 AM (3 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-content/themes/twentyeleven/image.php

    r42343 r43571  
    5252                            <div class="entry-attachment">
    5353                                <div class="attachment">
    54 <?php
    55     /*
    56      * Grab the IDs of all the image attachments in a gallery so we can get the URL of the next adjacent image in a gallery,
    57      * or the first image (if we're looking at the last image in a gallery), or, in a gallery of one, just the link to that image file
    58      */
    59     $attachments = array_values(
    60         get_children(
    61             array(
    62                 'post_parent'    => $post->post_parent,
    63                 'post_status'    => 'inherit',
    64                 'post_type'      => 'attachment',
    65                 'post_mime_type' => 'image',
    66                 'order'          => 'ASC',
    67                 'orderby'        => 'menu_order ID',
    68             )
    69         )
    70     );
    71 foreach ( $attachments as $k => $attachment ) {
    72     if ( $attachment->ID == $post->ID ) {
    73         break;
    74     }
    75 }
     54                <?php
     55                /*
     56                * Grab the IDs of all the image attachments in a gallery so we can get the URL of the next adjacent image in a gallery,
     57                * or the first image (if we're looking at the last image in a gallery), or, in a gallery of one, just the link to that image file
     58                */
     59                $attachments = array_values(
     60                    get_children(
     61                        array(
     62                            'post_parent'    => $post->post_parent,
     63                            'post_status'    => 'inherit',
     64                            'post_type'      => 'attachment',
     65                            'post_mime_type' => 'image',
     66                            'order'          => 'ASC',
     67                            'orderby'        => 'menu_order ID',
     68                        )
     69                    )
     70                );
     71                foreach ( $attachments as $k => $attachment ) {
     72                    if ( $attachment->ID == $post->ID ) {
     73                        break;
     74                    }
     75                }
    7676
    77     // If there is more than 1 attachment in a gallery
    78 if ( count( $attachments ) > 1 ) {
    79     $k++;
    80     if ( isset( $attachments[ $k ] ) ) {
    81         // get the URL of the next image attachment
    82         $next_attachment_url = get_attachment_link( $attachments[ $k ]->ID );
    83     } else {      // or get the URL of the first image attachment
    84         $next_attachment_url = get_attachment_link( $attachments[0]->ID );
    85     }
    86 } else {
    87     // or, if there's only 1 image, get the URL of the image
    88     $next_attachment_url = wp_get_attachment_url();
    89 }
    90 ?>
     77                // If there is more than 1 attachment in a gallery
     78                if ( count( $attachments ) > 1 ) {
     79                    $k++;
     80                    if ( isset( $attachments[ $k ] ) ) {
     81                        // get the URL of the next image attachment
     82                        $next_attachment_url = get_attachment_link( $attachments[ $k ]->ID );
     83                    } else {      // or get the URL of the first image attachment
     84                        $next_attachment_url = get_attachment_link( $attachments[0]->ID );
     85                    }
     86                } else {
     87                    // or, if there's only 1 image, get the URL of the image
     88                    $next_attachment_url = wp_get_attachment_url();
     89                }
     90                ?>
    9191                                    <a href="<?php echo esc_url( $next_attachment_url ); ?>" title="<?php the_title_attribute(); ?>" rel="attachment">
    9292                                                        <?php
     
    100100                                                        $attachment_size = apply_filters( 'twentyeleven_attachment_size', 848 );
    101101                                                        echo wp_get_attachment_image( $post->ID, array( $attachment_size, 1024 ) ); // filterable image width with 1024px limit for image height.
    102                                     ?>
     102                                                        ?>
    103103                                    </a>
    104104
     
    121121                                    )
    122122                                );
    123 ?>
     123                                ?>
    124124                            </div><!-- .entry-description -->
    125125
Note: See TracChangeset for help on using the changeset viewer.