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/network.php

    r42827 r43571  
    218218
    219219    if ( allow_subdomain_install() && allow_subdirectory_install() ) :
    220     ?>
     220        ?>
    221221        <h3><?php esc_html_e( 'Addresses of Sites in your Network' ); ?></h3>
    222222        <p><?php _e( 'Please choose whether you would like sites in your WordPress network to use sub-domains or sub-directories.' ); ?>
     
    251251        </table>
    252252
    253 <?php
     253        <?php
    254254    endif;
    255255
     
    283283                        '<code>' . $hostname . '</code>'
    284284                    );
    285                     ?>
     285                ?>
    286286                </td>
    287287            </tr>
     
    412412        if ( is_multisite() ) {
    413413            $subdomain_install = is_subdomain_install();
    414 ?>
     414            ?>
    415415    <p><?php _e( 'The original configuration steps are shown here for reference.' ); ?></p>
    416 <?php
     416            <?php
    417417        } else {
    418418            $subdomain_install = (bool) $wpdb->get_var( "SELECT meta_value FROM $wpdb->sitemeta WHERE site_id = 1 AND meta_key = 'subdomain_install'" );
    419 ?>
     419            ?>
    420420    <div class="error"><p><strong><?php _e( 'Warning:' ); ?></strong> <?php _e( 'An existing WordPress network was detected.' ); ?></p></div>
    421421    <p><?php _e( 'Please complete the configuration steps. To create a new network, you will need to empty or remove the network database tables.' ); ?></p>
    422 <?php
     422            <?php
    423423        }
    424424    }
     
    429429
    430430    if ( $_POST || ! is_multisite() ) {
    431 ?>
     431        ?>
    432432        <h3><?php esc_html_e( 'Enabling the Network' ); ?></h3>
    433433        <p><?php _e( 'Complete the following steps to enable the features for creating a network of sites.' ); ?></p>
     
    460460        ?>
    461461        </p></div>
    462 <?php
    463     }
    464 ?>
     462        <?php
     463    }
     464    ?>
    465465        <ol>
    466466            <li><p>
     
    488488define('BLOG_ID_CURRENT_SITE', 1);
    489489</textarea>
    490 <?php
     490    <?php
    491491    $keys_salts = array(
    492492        'AUTH_KEY'         => '',
     
    499499        'NONCE_SALT'       => '',
    500500    );
    501 foreach ( $keys_salts as $c => $v ) {
    502     if ( defined( $c ) ) {
    503         unset( $keys_salts[ $c ] );
    504     }
    505 }
    506 
    507 if ( ! empty( $keys_salts ) ) {
    508     $keys_salts_str = '';
    509     $from_api       = wp_remote_get( 'https://api.wordpress.org/secret-key/1.1/salt/' );
    510     if ( is_wp_error( $from_api ) ) {
    511         foreach ( $keys_salts as $c => $v ) {
    512             $keys_salts_str .= "\ndefine( '$c', '" . wp_generate_password( 64, true, true ) . "' );";
    513         }
    514     } else {
    515         $from_api = explode( "\n", wp_remote_retrieve_body( $from_api ) );
    516         foreach ( $keys_salts as $c => $v ) {
    517             $keys_salts_str .= "\ndefine( '$c', '" . substr( array_shift( $from_api ), 28, 64 ) . "' );";
    518         }
    519     }
    520     $num_keys_salts = count( $keys_salts );
    521 ?>
     501    foreach ( $keys_salts as $c => $v ) {
     502        if ( defined( $c ) ) {
     503            unset( $keys_salts[ $c ] );
     504        }
     505    }
     506
     507    if ( ! empty( $keys_salts ) ) {
     508        $keys_salts_str = '';
     509        $from_api       = wp_remote_get( 'https://api.wordpress.org/secret-key/1.1/salt/' );
     510        if ( is_wp_error( $from_api ) ) {
     511            foreach ( $keys_salts as $c => $v ) {
     512                $keys_salts_str .= "\ndefine( '$c', '" . wp_generate_password( 64, true, true ) . "' );";
     513            }
     514        } else {
     515            $from_api = explode( "\n", wp_remote_retrieve_body( $from_api ) );
     516            foreach ( $keys_salts as $c => $v ) {
     517                $keys_salts_str .= "\ndefine( '$c', '" . substr( array_shift( $from_api ), 28, 64 ) . "' );";
     518            }
     519        }
     520        $num_keys_salts = count( $keys_salts );
     521        ?>
    522522<p>
    523     <?php
    524     if ( 1 == $num_keys_salts ) {
    525         printf(
    526             /* translators: %s: wp-config.php */
    527             __( 'This unique authentication key is also missing from your %s file.' ),
    528             '<code>wp-config.php</code>'
    529         );
    530     } else {
    531         printf(
    532             /* translators: %s: wp-config.php */
    533             __( 'These unique authentication keys are also missing from your %s file.' ),
    534             '<code>wp-config.php</code>'
    535         );
    536     }
     523        <?php
     524        if ( 1 == $num_keys_salts ) {
     525            printf(
     526                /* translators: %s: wp-config.php */
     527                __( 'This unique authentication key is also missing from your %s file.' ),
     528                '<code>wp-config.php</code>'
     529            );
     530        } else {
     531            printf(
     532                /* translators: %s: wp-config.php */
     533                __( 'These unique authentication keys are also missing from your %s file.' ),
     534                '<code>wp-config.php</code>'
     535            );
     536        }
    537537        ?>
    538538        <?php _e( 'To make your installation more secure, you should also add:' ); ?>
    539539    </p>
    540540    <textarea class="code" readonly="readonly" cols="100" rows="<?php echo $num_keys_salts; ?>"><?php echo esc_textarea( $keys_salts_str ); ?></textarea>
    541 <?php
    542 }
    543 ?>
     541        <?php
     542    }
     543    ?>
    544544</li>
    545 <?php
    546 if ( iis7_supports_permalinks() ) :
    547     // IIS doesn't support RewriteBase, all your RewriteBase are belong to us
    548     $iis_subdir_match       = ltrim( $base, '/' ) . $subdir_match;
    549     $iis_rewrite_base       = ltrim( $base, '/' ) . $rewrite_base;
    550     $iis_subdir_replacement = $subdomain_install ? '' : '{R:1}';
    551 
    552     $web_config_file = '<?xml version="1.0" encoding="UTF-8"?>
     545    <?php
     546    if ( iis7_supports_permalinks() ) :
     547        // IIS doesn't support RewriteBase, all your RewriteBase are belong to us
     548        $iis_subdir_match       = ltrim( $base, '/' ) . $subdir_match;
     549        $iis_rewrite_base       = ltrim( $base, '/' ) . $rewrite_base;
     550        $iis_subdir_replacement = $subdomain_install ? '' : '{R:1}';
     551
     552        $web_config_file = '<?xml version="1.0" encoding="UTF-8"?>
    553553<configuration>
    554554    <system.webServer>
     
    559559                    <action type="None" />
    560560                </rule>';
    561     if ( is_multisite() && get_site_option( 'ms_files_rewriting' ) ) {
    562         $web_config_file .= '
     561        if ( is_multisite() && get_site_option( 'ms_files_rewriting' ) ) {
     562            $web_config_file .= '
    563563                <rule name="WordPress Rule for Files" stopProcessing="true">
    564564                    <match url="^' . $iis_subdir_match . 'files/(.+)" ignoreCase="false" />
    565565                    <action type="Rewrite" url="' . $iis_rewrite_base . WPINC . '/ms-files.php?file={R:1}" appendQueryString="false" />
    566566                </rule>';
    567     }
     567        }
    568568            $web_config_file .= '
    569569                <rule name="WordPress Rule 2" stopProcessing="true">
     
    604604                '<code>' . $home_path . '</code>'
    605605            );
    606     echo '</p>';
    607     if ( ! $subdomain_install && WP_CONTENT_DIR != ABSPATH . 'wp-content' ) {
    608         echo '<p><strong>' . __( 'Warning:' ) . ' ' . __( 'Subdirectory networks may not be fully compatible with custom wp-content directories.' ) . '</strong></p>';
    609     }
    610     ?>
     606        echo '</p>';
     607        if ( ! $subdomain_install && WP_CONTENT_DIR != ABSPATH . 'wp-content' ) {
     608            echo '<p><strong>' . __( 'Warning:' ) . ' ' . __( 'Subdirectory networks may not be fully compatible with custom wp-content directories.' ) . '</strong></p>';
     609        }
     610        ?>
    611611    <textarea class="code" readonly="readonly" cols="100" rows="20"><?php echo esc_textarea( $web_config_file ); ?>
    612612        </textarea></li>
    613613        </ol>
    614614
    615     <?php
     615        <?php
    616616    else : // end iis7_supports_permalinks(). construct an htaccess file instead:
    617617
     
    652652        ?>
    653653        <textarea class="code" readonly="readonly" cols="100" rows="<?php echo substr_count( $htaccess_file, "\n" ) + 1; ?>">
    654 <?php echo esc_textarea( $htaccess_file ); ?></textarea></li>
     654        <?php echo esc_textarea( $htaccess_file ); ?></textarea></li>
    655655        </ol>
    656656
    657     <?php
     657        <?php
    658658    endif; // end IIS/Apache code branches.
    659659
     
    661661        ?>
    662662        <p><?php _e( 'Once you complete these steps, your network is enabled and configured. You will have to log in again.' ); ?> <a href="<?php echo esc_url( wp_login_url() ); ?>"><?php _e( 'Log In' ); ?></a></p>
    663     <?php
     663        <?php
    664664    }
    665665}
Note: See TracChangeset for help on using the changeset viewer.