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-wp-upgrader-skin.php

    r41161 r42343  
    2626     * @var string|bool|WP_Error
    2727     */
    28     public $result = false;
     28    public $result  = false;
    2929    public $options = array();
    3030
    3131    /**
    32      *
    3332     * @param array $args
    3433     */
    35     public function __construct($args = array()) {
    36         $defaults = array( 'url' => '', 'nonce' => '', 'title' => '', 'context' => false );
    37         $this->options = wp_parse_args($args, $defaults);
    38     }
    39 
    40     /**
    41      *
     34    public function __construct( $args = array() ) {
     35        $defaults      = array(
     36            'url'     => '',
     37            'nonce'   => '',
     38            'title'   => '',
     39            'context' => false,
     40        );
     41        $this->options = wp_parse_args( $args, $defaults );
     42    }
     43
     44    /**
    4245     * @param WP_Upgrader $upgrader
    4346     */
    44     public function set_upgrader(&$upgrader) {
    45         if ( is_object($upgrader) )
     47    public function set_upgrader( &$upgrader ) {
     48        if ( is_object( $upgrader ) ) {
    4649            $this->upgrader =& $upgrader;
     50        }
    4751        $this->add_strings();
    4852    }
     
    8589            $context = $this->options['context'];
    8690        }
    87         if ( !empty($this->options['nonce']) ) {
    88             $url = wp_nonce_url($url, $this->options['nonce']);
     91        if ( ! empty( $this->options['nonce'] ) ) {
     92            $url = wp_nonce_url( $url, $this->options['nonce'] );
    8993        }
    9094
     
    116120
    117121    /**
    118      *
    119122     * @param string|WP_Error $errors
    120123     */
    121     public function error($errors) {
    122         if ( ! $this->done_header )
     124    public function error( $errors ) {
     125        if ( ! $this->done_header ) {
    123126            $this->header();
    124         if ( is_string($errors) ) {
    125             $this->feedback($errors);
    126         } elseif ( is_wp_error($errors) && $errors->get_error_code() ) {
     127        }
     128        if ( is_string( $errors ) ) {
     129            $this->feedback( $errors );
     130        } elseif ( is_wp_error( $errors ) && $errors->get_error_code() ) {
    127131            foreach ( $errors->get_error_messages() as $message ) {
    128                 if ( $errors->get_error_data() && is_string( $errors->get_error_data() ) )
    129                     $this->feedback($message . ' ' . esc_html( strip_tags( $errors->get_error_data() ) ) );
    130                 else
    131                     $this->feedback($message);
     132                if ( $errors->get_error_data() && is_string( $errors->get_error_data() ) ) {
     133                    $this->feedback( $message . ' ' . esc_html( strip_tags( $errors->get_error_data() ) ) );
     134                } else {
     135                    $this->feedback( $message );
     136                }
    132137            }
    133138        }
     
    135140
    136141    /**
    137      *
    138142     * @param string $string
    139143     */
    140     public function feedback($string) {
    141         if ( isset( $this->upgrader->strings[$string] ) )
    142             $string = $this->upgrader->strings[$string];
    143 
    144         if ( strpos($string, '%') !== false ) {
     144    public function feedback( $string ) {
     145        if ( isset( $this->upgrader->strings[ $string ] ) ) {
     146            $string = $this->upgrader->strings[ $string ];
     147        }
     148
     149        if ( strpos( $string, '%' ) !== false ) {
    145150            $args = func_get_args();
    146             $args = array_splice($args, 1);
     151            $args = array_splice( $args, 1 );
    147152            if ( $args ) {
    148                 $args = array_map( 'strip_tags', $args );
    149                 $args = array_map( 'esc_html', $args );
    150                 $string = vsprintf($string, $args);
     153                $args   = array_map( 'strip_tags', $args );
     154                $args   = array_map( 'esc_html', $args );
     155                $string = vsprintf( $string, $args );
    151156            }
    152157        }
    153         if ( empty($string) )
    154             return;
    155         show_message($string);
     158        if ( empty( $string ) ) {
     159            return;
     160        }
     161        show_message( $string );
    156162    }
    157163
Note: See TracChangeset for help on using the changeset viewer.