Make WordPress Core


Ignore:
Timestamp:
11/30/2017 11:09:33 PM (7 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-theme-installer-skin.php

    r41797 r42343  
    2121
    2222    /**
    23      *
    2423     * @param array $args
    2524     */
    26     public function __construct($args = array()) {
    27         $defaults = array( 'type' => 'web', 'url' => '', 'theme' => '', 'nonce' => '', 'title' => '' );
    28         $args = wp_parse_args($args, $defaults);
     25    public function __construct( $args = array() ) {
     26        $defaults = array(
     27            'type'  => 'web',
     28            'url'   => '',
     29            'theme' => '',
     30            'nonce' => '',
     31            'title' => '',
     32        );
     33        $args     = wp_parse_args( $args, $defaults );
    2934
    3035        $this->type = $args['type'];
    31         $this->api = isset($args['api']) ? $args['api'] : array();
     36        $this->api  = isset( $args['api'] ) ? $args['api'] : array();
    3237
    33         parent::__construct($args);
     38        parent::__construct( $args );
    3439    }
    3540
     
    3742     */
    3843    public function before() {
    39         if ( !empty($this->api) )
    40             $this->upgrader->strings['process_success'] = sprintf( $this->upgrader->strings['process_success_specific'], $this->api->name, $this->api->version);
     44        if ( ! empty( $this->api ) ) {
     45            $this->upgrader->strings['process_success'] = sprintf( $this->upgrader->strings['process_success_specific'], $this->api->name, $this->api->version );
     46        }
    4147    }
    4248
     
    4450     */
    4551    public function after() {
    46         if ( empty($this->upgrader->result['destination_name']) )
     52        if ( empty( $this->upgrader->result['destination_name'] ) ) {
    4753            return;
     54        }
    4855
    4956        $theme_info = $this->upgrader->theme_info();
    50         if ( empty( $theme_info ) )
     57        if ( empty( $theme_info ) ) {
    5158            return;
     59        }
    5260
    53         $name       = $theme_info->display('Name');
     61        $name       = $theme_info->display( 'Name' );
    5462        $stylesheet = $this->upgrader->result['destination_name'];
    5563        $template   = $theme_info->get_template();
    5664
    57         $activate_link = add_query_arg( array(
    58             'action'     => 'activate',
    59             'template'   => urlencode( $template ),
    60             'stylesheet' => urlencode( $stylesheet ),
    61         ), admin_url('themes.php') );
     65        $activate_link = add_query_arg(
     66            array(
     67                'action'     => 'activate',
     68                'template'   => urlencode( $template ),
     69                'stylesheet' => urlencode( $stylesheet ),
     70            ), admin_url( 'themes.php' )
     71        );
    6272        $activate_link = wp_nonce_url( $activate_link, 'switch-theme_' . $stylesheet );
    6373
     
    6575
    6676        if ( current_user_can( 'edit_theme_options' ) && current_user_can( 'customize' ) ) {
    67             $customize_url = add_query_arg(
     77            $customize_url              = add_query_arg(
    6878                array(
    69                     'theme' => urlencode( $stylesheet ),
     79                    'theme'  => urlencode( $stylesheet ),
    7080                    'return' => urlencode( admin_url( 'web' === $this->type ? 'theme-install.php' : 'themes.php' ) ),
    7181                ),
     
    7686        $install_actions['activate'] = '<a href="' . esc_url( $activate_link ) . '" class="activatelink"><span aria-hidden="true">' . __( 'Activate' ) . '</span><span class="screen-reader-text">' . sprintf( __( 'Activate &#8220;%s&#8221;' ), $name ) . '</span></a>';
    7787
    78         if ( is_network_admin() && current_user_can( 'manage_network_themes' ) )
     88        if ( is_network_admin() && current_user_can( 'manage_network_themes' ) ) {
    7989            $install_actions['network_enable'] = '<a href="' . esc_url( wp_nonce_url( 'themes.php?action=enable&amp;theme=' . urlencode( $stylesheet ), 'enable-theme_' . $stylesheet ) ) . '" target="_parent">' . __( 'Network Enable' ) . '</a>';
     90        }
    8091
    81         if ( $this->type == 'web' )
     92        if ( $this->type == 'web' ) {
    8293            $install_actions['themes_page'] = '<a href="' . self_admin_url( 'theme-install.php' ) . '" target="_parent">' . __( 'Return to Theme Installer' ) . '</a>';
    83         elseif ( current_user_can( 'switch_themes' ) || current_user_can( 'edit_theme_options' ) )
     94        } elseif ( current_user_can( 'switch_themes' ) || current_user_can( 'edit_theme_options' ) ) {
    8495            $install_actions['themes_page'] = '<a href="' . self_admin_url( 'themes.php' ) . '" target="_parent">' . __( 'Return to Themes page' ) . '</a>';
     96        }
    8597
    86         if ( ! $this->result || is_wp_error($this->result) || is_network_admin() || ! current_user_can( 'switch_themes' ) )
     98        if ( ! $this->result || is_wp_error( $this->result ) || is_network_admin() || ! current_user_can( 'switch_themes' ) ) {
    8799            unset( $install_actions['activate'], $install_actions['preview'] );
     100        }
    88101
    89102        /**
     
    98111         */
    99112        $install_actions = apply_filters( 'install_theme_complete_actions', $install_actions, $this->api, $stylesheet, $theme_info );
    100         if ( ! empty($install_actions) )
    101             $this->feedback(implode(' | ', (array)$install_actions));
     113        if ( ! empty( $install_actions ) ) {
     114            $this->feedback( implode( ' | ', (array) $install_actions ) );
     115        }
    102116    }
    103117}
Note: See TracChangeset for help on using the changeset viewer.