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-admin/widgets.php

    r42790 r43571  
    296296    <form action="widgets.php" method="post">
    297297    <div class="widget-inside">
    298 <?php
    299 if ( is_callable( $control_callback ) ) {
    300     call_user_func_array( $control_callback, $control['params'] );
    301 } else {
    302     echo '<p>' . __( 'There are no options for this widget.' ) . "</p>\n";
    303 }
    304         ?>
     298    <?php
     299    if ( is_callable( $control_callback ) ) {
     300        call_user_func_array( $control_callback, $control['params'] );
     301    } else {
     302        echo '<p>' . __( 'There are no options for this widget.' ) . "</p>\n";
     303    }
     304    ?>
    305305    </div>
    306306
     
    308308    <div class="widget-position">
    309309    <table class="widefat"><thead><tr><th><?php _e( 'Sidebar' ); ?></th><th><?php _e( 'Position' ); ?></th></tr></thead><tbody>
    310 <?php
    311 foreach ( $wp_registered_sidebars as $sbname => $sbvalue ) {
    312     echo "\t\t<tr><td><label><input type='radio' name='sidebar' value='" . esc_attr( $sbname ) . "'" . checked( $sbname, $sidebar, false ) . " /> $sbvalue[name]</label></td><td>";
    313     if ( 'wp_inactive_widgets' == $sbname || 'orphaned_widgets' == substr( $sbname, 0, 16 ) ) {
    314         echo '&nbsp;';
    315     } else {
    316         if ( ! isset( $sidebars_widgets[ $sbname ] ) || ! is_array( $sidebars_widgets[ $sbname ] ) ) {
    317             $j                           = 1;
    318             $sidebars_widgets[ $sbname ] = array();
     310    <?php
     311    foreach ( $wp_registered_sidebars as $sbname => $sbvalue ) {
     312        echo "\t\t<tr><td><label><input type='radio' name='sidebar' value='" . esc_attr( $sbname ) . "'" . checked( $sbname, $sidebar, false ) . " /> $sbvalue[name]</label></td><td>";
     313        if ( 'wp_inactive_widgets' == $sbname || 'orphaned_widgets' == substr( $sbname, 0, 16 ) ) {
     314            echo '&nbsp;';
    319315        } else {
    320             $j = count( $sidebars_widgets[ $sbname ] );
    321             if ( isset( $_GET['addnew'] ) || ! in_array( $widget_id, $sidebars_widgets[ $sbname ], true ) ) {
    322                 $j++;
     316            if ( ! isset( $sidebars_widgets[ $sbname ] ) || ! is_array( $sidebars_widgets[ $sbname ] ) ) {
     317                $j                           = 1;
     318                $sidebars_widgets[ $sbname ] = array();
     319            } else {
     320                $j = count( $sidebars_widgets[ $sbname ] );
     321                if ( isset( $_GET['addnew'] ) || ! in_array( $widget_id, $sidebars_widgets[ $sbname ], true ) ) {
     322                    $j++;
     323                }
    323324            }
    324         }
    325         $selected = '';
    326         echo "\t\t<select name='{$sbname}_position'>\n";
    327         echo "\t\t<option value=''>" . __( '&mdash; Select &mdash;' ) . "</option>\n";
    328         for ( $i = 1; $i <= $j; $i++ ) {
    329             if ( in_array( $widget_id, $sidebars_widgets[ $sbname ], true ) ) {
    330                 $selected = selected( $i, $key + 1, false );
     325            $selected = '';
     326            echo "\t\t<select name='{$sbname}_position'>\n";
     327            echo "\t\t<option value=''>" . __( '&mdash; Select &mdash;' ) . "</option>\n";
     328            for ( $i = 1; $i <= $j; $i++ ) {
     329                if ( in_array( $widget_id, $sidebars_widgets[ $sbname ], true ) ) {
     330                    $selected = selected( $i, $key + 1, false );
     331                }
     332                echo "\t\t<option value='$i'$selected> $i </option>\n";
    331333            }
    332             echo "\t\t<option value='$i'$selected> $i </option>\n";
    333         }
    334         echo "\t\t</select>\n";
    335     }
    336     echo "</td></tr>\n";
    337 }
     334            echo "\t\t</select>\n";
     335        }
     336        echo "</td></tr>\n";
     337    }
    338338    ?>
    339339    </tbody></table>
     
    341341
    342342    <div class="widget-control-actions">
    343 <?php
    344 if ( isset( $_GET['addnew'] ) ) {
    345     ?>
     343    <?php
     344    if ( isset( $_GET['addnew'] ) ) {
     345        ?>
    346346    <a href="widgets.php" class="button alignleft"><?php _e( 'Cancel' ); ?></a>
    347 <?php
    348 } else {
    349     submit_button( __( 'Delete' ), 'alignleft', 'removewidget', false );
    350 }
     347        <?php
     348    } else {
     349        submit_button( __( 'Delete' ), 'alignleft', 'removewidget', false );
     350    }
    351351    submit_button( __( 'Save Widget' ), 'primary alignright', 'savewidget', false );
    352352    ?>
     
    354354    <input type="hidden" name="id_base" class="id_base" value="<?php echo esc_attr( $id_base ); ?>" />
    355355    <input type="hidden" name="multi_number" class="multi_number" value="<?php echo esc_attr( $multi_number ); ?>" />
    356 <?php   wp_nonce_field( "save-delete-widget-$widget_id" ); ?>
     356    <?php   wp_nonce_field( "save-delete-widget-$widget_id" ); ?>
    357357    <br class="clear" />
    358358    </div>
     
    360360    </div>
    361361    </div>
    362 <?php
     362    <?php
    363363    require_once( ABSPATH . 'wp-admin/admin-footer.php' );
    364364    exit;
Note: See TracChangeset for help on using the changeset viewer.