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

    r43569 r43571  
    4040function wp_category_checklist( $post_id = 0, $descendants_and_self = 0, $selected_cats = false, $popular_cats = false, $walker = null, $checked_ontop = true ) {
    4141    wp_terms_checklist(
    42         $post_id, array(
     42        $post_id,
     43        array(
    4344            'taxonomy'             => 'category',
    4445            'descendants_and_self' => $descendants_and_self,
     
    129130    } else {
    130131        $args['popular_cats'] = get_terms(
    131             $taxonomy, array(
     132            $taxonomy,
     133            array(
    132134                'fields'       => 'ids',
    133135                'orderby'      => 'count',
     
    140142    if ( $descendants_and_self ) {
    141143        $categories = (array) get_terms(
    142             $taxonomy, array(
     144            $taxonomy,
     145            array(
    143146                'child_of'     => $descendants_and_self,
    144147                'hierarchical' => 0,
     
    205208
    206209    $terms = get_terms(
    207         $taxonomy, array(
     210        $taxonomy,
     211        array(
    208212            'orderby'      => 'count',
    209213            'order'        => 'DESC',
     
    263267
    264268    $categories = get_terms(
    265         'link_category', array(
     269        'link_category',
     270        array(
    266271            'orderby'    => 'name',
    267272            'hide_empty' => 0,
     
    405410     */
    406411    $content = apply_filters(
    407         'wp_comment_reply', '', array(
     412        'wp_comment_reply',
     413        '',
     414        array(
    408415            'position' => $position,
    409416            'checkbox' => $checkbox,
     
    425432    }
    426433
    427 ?>
     434    ?>
    428435<form method="get">
    429 <?php if ( $table_row ) : ?>
     436    <?php if ( $table_row ) : ?>
    430437<table style="display:none;"><tbody id="com-reply"><tr id="replyrow" class="inline-edit-row" style="display:none;"><td colspan="<?php echo $wp_list_table->get_column_count(); ?>" class="colspanchange">
    431438<?php else : ?>
     
    444451    $quicktags_settings = array( 'buttons' => 'strong,em,link,block,del,ins,img,ul,ol,li,code,close' );
    445452    wp_editor(
    446         '', 'replycontent', array(
     453        '',
     454        'replycontent',
     455        array(
    447456            'media_buttons' => false,
    448457            'tinymce'       => false,
     
    500509    ?>
    501510    </fieldset>
    502 <?php if ( $table_row ) : ?>
     511    <?php if ( $table_row ) : ?>
    503512</td></tr></tbody></table>
    504 <?php else : ?>
     513    <?php else : ?>
    505514</div></div>
    506 <?php endif; ?>
     515    <?php endif; ?>
    507516</form>
    508 <?php
     517    <?php
    509518}
    510519
     
    515524 */
    516525function wp_comment_trashnotice() {
    517 ?>
     526    ?>
    518527<div class="hidden" id="trash-undo-holder">
    519528    <div class="trash-undo-inside"><?php printf( __( 'Comment by %s moved to the trash.' ), '<strong></strong>' ); ?> <span class="undo untrash"><a href="#"><?php _e( 'Undo' ); ?></a></span></div>
     
    522531    <div class="spam-undo-inside"><?php printf( __( 'Comment by %s marked as spam.' ), '<strong></strong>' ); ?> <span class="undo unspam"><a href="#"><?php _e( 'Undo' ); ?></a></span></div>
    523532</div>
    524 <?php
     533    <?php
    525534}
    526535
     
    550559    }
    551560    $count = 0;
    552 ?>
     561    ?>
    553562<table id="list-table">
    554563    <thead>
     
    559568    </thead>
    560569    <tbody id='the-list' data-wp-lists='list:meta'>
    561 <?php
    562 foreach ( $meta as $entry ) {
    563     echo _list_meta_row( $entry, $count );
    564 }
    565 ?>
     570    <?php
     571    foreach ( $meta as $entry ) {
     572        echo _list_meta_row( $entry, $count );
     573    }
     574    ?>
    566575    </tbody>
    567576</table>
    568 <?php
     577    <?php
    569578}
    570579
     
    677686        $meta_key_input_id = 'metakeyinput';
    678687    }
    679 ?>
     688    ?>
    680689<p><strong><?php _e( 'Add New Custom Field:' ); ?></strong></p>
    681690<table id="newmeta">
     
    690699<tr>
    691700<td id="newmetaleft" class="left">
    692 <?php if ( $keys ) { ?>
     701    <?php if ( $keys ) { ?>
    693702<select id="metakeyselect" name="metakeyselect">
    694703<option value="#NONE#"><?php _e( '&mdash; Select &mdash;' ); ?></option>
    695 <?php
    696 
    697 foreach ( $keys as $key ) {
    698     if ( is_protected_meta( $key, 'post' ) || ! current_user_can( 'add_post_meta', $post->ID, $key ) ) {
    699         continue;
    700     }
    701     echo "\n<option value='" . esc_attr( $key ) . "'>" . esc_html( $key ) . '</option>';
    702 }
    703 ?>
     704        <?php
     705
     706        foreach ( $keys as $key ) {
     707            if ( is_protected_meta( $key, 'post' ) || ! current_user_can( 'add_post_meta', $post->ID, $key ) ) {
     708                continue;
     709            }
     710            echo "\n<option value='" . esc_attr( $key ) . "'>" . esc_html( $key ) . '</option>';
     711        }
     712        ?>
    704713</select>
    705714<input class="hide-if-js" type="text" id="metakeyinput" name="metakeyinput" value="" />
     
    716725<tr><td colspan="2">
    717726<div class="submit">
    718 <?php
    719 submit_button(
    720     __( 'Add Custom Field' ), '', 'addmeta', false, array(
    721         'id'            => 'newmeta-submit',
    722         'data-wp-lists' => 'add:the-list:newmeta',
    723     )
    724 );
    725 ?>
     727    <?php
     728    submit_button(
     729        __( 'Add Custom Field' ),
     730        '',
     731        'addmeta',
     732        false,
     733        array(
     734            'id'            => 'newmeta-submit',
     735            'data-wp-lists' => 'add:the-list:newmeta',
     736        )
     737    );
     738    ?>
    726739</div>
    727 <?php wp_nonce_field( 'add-meta', '_ajax_nonce-add-meta', false ); ?>
     740    <?php wp_nonce_field( 'add-meta', '_ajax_nonce-add-meta', false ); ?>
    728741</td></tr>
    729742</tbody>
    730743</table>
    731 <?php
     744    <?php
    732745
    733746}
     
    818831        echo '<input type="hidden" id="' . $cur_timeunit . '" name="' . $cur_timeunit . '" value="' . $curr . '" />' . "\n";
    819832    }
    820 ?>
     833    ?>
    821834
    822835<p>
     
    824837<a href="#edit_timestamp" class="cancel-timestamp hide-if-no-js button-cancel"><?php _e( 'Cancel' ); ?></a>
    825838</p>
    826 <?php
     839    <?php
    827840}
    828841
     
    935948                                <?php
    936949    else :
    937 ?>
     950        ?>
    938951<form enctype="multipart/form-data" id="import-upload-form" method="post" class="wp-upload-form" action="<?php echo esc_url( wp_nonce_url( $action, 'import-upload' ) ); ?>">
    939952<p>
     
    943956<input type="hidden" name="max_file_size" value="<?php echo $bytes; ?>" />
    944957</p>
    945 <?php submit_button( __( 'Upload file and import' ), 'primary' ); ?>
     958        <?php submit_button( __( 'Upload file and import' ), 'primary' ); ?>
    946959</form>
    947 <?php
     960        <?php
    948961    endif;
    949962}
     
    12441257    $page = $screen->id;
    12451258
    1246     $hidden     = get_hidden_meta_boxes( $screen );
     1259    $hidden = get_hidden_meta_boxes( $screen );
    12471260    ?>
    12481261    <div id="side-sortables" class="accordion-container">
     
    13181331    if ( 'misc' == $page ) {
    13191332        _deprecated_argument(
    1320             __FUNCTION__, '3.0.0',
     1333            __FUNCTION__,
     1334            '3.0.0',
    13211335            /* translators: %s: misc */
    13221336            sprintf(
     
    13301344    if ( 'privacy' == $page ) {
    13311345        _deprecated_argument(
    1332             __FUNCTION__, '3.5.0',
     1346            __FUNCTION__,
     1347            '3.5.0',
    13331348            /* translators: %s: privacy */
    13341349            sprintf(
     
    13871402    if ( 'misc' == $page ) {
    13881403        _deprecated_argument(
    1389             __FUNCTION__, '3.0.0',
     1404            __FUNCTION__,
     1405            '3.0.0',
    13901406            /* translators: %s: misc */
    13911407            sprintf(
     
    13991415    if ( 'privacy' == $page ) {
    14001416        _deprecated_argument(
    1401             __FUNCTION__, '3.5.0',
     1417            __FUNCTION__,
     1418            '3.5.0',
    14021419            /* translators: %s: privacy */
    14031420            sprintf(
     
    16511668 */
    16521669function find_posts_div( $found_action = '' ) {
    1653 ?>
     1670    ?>
    16541671    <div id="find-posts" class="find-box" style="display: none;">
    16551672        <div id="find-posts-head" class="find-box-head">
     
    16771694        </div>
    16781695    </div>
    1679 <?php
     1696    <?php
    16801697}
    16811698
     
    17461763    @header( 'Content-Type: ' . get_option( 'html_type' ) . '; charset=' . get_option( 'blog_charset' ) );
    17471764    _wp_admin_html_begin();
    1748 ?>
     1765    ?>
    17491766<title><?php bloginfo( 'name' ); ?> &rsaquo; <?php echo $title; ?> &#8212; <?php _e( 'WordPress' ); ?></title>
    1750 <?php
    1751 wp_enqueue_style( 'colors' );
    1752 ?>
     1767    <?php
     1768    wp_enqueue_style( 'colors' );
     1769    ?>
    17531770<script type="text/javascript">
    17541771addLoadEvent = function(func){if(typeof jQuery!="undefined")jQuery(document).ready(func);else if(typeof wpOnload!='function'){wpOnload=func;}else{var oldonload=wpOnload;wpOnload=function(){oldonload();func();}}};
     
    17621779    isRtl = <?php echo (int) is_rtl(); ?>;
    17631780</script>
    1764 <?php
    1765 /** This action is documented in wp-admin/admin-header.php */
    1766 do_action( 'admin_enqueue_scripts', $hook_suffix );
    1767 
    1768 /** This action is documented in wp-admin/admin-header.php */
    1769 do_action( "admin_print_styles-$hook_suffix" );
    1770 
    1771 /** This action is documented in wp-admin/admin-header.php */
    1772 do_action( 'admin_print_styles' );
    1773 
    1774 /** This action is documented in wp-admin/admin-header.php */
    1775 do_action( "admin_print_scripts-$hook_suffix" );
    1776 
    1777 /** This action is documented in wp-admin/admin-header.php */
    1778 do_action( 'admin_print_scripts' );
    1779 
    1780 /** This action is documented in wp-admin/admin-header.php */
    1781 do_action( "admin_head-$hook_suffix" );
    1782 
    1783 /** This action is documented in wp-admin/admin-header.php */
    1784 do_action( 'admin_head' );
    1785 
    1786 $admin_body_class .= ' locale-' . sanitize_html_class( strtolower( str_replace( '_', '-', get_user_locale() ) ) );
    1787 
    1788 if ( is_rtl() ) {
    1789     $admin_body_class .= ' rtl';
    1790 }
    1791 
    1792 ?>
     1781    <?php
     1782    /** This action is documented in wp-admin/admin-header.php */
     1783    do_action( 'admin_enqueue_scripts', $hook_suffix );
     1784
     1785    /** This action is documented in wp-admin/admin-header.php */
     1786    do_action( "admin_print_styles-$hook_suffix" );
     1787
     1788    /** This action is documented in wp-admin/admin-header.php */
     1789    do_action( 'admin_print_styles' );
     1790
     1791    /** This action is documented in wp-admin/admin-header.php */
     1792    do_action( "admin_print_scripts-$hook_suffix" );
     1793
     1794    /** This action is documented in wp-admin/admin-header.php */
     1795    do_action( 'admin_print_scripts' );
     1796
     1797    /** This action is documented in wp-admin/admin-header.php */
     1798    do_action( "admin_head-$hook_suffix" );
     1799
     1800    /** This action is documented in wp-admin/admin-header.php */
     1801    do_action( 'admin_head' );
     1802
     1803    $admin_body_class .= ' locale-' . sanitize_html_class( strtolower( str_replace( '_', '-', get_user_locale() ) ) );
     1804
     1805    if ( is_rtl() ) {
     1806        $admin_body_class .= ' rtl';
     1807    }
     1808
     1809    ?>
    17931810</head>
    1794 <?php
    1795 /** This filter is documented in wp-admin/admin-header.php */
    1796 $admin_body_classes = apply_filters( 'admin_body_class', '' );
    1797 $admin_body_classes = ltrim( $admin_body_classes . ' ' . $admin_body_class );
    1798 ?>
     1811    <?php
     1812    /** This filter is documented in wp-admin/admin-header.php */
     1813    $admin_body_classes = apply_filters( 'admin_body_class', '' );
     1814    $admin_body_classes = ltrim( $admin_body_classes . ' ' . $admin_body_class );
     1815    ?>
    17991816<body
    1800 <?php
    1801 /**
    1802  * @global string $body_id
    1803  */
    1804 if ( isset( $GLOBALS['body_id'] ) ) {
    1805     echo ' id="' . $GLOBALS['body_id'] . '"';
    1806 }
    1807 ?>
     1817    <?php
     1818    /**
     1819    * @global string $body_id
     1820    */
     1821    if ( isset( $GLOBALS['body_id'] ) ) {
     1822        echo ' id="' . $GLOBALS['body_id'] . '"';
     1823    }
     1824    ?>
    18081825 class="wp-admin wp-core-ui no-js iframe <?php echo $admin_body_classes; ?>">
    18091826<script type="text/javascript">
     
    18141831})();
    18151832</script>
    1816 <?php
     1833    <?php
    18171834}
    18181835
     
    18351852    ?>
    18361853    <div class="hidden">
    1837 <?php
     1854    <?php
    18381855    /** This action is documented in wp-admin/admin-footer.php */
    18391856    do_action( 'admin_footer', $hook_suffix );
     
    18441861    /** This action is documented in wp-admin/admin-footer.php */
    18451862    do_action( 'admin_print_footer_scripts' );
    1846 ?>
     1863    ?>
    18471864    </div>
    18481865<script type="text/javascript">if(typeof wpOnload=="function")wpOnload();</script>
    18491866</body>
    18501867</html>
    1851 <?php
     1868    <?php
    18521869}
    18531870
     
    20142031 */
    20152032function compression_test() {
    2016 ?>
     2033    ?>
    20172034    <script type="text/javascript">
    20182035    var compressionNonce = <?php echo wp_json_encode( wp_create_nonce( 'update_can_compress_scripts' ) ); ?>;
     
    20642081    testCompression.check();
    20652082    </script>
    2066 <?php
     2083    <?php
    20672084}
    20682085
     
    21742191    }
    21752192
    2176 ?>
     2193    ?>
    21772194<!DOCTYPE html>
    21782195<!--[if IE 8]>
     
    22022219<head>
    22032220<meta http-equiv="Content-Type" content="<?php bloginfo( 'html_type' ); ?>; charset=<?php echo get_option( 'blog_charset' ); ?>" />
    2204 <?php
     2221    <?php
    22052222}
    22062223
Note: See TracChangeset for help on using the changeset viewer.