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/update-core.php

    r43569 r43571  
    137137        $show_text = esc_js( __( 'Show hidden updates' ) );
    138138        $hide_text = esc_js( __( 'Hide hidden updates' ) );
    139     ?>
     139        ?>
    140140    <script type="text/javascript">
    141141        jQuery(function( $ ) {
     
    145145        });
    146146    </script>
    147     <?php
     147        <?php
    148148        echo '<p class="hide-if-no-js"><button type="button" class="button" id="show-dismissed" aria-expanded="false">' . __( 'Show hidden updates' ) . '</button></p>';
    149149        echo '<ul id="dismissed-updates" class="core-updates dismissed">';
    150     foreach ( (array) $dismissed as $update ) {
    151         echo '<li>';
    152         list_core_update( $update );
    153         echo '</li>';
    154     }
     150        foreach ( (array) $dismissed as $update ) {
     151            echo '<li>';
     152            list_core_update( $update );
     153            echo '</li>';
     154        }
    155155        echo '</ul>';
    156156    }
     
    250250<p><?php _e( 'The following plugins have new versions available. Check the ones you want to update and then click &#8220;Update Plugins&#8221;.' ); ?></p>
    251251<form method="post" action="<?php echo esc_url( $form_action ); ?>" name="upgrade-plugins" class="upgrade">
    252 <?php wp_nonce_field( 'upgrade-core' ); ?>
     252    <?php wp_nonce_field( 'upgrade-core' ); ?>
    253253<p><input id="upgrade-plugins" class="button" type="submit" value="<?php esc_attr_e( 'Update Plugins' ); ?>" name="upgrade" /></p>
    254254<table class="widefat updates-table" id="update-plugins-table">
     
    261261
    262262    <tbody class="plugins">
    263 <?php
    264 foreach ( (array) $plugins as $plugin_file => $plugin_data ) {
    265     $plugin_data = (object) _get_plugin_data_markup_translate( $plugin_file, (array) $plugin_data, false, true );
    266 
    267     $icon            = '<span class="dashicons dashicons-admin-plugins"></span>';
    268     $preferred_icons = array( 'svg', '2x', '1x', 'default' );
    269     foreach ( $preferred_icons as $preferred_icon ) {
    270         if ( ! empty( $plugin_data->update->icons[ $preferred_icon ] ) ) {
    271             $icon = '<img src="' . esc_url( $plugin_data->update->icons[ $preferred_icon ] ) . '" alt="" />';
    272             break;
    273         }
    274     }
    275 
    276     // Get plugin compat for running version of WordPress.
    277     if ( isset( $plugin_data->update->tested ) && version_compare( $plugin_data->update->tested, $cur_wp_version, '>=' ) ) {
    278         $compat = '<br />' . sprintf( __( 'Compatibility with WordPress %1$s: 100%% (according to its author)' ), $cur_wp_version );
    279     } else {
    280         $compat = '<br />' . sprintf( __( 'Compatibility with WordPress %1$s: Unknown' ), $cur_wp_version );
    281     }
    282     // Get plugin compat for updated version of WordPress.
    283     if ( $core_update_version ) {
    284         if ( isset( $plugin_data->update->tested ) && version_compare( $plugin_data->update->tested, $core_update_version, '>=' ) ) {
    285             $compat .= '<br />' . sprintf( __( 'Compatibility with WordPress %1$s: 100%% (according to its author)' ), $core_update_version );
     263    <?php
     264    foreach ( (array) $plugins as $plugin_file => $plugin_data ) {
     265        $plugin_data = (object) _get_plugin_data_markup_translate( $plugin_file, (array) $plugin_data, false, true );
     266
     267        $icon            = '<span class="dashicons dashicons-admin-plugins"></span>';
     268        $preferred_icons = array( 'svg', '2x', '1x', 'default' );
     269        foreach ( $preferred_icons as $preferred_icon ) {
     270            if ( ! empty( $plugin_data->update->icons[ $preferred_icon ] ) ) {
     271                $icon = '<img src="' . esc_url( $plugin_data->update->icons[ $preferred_icon ] ) . '" alt="" />';
     272                break;
     273            }
     274        }
     275
     276        // Get plugin compat for running version of WordPress.
     277        if ( isset( $plugin_data->update->tested ) && version_compare( $plugin_data->update->tested, $cur_wp_version, '>=' ) ) {
     278            $compat = '<br />' . sprintf( __( 'Compatibility with WordPress %1$s: 100%% (according to its author)' ), $cur_wp_version );
    286279        } else {
    287             $compat .= '<br />' . sprintf( __( 'Compatibility with WordPress %1$s: Unknown' ), $core_update_version );
    288         }
    289     }
    290     // Get the upgrade notice for the new plugin version.
    291     if ( isset( $plugin_data->update->upgrade_notice ) ) {
    292         $upgrade_notice = '<br />' . strip_tags( $plugin_data->update->upgrade_notice );
    293     } else {
    294         $upgrade_notice = '';
    295     }
    296 
    297     $details_url = self_admin_url( 'plugin-install.php?tab=plugin-information&plugin=' . $plugin_data->update->slug . '&section=changelog&TB_iframe=true&width=640&height=662' );
    298     $details     = sprintf(
    299         '<a href="%1$s" class="thickbox open-plugin-details-modal" aria-label="%2$s">%3$s</a>',
    300         esc_url( $details_url ),
    301         /* translators: 1: plugin name, 2: version number */
    302         esc_attr( sprintf( __( 'View %1$s version %2$s details' ), $plugin_data->Name, $plugin_data->update->new_version ) ),
    303         /* translators: %s: plugin version */
    304         sprintf( __( 'View version %s details.' ), $plugin_data->update->new_version )
    305     );
    306 
    307     $checkbox_id = 'checkbox_' . md5( $plugin_data->Name );
    308     ?>
     280            $compat = '<br />' . sprintf( __( 'Compatibility with WordPress %1$s: Unknown' ), $cur_wp_version );
     281        }
     282        // Get plugin compat for updated version of WordPress.
     283        if ( $core_update_version ) {
     284            if ( isset( $plugin_data->update->tested ) && version_compare( $plugin_data->update->tested, $core_update_version, '>=' ) ) {
     285                $compat .= '<br />' . sprintf( __( 'Compatibility with WordPress %1$s: 100%% (according to its author)' ), $core_update_version );
     286            } else {
     287                $compat .= '<br />' . sprintf( __( 'Compatibility with WordPress %1$s: Unknown' ), $core_update_version );
     288            }
     289        }
     290        // Get the upgrade notice for the new plugin version.
     291        if ( isset( $plugin_data->update->upgrade_notice ) ) {
     292            $upgrade_notice = '<br />' . strip_tags( $plugin_data->update->upgrade_notice );
     293        } else {
     294            $upgrade_notice = '';
     295        }
     296
     297        $details_url = self_admin_url( 'plugin-install.php?tab=plugin-information&plugin=' . $plugin_data->update->slug . '&section=changelog&TB_iframe=true&width=640&height=662' );
     298        $details     = sprintf(
     299            '<a href="%1$s" class="thickbox open-plugin-details-modal" aria-label="%2$s">%3$s</a>',
     300            esc_url( $details_url ),
     301            /* translators: 1: plugin name, 2: version number */
     302            esc_attr( sprintf( __( 'View %1$s version %2$s details' ), $plugin_data->Name, $plugin_data->update->new_version ) ),
     303            /* translators: %s: plugin version */
     304            sprintf( __( 'View version %s details.' ), $plugin_data->update->new_version )
     305        );
     306
     307        $checkbox_id = 'checkbox_' . md5( $plugin_data->Name );
     308        ?>
    309309    <tr>
    310310        <td class="check-column">
     
    321321        </td>
    322322        <td class="plugin-title"><p>
    323             <?php echo $icon; ?>
     323                <?php echo $icon; ?>
    324324            <strong><?php echo $plugin_data->Name; ?></strong>
    325325            <?php
     
    330330                $plugin_data->update->new_version
    331331            );
    332             echo ' ' . $details . $compat . $upgrade_notice;
    333         ?>
     332                echo ' ' . $details . $compat . $upgrade_notice;
     333            ?>
    334334        </p></td>
    335335    </tr>
    336         <?php
    337 }
    338 ?>
     336            <?php
     337    }
     338    ?>
    339339    </tbody>
    340340
     
    348348<p><input id="upgrade-plugins-2" class="button" type="submit" value="<?php esc_attr_e( 'Update Plugins' ); ?>" name="upgrade" /></p>
    349349</form>
    350 <?php
     350    <?php
    351351}
    352352
     
    363363
    364364    $form_action = 'update-core.php?action=do-theme-upgrade';
    365 ?>
     365    ?>
    366366<h2><?php _e( 'Themes' ); ?></h2>
    367367<p><?php _e( 'The following themes have new versions available. Check the ones you want to update and then click &#8220;Update Themes&#8221;.' ); ?></p>
    368368<p><?php printf( __( '<strong>Please Note:</strong> Any customizations you have made to theme files will be lost. Please consider using <a href="%s">child themes</a> for modifications.' ), __( 'https://codex.wordpress.org/Child_Themes' ) ); ?></p>
    369369<form method="post" action="<?php echo esc_url( $form_action ); ?>" name="upgrade-themes" class="upgrade">
    370 <?php wp_nonce_field( 'upgrade-core' ); ?>
     370    <?php wp_nonce_field( 'upgrade-core' ); ?>
    371371<p><input id="upgrade-themes" class="button" type="submit" value="<?php esc_attr_e( 'Update Themes' ); ?>" name="upgrade" /></p>
    372372<table class="widefat updates-table" id="update-themes-table">
     
    379379
    380380    <tbody class="plugins">
    381 <?php
    382 foreach ( $themes as $stylesheet => $theme ) {
    383     $checkbox_id = 'checkbox_' . md5( $theme->get( 'Name' ) );
    384     ?>
     381    <?php
     382    foreach ( $themes as $stylesheet => $theme ) {
     383        $checkbox_id = 'checkbox_' . md5( $theme->get( 'Name' ) );
     384        ?>
    385385    <tr>
    386386        <td class="check-column">
     
    406406                $theme->update['new_version']
    407407            );
    408         ?>
     408            ?>
    409409        </p></td>
    410410    </tr>
    411         <?php
    412 }
    413 ?>
     411            <?php
     412    }
     413    ?>
    414414    </tbody>
    415415
     
    423423<p><input id="upgrade-themes-2" class="button" type="submit" value="<?php esc_attr_e( 'Update Themes' ); ?>" name="upgrade" /></p>
    424424</form>
    425 <?php
     425    <?php
    426426}
    427427
     
    482482    $allow_relaxed_file_ownership = ! $reinstall && isset( $update->new_files ) && ! $update->new_files;
    483483
    484 ?>
     484    ?>
    485485    <div class="wrap">
    486486    <h1><?php _e( 'Update WordPress' ); ?></h1>
    487 <?php
    488 
    489 if ( false === ( $credentials = request_filesystem_credentials( $url, '', false, ABSPATH, array( 'version', 'locale' ), $allow_relaxed_file_ownership ) ) ) {
    490     echo '</div>';
    491     return;
    492 }
    493 
    494 if ( ! WP_Filesystem( $credentials, ABSPATH, $allow_relaxed_file_ownership ) ) {
    495     // Failed to connect, Error and request again
    496     request_filesystem_credentials( $url, '', true, ABSPATH, array( 'version', 'locale' ), $allow_relaxed_file_ownership );
    497     echo '</div>';
    498     return;
    499 }
    500 
    501 if ( $wp_filesystem->errors->has_errors() ) {
    502     foreach ( $wp_filesystem->errors->get_error_messages() as $message ) {
    503         show_message( $message );
    504     }
    505     echo '</div>';
    506     return;
    507 }
    508 
    509 if ( $reinstall ) {
    510     $update->response = 'reinstall';
    511 }
     487    <?php
     488
     489    if ( false === ( $credentials = request_filesystem_credentials( $url, '', false, ABSPATH, array( 'version', 'locale' ), $allow_relaxed_file_ownership ) ) ) {
     490        echo '</div>';
     491        return;
     492    }
     493
     494    if ( ! WP_Filesystem( $credentials, ABSPATH, $allow_relaxed_file_ownership ) ) {
     495        // Failed to connect, Error and request again
     496        request_filesystem_credentials( $url, '', true, ABSPATH, array( 'version', 'locale' ), $allow_relaxed_file_ownership );
     497        echo '</div>';
     498        return;
     499    }
     500
     501    if ( $wp_filesystem->errors->has_errors() ) {
     502        foreach ( $wp_filesystem->errors->get_error_messages() as $message ) {
     503            show_message( $message );
     504        }
     505        echo '</div>';
     506        return;
     507    }
     508
     509    if ( $reinstall ) {
     510        $update->response = 'reinstall';
     511    }
    512512
    513513    add_filter( 'update_feedback', 'show_message' );
     
    515515    $upgrader = new Core_Upgrader();
    516516    $result   = $upgrader->upgrade(
    517         $update, array(
     517        $update,
     518        array(
    518519            'allow_relaxed_file_ownership' => $allow_relaxed_file_ownership,
    519520        )
    520521    );
    521522
    522 if ( is_wp_error( $result ) ) {
    523     show_message( $result );
    524     if ( 'up_to_date' != $result->get_error_code() && 'locked' != $result->get_error_code() ) {
    525         show_message( __( 'Installation Failed' ) );
    526     }
    527     echo '</div>';
    528     return;
    529 }
     523    if ( is_wp_error( $result ) ) {
     524        show_message( $result );
     525        if ( 'up_to_date' != $result->get_error_code() && 'locked' != $result->get_error_code() ) {
     526            show_message( __( 'Installation Failed' ) );
     527        }
     528        echo '</div>';
     529        return;
     530    }
    530531
    531532    show_message( __( 'WordPress updated successfully' ) );
     
    669670
    670671    wp_localize_script(
    671         'updates', '_wpUpdatesItemCounts', array(
     672        'updates',
     673        '_wpUpdatesItemCounts',
     674        array(
    672675            'totals' => wp_get_update_data(),
    673676        )
     
    703706
    704707    wp_localize_script(
    705         'updates', '_wpUpdatesItemCounts', array(
     708        'updates',
     709        '_wpUpdatesItemCounts',
     710        array(
    706711            'totals' => wp_get_update_data(),
    707712        )
     
    739744
    740745    wp_localize_script(
    741         'updates', '_wpUpdatesItemCounts', array(
     746        'updates',
     747        '_wpUpdatesItemCounts',
     748        array(
    742749            'totals' => wp_get_update_data(),
    743750        )
     
    777784
    778785    wp_localize_script(
    779         'updates', '_wpUpdatesItemCounts', array(
     786        'updates',
     787        '_wpUpdatesItemCounts',
     788        array(
    780789            'totals' => wp_get_update_data(),
    781790        )
     
    804813
    805814    wp_localize_script(
    806         'updates', '_wpUpdatesItemCounts', array(
     815        'updates',
     816        '_wpUpdatesItemCounts',
     817        array(
    807818            'totals' => wp_get_update_data(),
    808819        )
Note: See TracChangeset for help on using the changeset viewer.