Make WordPress Core


Ignore:
Timestamp:
11/30/2017 11:09:33 PM (8 years ago)
Author:
pento
Message:

Code is Poetry.
WordPress' code just... wasn't.
This is now dealt with.

Props jrf, pento, netweb, GaryJ, jdgrimes, westonruter, Greg Sherwood from PHPCS, and everyone who's ever contributed to WPCS and PHPCS.
Fixes #41057.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-admin/includes/class-bulk-upgrader-skin.php

    r41161 r42343  
    2424
    2525    /**
    26      *
    2726     * @param array $args
    2827     */
    29     public function __construct($args = array()) {
    30         $defaults = array( 'url' => '', 'nonce' => '' );
    31         $args = wp_parse_args($args, $defaults);
     28    public function __construct( $args = array() ) {
     29        $defaults = array(
     30            'url'   => '',
     31            'nonce' => '',
     32        );
     33        $args     = wp_parse_args( $args, $defaults );
    3234
    33         parent::__construct($args);
     35        parent::__construct( $args );
    3436    }
    3537
     
    3739     */
    3840    public function add_strings() {
    39         $this->upgrader->strings['skin_upgrade_start'] = __('The update process is starting. This process may take a while on some hosts, so please be patient.');
     41        $this->upgrader->strings['skin_upgrade_start'] = __( 'The update process is starting. This process may take a while on some hosts, so please be patient.' );
    4042        /* translators: 1: Title of an update, 2: Error message */
    41         $this->upgrader->strings['skin_update_failed_error'] = __('An error occurred while updating %1$s: %2$s');
     43        $this->upgrader->strings['skin_update_failed_error'] = __( 'An error occurred while updating %1$s: %2$s' );
    4244        /* translators: 1: Title of an update */
    43         $this->upgrader->strings['skin_update_failed'] = __('The update of %1$s failed.');
     45        $this->upgrader->strings['skin_update_failed'] = __( 'The update of %1$s failed.' );
    4446        /* translators: 1: Title of an update */
    4547        $this->upgrader->strings['skin_update_successful'] = __( '%1$s updated successfully.' );
    46         $this->upgrader->strings['skin_upgrade_end'] = __('All updates have been completed.');
     48        $this->upgrader->strings['skin_upgrade_end']       = __( 'All updates have been completed.' );
    4749    }
    4850
    4951    /**
    50      *
    5152     * @param string $string
    5253     */
    53     public function feedback($string) {
    54         if ( isset( $this->upgrader->strings[$string] ) )
    55             $string = $this->upgrader->strings[$string];
     54    public function feedback( $string ) {
     55        if ( isset( $this->upgrader->strings[ $string ] ) ) {
     56            $string = $this->upgrader->strings[ $string ];
     57        }
    5658
    57         if ( strpos($string, '%') !== false ) {
     59        if ( strpos( $string, '%' ) !== false ) {
    5860            $args = func_get_args();
    59             $args = array_splice($args, 1);
     61            $args = array_splice( $args, 1 );
    6062            if ( $args ) {
    61                 $args = array_map( 'strip_tags', $args );
    62                 $args = array_map( 'esc_html', $args );
    63                 $string = vsprintf($string, $args);
     63                $args   = array_map( 'strip_tags', $args );
     64                $args   = array_map( 'esc_html', $args );
     65                $string = vsprintf( $string, $args );
    6466            }
    6567        }
    66         if ( empty($string) )
     68        if ( empty( $string ) ) {
    6769            return;
    68         if ( $this->in_loop )
     70        }
     71        if ( $this->in_loop ) {
    6972            echo "$string<br />\n";
    70         else
     73        } else {
    7174            echo "<p>$string</p>\n";
     75        }
    7276    }
    7377
     
    8589
    8690    /**
    87      *
    8891     * @param string|WP_Error $error
    8992     */
    90     public function error($error) {
    91         if ( is_string($error) && isset( $this->upgrader->strings[$error] ) )
    92             $this->error = $this->upgrader->strings[$error];
     93    public function error( $error ) {
     94        if ( is_string( $error ) && isset( $this->upgrader->strings[ $error ] ) ) {
     95            $this->error = $this->upgrader->strings[ $error ];
     96        }
    9397
    94         if ( is_wp_error($error) ) {
     98        if ( is_wp_error( $error ) ) {
    9599            $messages = array();
    96100            foreach ( $error->get_error_messages() as $emessage ) {
    97                 if ( $error->get_error_data() && is_string( $error->get_error_data() ) )
     101                if ( $error->get_error_data() && is_string( $error->get_error_data() ) ) {
    98102                    $messages[] = $emessage . ' ' . esc_html( strip_tags( $error->get_error_data() ) );
    99                 else
     103                } else {
    100104                    $messages[] = $emessage;
     105                }
    101106            }
    102             $this->error = implode(', ', $messages);
     107            $this->error = implode( ', ', $messages );
    103108        }
    104         echo '<script type="text/javascript">jQuery(\'.waiting-' . esc_js($this->upgrader->update_current) . '\').hide();</script>';
     109        echo '<script type="text/javascript">jQuery(\'.waiting-' . esc_js( $this->upgrader->update_current ) . '\').hide();</script>';
    105110    }
    106111
     
    108113     */
    109114    public function bulk_header() {
    110         $this->feedback('skin_upgrade_start');
     115        $this->feedback( 'skin_upgrade_start' );
    111116    }
    112117
     
    114119     */
    115120    public function bulk_footer() {
    116         $this->feedback('skin_upgrade_end');
     121        $this->feedback( 'skin_upgrade_end' );
    117122    }
    118123
    119124    /**
    120      *
    121125     * @param string $title
    122126     */
    123     public function before($title = '') {
     127    public function before( $title = '' ) {
    124128        $this->in_loop = true;
    125129        printf( '<h2>' . $this->upgrader->strings['skin_before_update_header'] . ' <span class="spinner waiting-' . $this->upgrader->update_current . '"></span></h2>', $title, $this->upgrader->update_current, $this->upgrader->update_count );
    126         echo '<script type="text/javascript">jQuery(\'.waiting-' . esc_js($this->upgrader->update_current) . '\').css("display", "inline-block");</script>';
     130        echo '<script type="text/javascript">jQuery(\'.waiting-' . esc_js( $this->upgrader->update_current ) . '\').css("display", "inline-block");</script>';
    127131        // This progress messages div gets moved via JavaScript when clicking on "Show details.".
    128         echo '<div class="update-messages hide-if-js" id="progress-' . esc_attr($this->upgrader->update_current) . '"><p>';
     132        echo '<div class="update-messages hide-if-js" id="progress-' . esc_attr( $this->upgrader->update_current ) . '"><p>';
    129133        $this->flush_output();
    130134    }
    131135
    132136    /**
    133      *
    134137     * @param string $title
    135138     */
    136     public function after($title = '') {
     139    public function after( $title = '' ) {
    137140        echo '</p></div>';
    138141        if ( $this->error || ! $this->result ) {
    139142            if ( $this->error ) {
    140                 echo '<div class="error"><p>' . sprintf($this->upgrader->strings['skin_update_failed_error'], $title, '<strong>' . $this->error . '</strong>' ) . '</p></div>';
     143                echo '<div class="error"><p>' . sprintf( $this->upgrader->strings['skin_update_failed_error'], $title, '<strong>' . $this->error . '</strong>' ) . '</p></div>';
    141144            } else {
    142                 echo '<div class="error"><p>' . sprintf($this->upgrader->strings['skin_update_failed'], $title) . '</p></div>';
     145                echo '<div class="error"><p>' . sprintf( $this->upgrader->strings['skin_update_failed'], $title ) . '</p></div>';
    143146            }
    144147
    145             echo '<script type="text/javascript">jQuery(\'#progress-' . esc_js($this->upgrader->update_current) . '\').show();</script>';
     148            echo '<script type="text/javascript">jQuery(\'#progress-' . esc_js( $this->upgrader->update_current ) . '\').show();</script>';
    146149        }
    147150        if ( $this->result && ! is_wp_error( $this->result ) ) {
     
    153156            }
    154157
    155             echo '<script type="text/javascript">jQuery(\'.waiting-' . esc_js($this->upgrader->update_current) . '\').hide();</script>';
     158            echo '<script type="text/javascript">jQuery(\'.waiting-' . esc_js( $this->upgrader->update_current ) . '\').hide();</script>';
    156159        }
    157160
     
    164167    public function reset() {
    165168        $this->in_loop = false;
    166         $this->error = false;
     169        $this->error   = false;
    167170    }
    168171
Note: See TracChangeset for help on using the changeset viewer.