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-content/themes/twentytwelve/image.php

    r42343 r43571  
    1818        while ( have_posts() ) :
    1919            the_post();
    20 ?>
     20            ?>
    2121
    2222                <article id="post-<?php the_ID(); ?>" <?php post_class( 'image-attachment' ); ?>>
     
    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     }
     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                }
    7575endforeach;
    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 :
    84         // or get the URL of the first image attachment
    85         $next_attachment_url = get_attachment_link( $attachments[0]->ID );
    86     endif;
     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 :
     84                    // or get the URL of the first image attachment
     85                    $next_attachment_url = get_attachment_link( $attachments[0]->ID );
     86                endif;
    8787else :
    8888    // or, if there's only 1 image, get the URL of the image
     
    104104                                                    $attachment_size = apply_filters( 'twentytwelve_attachment_size', array( 960, 960 ) );
    105105                                                    echo wp_get_attachment_image( $post->ID, $attachment_size );
    106                                 ?>
     106                                                    ?>
    107107                                </a>
    108108
     
    125125                                )
    126126                            );
    127 ?>
     127                            ?>
    128128                        </div><!-- .entry-description -->
    129129
Note: See TracChangeset for help on using the changeset viewer.