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

    r43569 r43571  
    891891     */
    892892    return apply_filters(
    893         'wp_handle_upload', array(
     893        'wp_handle_upload',
     894        array(
    894895            'file' => $new_file,
    895896            'url'  => $url,
    896897            'type' => $type,
    897         ), 'wp_handle_sideload' === $action ? 'sideload' : 'upload'
     898        ),
     899        'wp_handle_sideload' === $action ? 'sideload' : 'upload'
    898900    );
    899901}
     
    983985
    984986    $response = wp_safe_remote_get(
    985         $url, array(
     987        $url,
     988        array(
    986989            'timeout'  => $timeout,
    987990            'stream'   => true,
     
    16801683
    16811684    $credentials = get_option(
    1682         'ftp_credentials', array(
     1685        'ftp_credentials',
     1686        array(
    16831687            'hostname' => '',
    16841688            'username' => '',
     
    17871791    $types = apply_filters( 'fs_ftp_connection_types', $types, $credentials, $type, $error, $context );
    17881792
    1789 ?>
     1793    ?>
    17901794<form action="<?php echo esc_url( $form_post ); ?>" method="post">
    17911795<div id="request-filesystem-credentials-form" class="request-filesystem-credentials-form">
    1792 <?php
    1793 // Print a H1 heading in the FTP credentials modal dialog, default is a H2.
    1794 $heading_tag = 'h2';
    1795 if ( 'plugins.php' === $pagenow || 'plugin-install.php' === $pagenow ) {
    1796     $heading_tag = 'h1';
    1797 }
    1798 echo "<$heading_tag id='request-filesystem-credentials-title'>" . __( 'Connection Information' ) . "</$heading_tag>";
    1799 ?>
     1796    <?php
     1797    // Print a H1 heading in the FTP credentials modal dialog, default is a H2.
     1798    $heading_tag = 'h2';
     1799    if ( 'plugins.php' === $pagenow || 'plugin-install.php' === $pagenow ) {
     1800        $heading_tag = 'h1';
     1801    }
     1802    echo "<$heading_tag id='request-filesystem-credentials-title'>" . __( 'Connection Information' ) . "</$heading_tag>";
     1803    ?>
    18001804<p id="request-filesystem-credentials-desc">
    1801 <?php
     1805    <?php
    18021806    $label_user = __( 'Username' );
    18031807    $label_pass = __( 'Password' );
    18041808    _e( 'To perform the requested action, WordPress needs to access your web server.' );
    18051809    echo ' ';
    1806 if ( ( isset( $types['ftp'] ) || isset( $types['ftps'] ) ) ) {
    1807     if ( isset( $types['ssh'] ) ) {
    1808         _e( 'Please enter your FTP or SSH credentials to proceed.' );
    1809         $label_user = __( 'FTP/SSH Username' );
    1810         $label_pass = __( 'FTP/SSH Password' );
    1811     } else {
    1812         _e( 'Please enter your FTP credentials to proceed.' );
    1813         $label_user = __( 'FTP Username' );
    1814         $label_pass = __( 'FTP Password' );
    1815     }
    1816     echo ' ';
    1817 }
     1810    if ( ( isset( $types['ftp'] ) || isset( $types['ftps'] ) ) ) {
     1811        if ( isset( $types['ssh'] ) ) {
     1812            _e( 'Please enter your FTP or SSH credentials to proceed.' );
     1813            $label_user = __( 'FTP/SSH Username' );
     1814            $label_pass = __( 'FTP/SSH Password' );
     1815        } else {
     1816            _e( 'Please enter your FTP credentials to proceed.' );
     1817            $label_user = __( 'FTP Username' );
     1818            $label_pass = __( 'FTP Password' );
     1819        }
     1820        echo ' ';
     1821    }
    18181822    _e( 'If you do not remember your credentials, you should contact your web host.' );
    18191823
     
    18271831        $password_value = '*****';
    18281832    }
    1829 ?>
     1833    ?>
    18301834</p>
    18311835<label for="hostname">
     
    18471851        if ( ! defined( 'FTP_PASS' ) ) {
    18481852            _e( 'This password will not be stored on the server.' );}
    1849 ?>
     1853        ?>
    18501854</em>
    18511855    </label>
     
    18531857<fieldset>
    18541858<legend><?php _e( 'Connection Type' ); ?></legend>
    1855 <?php
     1859    <?php
    18561860    $disabled = disabled( ( defined( 'FTP_SSL' ) && FTP_SSL ) || ( defined( 'FTP_SSH' ) && FTP_SSH ), true, false );
    1857 foreach ( $types as $name => $text ) :
    1858     ?>
     1861    foreach ( $types as $name => $text ) :
     1862        ?>
    18591863    <label for="<?php echo esc_attr( $name ); ?>">
    18601864        <input type="radio" name="connection_type" id="<?php echo esc_attr( $name ); ?>" value="<?php echo esc_attr( $name ); ?>" <?php checked( $name, $connection_type ); ?> <?php echo $disabled; ?> />
    18611865        <?php echo $text; ?>
    18621866    </label>
    1863 <?php
     1867        <?php
    18641868    endforeach;
    1865 ?>
     1869    ?>
    18661870</fieldset>
    1867 <?php
    1868 if ( isset( $types['ssh'] ) ) {
    1869     $hidden_class = '';
    1870     if ( 'ssh' != $connection_type || empty( $connection_type ) ) {
    1871         $hidden_class = ' class="hidden"';
    1872     }
    1873 ?>
     1871    <?php
     1872    if ( isset( $types['ssh'] ) ) {
     1873        $hidden_class = '';
     1874        if ( 'ssh' != $connection_type || empty( $connection_type ) ) {
     1875            $hidden_class = ' class="hidden"';
     1876        }
     1877        ?>
    18741878<fieldset id="ssh-keys"<?php echo $hidden_class; ?>>
    18751879<legend><?php _e( 'Authentication Keys' ); ?></legend>
     
    18841888<p id="auth-keys-desc"><?php _e( 'Enter the location on the server where the public and private keys are located. If a passphrase is needed, enter that in the password field above.' ); ?></p>
    18851889</fieldset>
    1886 <?php
    1887 }
    1888 
    1889 foreach ( (array) $extra_fields as $field ) {
    1890     if ( isset( $submitted_form[ $field ] ) ) {
    1891         echo '<input type="hidden" name="' . esc_attr( $field ) . '" value="' . esc_attr( $submitted_form[ $field ] ) . '" />';
    1892     }
    1893 }
    1894 ?>
     1890        <?php
     1891    }
     1892
     1893    foreach ( (array) $extra_fields as $field ) {
     1894        if ( isset( $submitted_form[ $field ] ) ) {
     1895            echo '<input type="hidden" name="' . esc_attr( $field ) . '" value="' . esc_attr( $submitted_form[ $field ] ) . '" />';
     1896        }
     1897    }
     1898    ?>
    18951899    <p class="request-filesystem-credentials-action-buttons">
    18961900        <?php wp_nonce_field( 'filesystem-credentials', '_fs_nonce', false, true ); ?>
     
    19001904</div>
    19011905</form>
    1902 <?php
     1906    <?php
    19031907    return false;
    19041908}
     
    19541958function wp_privacy_generate_personal_data_export_group_html( $group_data ) {
    19551959    $allowed_tags      = array(
    1956         'a' => array(
     1960        'a'  => array(
    19571961            'href'   => array(),
    1958             'target' => array()
     1962            'target' => array(),
    19591963        ),
    1960         'br' => array()
     1964        'br' => array(),
    19611965    );
    19621966    $allowed_protocols = array( 'http', 'https' );
     
    20422046    $html_report_filename = $file_basename . '.html';
    20432047    $html_report_pathname = wp_normalize_path( $exports_dir . $html_report_filename );
    2044     $file = fopen( $html_report_pathname, 'w' );
     2048    $file                 = fopen( $html_report_pathname, 'w' );
    20452049    if ( false === $file ) {
    20462050        wp_send_json_error( __( 'Unable to open export file (HTML report) for writing.' ) );
     
    20612065    fwrite( $file, "<meta http-equiv='Content-Type' content='text/html; charset=UTF-8' />\n" );
    20622066    fwrite( $file, "<style type='text/css'>" );
    2063     fwrite( $file, "body { color: black; font-family: Arial, sans-serif; font-size: 11pt; margin: 15px auto; width: 860px; }" );
    2064     fwrite( $file, "table { background: #f0f0f0; border: 1px solid #ddd; margin-bottom: 20px; width: 100%; }" );
    2065     fwrite( $file, "th { padding: 5px; text-align: left; width: 20%; }" );
    2066     fwrite( $file, "td { padding: 5px; }" );
    2067     fwrite( $file, "tr:nth-child(odd) { background-color: #fafafa; }" );
    2068     fwrite( $file, "</style>" );
    2069     fwrite( $file, "<title>" );
     2067    fwrite( $file, 'body { color: black; font-family: Arial, sans-serif; font-size: 11pt; margin: 15px auto; width: 860px; }' );
     2068    fwrite( $file, 'table { background: #f0f0f0; border: 1px solid #ddd; margin-bottom: 20px; width: 100%; }' );
     2069    fwrite( $file, 'th { padding: 5px; text-align: left; width: 20%; }' );
     2070    fwrite( $file, 'td { padding: 5px; }' );
     2071    fwrite( $file, 'tr:nth-child(odd) { background-color: #fafafa; }' );
     2072    fwrite( $file, '</style>' );
     2073    fwrite( $file, '<title>' );
    20702074    fwrite( $file, esc_html( $title ) );
    2071     fwrite( $file, "</title>" );
     2075    fwrite( $file, '</title>' );
    20722076    fwrite( $file, "</head>\n" );
    20732077
     
    20762080
    20772081    // Heading.
    2078     fwrite( $file, "<h1>" . esc_html__( 'Personal Data Export' ) . "</h1>" );
     2082    fwrite( $file, '<h1>' . esc_html__( 'Personal Data Export' ) . '</h1>' );
    20792083
    20802084    // And now, all the Groups.
     
    21982202    $expiration_date = date_i18n( get_option( 'date_format' ), time() + $expiration );
    21992203
    2200 /* translators: Do not translate EXPIRATION, LINK, SITENAME, SITEURL: those are placeholders. */
    2201 $email_text = __(
    2202 'Howdy,
     2204    /* translators: Do not translate EXPIRATION, LINK, SITENAME, SITEURL: those are placeholders. */
     2205    $email_text = __(
     2206        'Howdy,
    22032207
    22042208Your request for an export of personal data has been completed. You may
     
    22122216All at ###SITENAME###
    22132217###SITEURL###'
    2214 );
     2218    );
    22152219
    22162220    /**
     
    22302234    $content = apply_filters( 'wp_privacy_personal_data_email_content', $email_text, $request_id );
    22312235
    2232     $email_address = $request->email;
     2236    $email_address   = $request->email;
    22332237    $export_file_url = get_post_meta( $request_id, '_export_file_url', true );
    2234     $site_name = wp_specialchars_decode( get_option( 'blogname' ), ENT_QUOTES );
    2235     $site_url = home_url();
     2238    $site_name       = wp_specialchars_decode( get_option( 'blogname' ), ENT_QUOTES );
     2239    $site_url        = home_url();
    22362240
    22372241    $content = str_replace( '###EXPIRATION###', $expiration_date, $content );
     
    23142318    // If we are not yet on the last page of the last exporter, return now.
    23152319    /** This filter is documented in wp-admin/includes/ajax-actions.php */
    2316     $exporters = apply_filters( 'wp_privacy_personal_data_exporters', array() );
     2320    $exporters        = apply_filters( 'wp_privacy_personal_data_exporters', array() );
    23172321    $is_last_exporter = $exporter_index === count( $exporters );
    2318     $exporter_done = $response['done'];
     2322    $exporter_done    = $response['done'];
    23192323    if ( ! $is_last_exporter || ! $exporter_done ) {
    23202324        return $response;
     
    23402344        }
    23412345
    2342         $old_item_data = $groups[ $group_id ]['items'][ $item_id ];
    2343         $merged_item_data = array_merge( $export_datum['data'], $old_item_data );
     2346        $old_item_data                            = $groups[ $group_id ]['items'][ $item_id ];
     2347        $merged_item_data                         = array_merge( $export_datum['data'], $old_item_data );
    23442348        $groups[ $group_id ]['items'][ $item_id ] = $merged_item_data;
    23452349    }
Note: See TracChangeset for help on using the changeset viewer.