Make WordPress Core


Ignore:
Timestamp:
08/17/2018 01:50:26 AM (8 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/custom-background.php

    r42343 r43571  
    222222         */
    223223        public function admin_page() {
    224 ?>
     224                ?>
    225225<div class="wrap" id="custom-background">
    226226<h1><?php _e( 'Custom Background' ); ?></h1>
    227227
    228 <?php if ( current_user_can( 'customize' ) ) { ?>
     228                <?php if ( current_user_can( 'customize' ) ) { ?>
    229229<div class="notice notice-info hide-if-no-customize">
    230230        <p>
    231                 <?php
    232                 printf(
    233                         __( 'You can now manage and live-preview Custom Backgrounds in the <a href="%1$s">Customizer</a>.' ),
    234                         admin_url( 'customize.php?autofocus[control]=background_image' )
    235                 );
    236                 ?>
     231                        <?php
     232                                printf(
     233                                        __( 'You can now manage and live-preview Custom Backgrounds in the <a href="%1$s">Customizer</a>.' ),
     234                                        admin_url( 'customize.php?autofocus[control]=background_image' )
     235                                );
     236                        ?>
    237237        </p>
    238238</div>
    239 <?php } ?>
    240 
    241 <?php if ( ! empty( $this->updated ) ) { ?>
     239                <?php } ?>
     240
     241                <?php if ( ! empty( $this->updated ) ) { ?>
    242242<div id="message" class="updated">
    243243<p><?php printf( __( 'Background updated. <a href="%s">Visit your site</a> to see how it looks.' ), home_url( '/' ) ); ?></p>
    244244</div>
    245 <?php } ?>
     245                <?php } ?>
    246246
    247247<h3><?php _e( 'Background Image' ); ?></h3>
     
    252252<th scope="row"><?php _e( 'Preview' ); ?></th>
    253253<td>
    254         <?php
    255         if ( $this->admin_image_div_callback ) {
    256                 call_user_func( $this->admin_image_div_callback );
    257         } else {
    258                 $background_styles = '';
    259                 if ( $bgcolor = get_background_color() ) {
    260                         $background_styles .= 'background-color: #' . $bgcolor . ';';
    261                 }
    262 
    263                 $background_image_thumb = get_background_image();
    264                 if ( $background_image_thumb ) {
    265                         $background_image_thumb = esc_url( set_url_scheme( get_theme_mod( 'background_image_thumb', str_replace( '%', '%%', $background_image_thumb ) ) ) );
    266                         $background_position_x  = get_theme_mod( 'background_position_x', get_theme_support( 'custom-background', 'default-position-x' ) );
    267                         $background_position_y  = get_theme_mod( 'background_position_y', get_theme_support( 'custom-background', 'default-position-y' ) );
    268                         $background_size        = get_theme_mod( 'background_size', get_theme_support( 'custom-background', 'default-size' ) );
    269                         $background_repeat      = get_theme_mod( 'background_repeat', get_theme_support( 'custom-background', 'default-repeat' ) );
    270                         $background_attachment  = get_theme_mod( 'background_attachment', get_theme_support( 'custom-background', 'default-attachment' ) );
    271 
    272                         // Background-image URL must be single quote, see below.
    273                         $background_styles .= " background-image: url('$background_image_thumb');"
     254                <?php
     255                if ( $this->admin_image_div_callback ) {
     256                        call_user_func( $this->admin_image_div_callback );
     257                } else {
     258                        $background_styles = '';
     259                        if ( $bgcolor = get_background_color() ) {
     260                                $background_styles .= 'background-color: #' . $bgcolor . ';';
     261                        }
     262
     263                        $background_image_thumb = get_background_image();
     264                        if ( $background_image_thumb ) {
     265                                $background_image_thumb = esc_url( set_url_scheme( get_theme_mod( 'background_image_thumb', str_replace( '%', '%%', $background_image_thumb ) ) ) );
     266                                $background_position_x  = get_theme_mod( 'background_position_x', get_theme_support( 'custom-background', 'default-position-x' ) );
     267                                $background_position_y  = get_theme_mod( 'background_position_y', get_theme_support( 'custom-background', 'default-position-y' ) );
     268                                $background_size        = get_theme_mod( 'background_size', get_theme_support( 'custom-background', 'default-size' ) );
     269                                $background_repeat      = get_theme_mod( 'background_repeat', get_theme_support( 'custom-background', 'default-repeat' ) );
     270                                $background_attachment  = get_theme_mod( 'background_attachment', get_theme_support( 'custom-background', 'default-attachment' ) );
     271
     272                                // Background-image URL must be single quote, see below.
     273                                $background_styles .= " background-image: url('$background_image_thumb');"
    274274                                . " background-size: $background_size;"
    275275                                . " background-position: $background_position_x $background_position_y;"
    276276                                . " background-repeat: $background_repeat;"
    277277                                . " background-attachment: $background_attachment;";
    278                 }
    279         ?>
     278                        }
     279                        ?>
    280280        <div id="custom-background-image" style="<?php echo $background_styles; ?>"><?php // must be double quote, see above ?>
    281                 <?php if ( $background_image_thumb ) { ?>
     281                        <?php if ( $background_image_thumb ) { ?>
    282282                <img class="custom-background-image" src="<?php echo $background_image_thumb; ?>" style="visibility:hidden;" alt="" /><br />
    283283                <img class="custom-background-image" src="<?php echo $background_image_thumb; ?>" style="visibility:hidden;" alt="" />
     
    288288</tr>
    289289
    290 <?php if ( get_background_image() ) : ?>
     290                <?php if ( get_background_image() ) : ?>
    291291<tr>
    292292<th scope="row"><?php _e( 'Remove Image' ); ?></th>
    293293<td>
    294294<form method="post">
    295 <?php wp_nonce_field( 'custom-background-remove', '_wpnonce-custom-background-remove' ); ?>
    296 <?php submit_button( __( 'Remove Background Image' ), '', 'remove-background', false ); ?><br/>
    297 <?php _e( 'This will remove the background image. You will not be able to restore any customizations.' ); ?>
     295                        <?php wp_nonce_field( 'custom-background-remove', '_wpnonce-custom-background-remove' ); ?>
     296                        <?php submit_button( __( 'Remove Background Image' ), '', 'remove-background', false ); ?><br/>
     297                        <?php _e( 'This will remove the background image. You will not be able to restore any customizations.' ); ?>
    298298</form>
    299299</td>
    300300</tr>
    301 <?php endif; ?>
    302 
    303 <?php $default_image = get_theme_support( 'custom-background', 'default-image' ); ?>
    304 <?php if ( $default_image && get_background_image() != $default_image ) : ?>
     301                <?php endif; ?>
     302
     303                <?php $default_image = get_theme_support( 'custom-background', 'default-image' ); ?>
     304                <?php if ( $default_image && get_background_image() != $default_image ) : ?>
    305305<tr>
    306306<th scope="row"><?php _e( 'Restore Original Image' ); ?></th>
    307307<td>
    308308<form method="post">
    309 <?php wp_nonce_field( 'custom-background-reset', '_wpnonce-custom-background-reset' ); ?>
    310 <?php submit_button( __( 'Restore Original Image' ), '', 'reset-background', false ); ?><br/>
    311 <?php _e( 'This will restore the original background image. You will not be able to restore any customizations.' ); ?>
     309                        <?php wp_nonce_field( 'custom-background-reset', '_wpnonce-custom-background-reset' ); ?>
     310                        <?php submit_button( __( 'Restore Original Image' ), '', 'reset-background', false ); ?><br/>
     311                        <?php _e( 'This will restore the original background image. You will not be able to restore any customizations.' ); ?>
    312312</form>
    313313</td>
    314314</tr>
    315 <?php endif; ?>
    316 
    317 <?php if ( current_user_can( 'upload_files' ) ) : ?>
     315                <?php endif; ?>
     316
     317                <?php if ( current_user_can( 'upload_files' ) ) : ?>
    318318<tr>
    319319<th scope="row"><?php _e( 'Select Image' ); ?></th>
     
    323323                <input type="file" id="upload" name="import" />
    324324                <input type="hidden" name="action" value="save" />
    325                 <?php wp_nonce_field( 'custom-background-upload', '_wpnonce-custom-background-upload' ); ?>
    326                 <?php submit_button( __( 'Upload' ), '', 'submit', false ); ?>
     325                        <?php wp_nonce_field( 'custom-background-upload', '_wpnonce-custom-background-upload' ); ?>
     326                        <?php submit_button( __( 'Upload' ), '', 'submit', false ); ?>
    327327        </p>
    328328        <p>
     
    335335</td>
    336336</tr>
    337 <?php endif; ?>
     337                <?php endif; ?>
    338338</tbody>
    339339</table>
     
    343343<table class="form-table">
    344344<tbody>
    345 <?php if ( get_background_image() ) : ?>
     345                <?php if ( get_background_image() ) : ?>
    346346<input name="background-preset" type="hidden" value="custom">
    347347
    348 <?php
    349 $background_position = sprintf(
    350         '%s %s',
    351         get_theme_mod( 'background_position_x', get_theme_support( 'custom-background', 'default-position-x' ) ),
    352         get_theme_mod( 'background_position_y', get_theme_support( 'custom-background', 'default-position-y' ) )
    353 );
    354 
    355 $background_position_options = array(
    356         array(
    357                 'left top'   => array(
    358                         'label' => __( 'Top Left' ),
    359                         'icon'  => 'dashicons dashicons-arrow-left-alt',
    360                 ),
    361                 'center top' => array(
    362                         'label' => __( 'Top' ),
    363                         'icon'  => 'dashicons dashicons-arrow-up-alt',
    364                 ),
    365                 'right top'  => array(
    366                         'label' => __( 'Top Right' ),
    367                         'icon'  => 'dashicons dashicons-arrow-right-alt',
    368                 ),
    369         ),
    370         array(
    371                 'left center'   => array(
    372                         'label' => __( 'Left' ),
    373                         'icon'  => 'dashicons dashicons-arrow-left-alt',
    374                 ),
    375                 'center center' => array(
    376                         'label' => __( 'Center' ),
    377                         'icon'  => 'background-position-center-icon',
    378                 ),
    379                 'right center'  => array(
    380                         'label' => __( 'Right' ),
    381                         'icon'  => 'dashicons dashicons-arrow-right-alt',
    382                 ),
    383         ),
    384         array(
    385                 'left bottom'   => array(
    386                         'label' => __( 'Bottom Left' ),
    387                         'icon'  => 'dashicons dashicons-arrow-left-alt',
    388                 ),
    389                 'center bottom' => array(
    390                         'label' => __( 'Bottom' ),
    391                         'icon'  => 'dashicons dashicons-arrow-down-alt',
    392                 ),
    393                 'right bottom'  => array(
    394                         'label' => __( 'Bottom Right' ),
    395                         'icon'  => 'dashicons dashicons-arrow-right-alt',
    396                 ),
    397         ),
    398 );
    399 ?>
     348                        <?php
     349                        $background_position = sprintf(
     350                                '%s %s',
     351                                get_theme_mod( 'background_position_x', get_theme_support( 'custom-background', 'default-position-x' ) ),
     352                                get_theme_mod( 'background_position_y', get_theme_support( 'custom-background', 'default-position-y' ) )
     353                        );
     354
     355                        $background_position_options = array(
     356                                array(
     357                                        'left top'   => array(
     358                                                'label' => __( 'Top Left' ),
     359                                                'icon'  => 'dashicons dashicons-arrow-left-alt',
     360                                        ),
     361                                        'center top' => array(
     362                                                'label' => __( 'Top' ),
     363                                                'icon'  => 'dashicons dashicons-arrow-up-alt',
     364                                        ),
     365                                        'right top'  => array(
     366                                                'label' => __( 'Top Right' ),
     367                                                'icon'  => 'dashicons dashicons-arrow-right-alt',
     368                                        ),
     369                                ),
     370                                array(
     371                                        'left center'   => array(
     372                                                'label' => __( 'Left' ),
     373                                                'icon'  => 'dashicons dashicons-arrow-left-alt',
     374                                        ),
     375                                        'center center' => array(
     376                                                'label' => __( 'Center' ),
     377                                                'icon'  => 'background-position-center-icon',
     378                                        ),
     379                                        'right center'  => array(
     380                                                'label' => __( 'Right' ),
     381                                                'icon'  => 'dashicons dashicons-arrow-right-alt',
     382                                        ),
     383                                ),
     384                                array(
     385                                        'left bottom'   => array(
     386                                                'label' => __( 'Bottom Left' ),
     387                                                'icon'  => 'dashicons dashicons-arrow-left-alt',
     388                                        ),
     389                                        'center bottom' => array(
     390                                                'label' => __( 'Bottom' ),
     391                                                'icon'  => 'dashicons dashicons-arrow-down-alt',
     392                                        ),
     393                                        'right bottom'  => array(
     394                                                'label' => __( 'Bottom Right' ),
     395                                                'icon'  => 'dashicons dashicons-arrow-right-alt',
     396                                        ),
     397                                ),
     398                        );
     399                        ?>
    400400<tr>
    401401<th scope="row"><?php _e( 'Image Position' ); ?></th>
    402402<td><fieldset><legend class="screen-reader-text"><span><?php _e( 'Image Position' ); ?></span></legend>
    403403<div class="background-position-control">
    404 <?php foreach ( $background_position_options as $group ) : ?>
     404                        <?php foreach ( $background_position_options as $group ) : ?>
    405405        <div class="button-group">
    406         <?php foreach ( $group as $value => $input ) : ?>
     406                                <?php foreach ( $group as $value => $input ) : ?>
    407407                <label>
    408408                        <input class="screen-reader-text" name="background-position" type="radio" value="<?php echo esc_attr( $value ); ?>"<?php checked( $value, $background_position ); ?>>
     
    447447<th scope="row"><?php _e( 'Background Color' ); ?></th>
    448448<td><fieldset><legend class="screen-reader-text"><span><?php _e( 'Background Color' ); ?></span></legend>
    449 <?php
    450 $default_color = '';
    451 if ( current_theme_supports( 'custom-background', 'default-color' ) ) {
    452         $default_color = ' data-default-color="#' . esc_attr( get_theme_support( 'custom-background', 'default-color' ) ) . '"';
    453 }
    454 ?>
     449                <?php
     450                $default_color = '';
     451                if ( current_theme_supports( 'custom-background', 'default-color' ) ) {
     452                        $default_color = ' data-default-color="#' . esc_attr( get_theme_support( 'custom-background', 'default-color' ) ) . '"';
     453                }
     454                ?>
    455455<input type="text" name="background-color" id="background-color" value="#<?php echo esc_attr( get_background_color() ); ?>"<?php echo $default_color; ?>>
    456456</fieldset></td>
     
    459459</table>
    460460
    461 <?php wp_nonce_field( 'custom-background' ); ?>
    462 <?php submit_button( null, 'primary', 'save-background-options' ); ?>
     461                <?php wp_nonce_field( 'custom-background' ); ?>
     462                <?php submit_button( null, 'primary', 'save-background-options' ); ?>
    463463</form>
    464464
    465465</div>
    466 <?php
     466                <?php
    467467        }
    468468
     
    582582                $sizes = array_keys(
    583583                        apply_filters(
    584                                 'image_size_names_choose', array(
     584                                'image_size_names_choose',
     585                                array(
    585586                                        'thumbnail' => __( 'Thumbnail' ),
    586587                                        'medium'    => __( 'Medium' ),
Note: See TracChangeset for help on using the changeset viewer.