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/edit-form-advanced.php

    r42871 r43571  
    159159$scheduled_date = date_i18n( __( 'M j, Y @ H:i' ), strtotime( $post->post_date ) );
    160160
    161 $messages['post'] = array(
     161$messages['post']       = array(
    162162    0  => '', // Unused. Messages start at index 1.
    163163    1  => __( 'Post updated.' ) . $view_post_link_html,
     
    173173    10 => __( 'Post draft updated.' ) . $preview_post_link_html,
    174174);
    175 $messages['page'] = array(
     175$messages['page']       = array(
    176176    0  => '', // Unused. Messages start at index 1.
    177177    1  => __( 'Page updated.' ) . $view_page_link_html,
     
    395395
    396396add_screen_option(
    397     'layout_columns', array(
     397    'layout_columns',
     398    array(
    398399        'max'     => 2,
    399400        'default' => 2,
     
    587588<?php if ( ! empty( $active_post_lock ) ) { ?>
    588589<input type="hidden" id="active_post_lock" value="<?php echo esc_attr( implode( ':', $active_post_lock ) ); ?>" />
    589 <?php
     590    <?php
    590591}
    591592if ( 'draft' != get_post_status( $post ) ) {
     
    633634    <input type="text" name="post_title" size="30" value="<?php echo esc_attr( $post->post_title ); ?>" id="title" spellcheck="true" autocomplete="off" />
    634635</div>
    635 <?php
    636 /**
    637  * Fires before the permalink field in the edit form.
    638  *
    639  * @since 4.1.0
    640  *
    641  * @param WP_Post $post Post object.
    642  */
    643 do_action( 'edit_form_before_permalink', $post );
    644 ?>
     636    <?php
     637    /**
     638    * Fires before the permalink field in the edit form.
     639    *
     640    * @since 4.1.0
     641    *
     642    * @param WP_Post $post Post object.
     643    */
     644    do_action( 'edit_form_before_permalink', $post );
     645    ?>
    645646<div class="inside">
    646 <?php
    647 if ( $viewable ) :
    648     $sample_permalink_html = $post_type_object->public ? get_sample_permalink_html( $post->ID ) : '';
    649 
    650     // As of 4.4, the Get Shortlink button is hidden by default.
    651     if ( has_filter( 'pre_get_shortlink' ) || has_filter( 'get_shortlink' ) ) {
    652         $shortlink = wp_get_shortlink( $post->ID, 'post' );
    653 
    654         if ( ! empty( $shortlink ) && $shortlink !== $permalink && $permalink !== home_url( '?page_id=' . $post->ID ) ) {
    655             $sample_permalink_html .= '<input id="shortlink" type="hidden" value="' . esc_attr( $shortlink ) . '" /><button type="button" class="button button-small" onclick="prompt(&#39;URL:&#39;, jQuery(\'#shortlink\').val());">' . __( 'Get Shortlink' ) . '</button>';
     647    <?php
     648    if ( $viewable ) :
     649        $sample_permalink_html = $post_type_object->public ? get_sample_permalink_html( $post->ID ) : '';
     650
     651        // As of 4.4, the Get Shortlink button is hidden by default.
     652        if ( has_filter( 'pre_get_shortlink' ) || has_filter( 'get_shortlink' ) ) {
     653            $shortlink = wp_get_shortlink( $post->ID, 'post' );
     654
     655            if ( ! empty( $shortlink ) && $shortlink !== $permalink && $permalink !== home_url( '?page_id=' . $post->ID ) ) {
     656                $sample_permalink_html .= '<input id="shortlink" type="hidden" value="' . esc_attr( $shortlink ) . '" /><button type="button" class="button button-small" onclick="prompt(&#39;URL:&#39;, jQuery(\'#shortlink\').val());">' . __( 'Get Shortlink' ) . '</button>';
     657            }
    656658        }
    657     }
    658 
    659     if ( $post_type_object->public && ! ( 'pending' == get_post_status( $post ) && ! current_user_can( $post_type_object->cap->publish_posts ) ) ) {
    660         $has_sample_permalink = $sample_permalink_html && 'auto-draft' != $post->post_status;
     659
     660        if ( $post_type_object->public && ! ( 'pending' == get_post_status( $post ) && ! current_user_can( $post_type_object->cap->publish_posts ) ) ) {
     661            $has_sample_permalink = $sample_permalink_html && 'auto-draft' != $post->post_status;
     662            ?>
     663    <div id="edit-slug-box" class="hide-if-no-js">
     664            <?php
     665            if ( $has_sample_permalink ) {
     666                echo $sample_permalink_html;
     667            }
     668            ?>
     669    </div>
     670            <?php
     671        }
     672endif;
    661673    ?>
    662     <div id="edit-slug-box" class="hide-if-no-js">
     674</div>
    663675    <?php
    664     if ( $has_sample_permalink ) {
    665         echo $sample_permalink_html;
    666     }
     676    wp_nonce_field( 'samplepermalink', 'samplepermalinknonce', false );
    667677    ?>
    668     </div>
     678</div><!-- /titlediv -->
    669679    <?php
    670     }
    671 endif;
    672 ?>
    673 </div>
    674 <?php
    675 wp_nonce_field( 'samplepermalink', 'samplepermalinknonce', false );
    676 ?>
    677 </div><!-- /titlediv -->
    678 <?php
    679680}
    680681/**
     
    692693        $_wp_editor_expand_class = ' wp-editor-expand';
    693694    }
    694 ?>
     695    ?>
    695696<div id="postdivrich" class="postarea<?php echo $_wp_editor_expand_class; ?>">
    696697
    697 <?php
    698 wp_editor(
    699     $post->post_content, 'content', array(
    700         '_content_editor_dfw' => $_content_editor_dfw,
    701         'drag_drop_upload'    => true,
    702         'tabfocus_elements'   => 'content-html,save-post',
    703         'editor_height'       => 300,
    704         'tinymce'             => array(
    705             'resize'                  => false,
    706             'wp_autoresize_on'        => $_wp_editor_expand,
    707             'add_unload_trigger'      => false,
    708             'wp_keep_scroll_position' => ! $is_IE,
    709         ),
    710     )
    711 );
    712 ?>
     698    <?php
     699    wp_editor(
     700        $post->post_content,
     701        'content',
     702        array(
     703            '_content_editor_dfw' => $_content_editor_dfw,
     704            'drag_drop_upload'    => true,
     705            'tabfocus_elements'   => 'content-html,save-post',
     706            'editor_height'       => 300,
     707            'tinymce'             => array(
     708                'resize'                  => false,
     709                'wp_autoresize_on'        => $_wp_editor_expand,
     710                'add_unload_trigger'      => false,
     711                'wp_keep_scroll_position' => ! $is_IE,
     712            ),
     713        )
     714    );
     715    ?>
    713716<table id="post-status-info"><tbody><tr>
    714717    <td id="wp-word-count" class="hide-if-no-js"><?php printf( __( 'Word count: %s' ), '<span class="word-count">0</span>' ); ?></td>
    715718    <td class="autosave-info">
    716719    <span class="autosave-message">&nbsp;</span>
    717 <?php
    718 if ( 'auto-draft' != $post->post_status ) {
    719     echo '<span id="last-edit">';
    720     if ( $last_user = get_userdata( get_post_meta( $post_ID, '_edit_last', true ) ) ) {
    721         /* translators: 1: Name of most recent post author, 2: Post edited date, 3: Post edited time */
    722         printf( __( 'Last edited by %1$s on %2$s at %3$s' ), esc_html( $last_user->display_name ), mysql2date( __( 'F j, Y' ), $post->post_modified ), mysql2date( __( 'g:i a' ), $post->post_modified ) );
    723     } else {
    724         /* translators: 1: Post edited date, 2: Post edited time */
    725         printf( __( 'Last edited on %1$s at %2$s' ), mysql2date( __( 'F j, Y' ), $post->post_modified ), mysql2date( __( 'g:i a' ), $post->post_modified ) );
    726     }
    727     echo '</span>';
    728 }
     720    <?php
     721    if ( 'auto-draft' != $post->post_status ) {
     722        echo '<span id="last-edit">';
     723        if ( $last_user = get_userdata( get_post_meta( $post_ID, '_edit_last', true ) ) ) {
     724            /* translators: 1: Name of most recent post author, 2: Post edited date, 3: Post edited time */
     725            printf( __( 'Last edited by %1$s on %2$s at %3$s' ), esc_html( $last_user->display_name ), mysql2date( __( 'F j, Y' ), $post->post_modified ), mysql2date( __( 'g:i a' ), $post->post_modified ) );
     726        } else {
     727            /* translators: 1: Post edited date, 2: Post edited time */
     728            printf( __( 'Last edited on %1$s at %2$s' ), mysql2date( __( 'F j, Y' ), $post->post_modified ), mysql2date( __( 'g:i a' ), $post->post_modified ) );
     729        }
     730        echo '</span>';
     731    }
    729732    ?>
    730733    </td>
     
    733736
    734737</div>
    735 <?php
     738    <?php
    736739}
    737740/**
Note: See TracChangeset for help on using the changeset viewer.