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-language-pack-upgrader.php

    r41908 r42343  
    9595            $skin = $upgrader->skin;
    9696        } else {
    97             $skin = new Language_Pack_Upgrader_Skin( array(
    98                 'skip_header_footer' => true,
    99             ) );
     97            $skin = new Language_Pack_Upgrader_Skin(
     98                array(
     99                    'skip_header_footer' => true,
     100                )
     101            );
    100102        }
    101103
     
    111113    public function upgrade_strings() {
    112114        $this->strings['starting_upgrade'] = __( 'Some of your translations need updating. Sit tight for a few more seconds while we update them as well.' );
    113         $this->strings['up_to_date'] = __( 'The translations are up to date.' );
    114         $this->strings['no_package'] = __( 'Update package not available.' );
     115        $this->strings['up_to_date']       = __( 'The translations are up to date.' );
     116        $this->strings['no_package']       = __( 'Update package not available.' );
    115117        /* translators: %s: package URL */
    116118        $this->strings['downloading_package'] = sprintf( __( 'Downloading translation from %s&#8230;' ), '<span class="code">%s</span>' );
    117         $this->strings['unpack_package'] = __( 'Unpacking the update&#8230;' );
    118         $this->strings['process_failed'] = __( 'Translation update failed.' );
    119         $this->strings['process_success'] = __( 'Translation updated successfully.' );
     119        $this->strings['unpack_package']      = __( 'Unpacking the update&#8230;' );
     120        $this->strings['process_failed']      = __( 'Translation update failed.' );
     121        $this->strings['process_success']     = __( 'Translation updated successfully.' );
    120122    }
    121123
     
    164166        global $wp_filesystem;
    165167
    166         $defaults = array(
     168        $defaults    = array(
    167169            'clear_update_cache' => true,
    168170        );
     
    172174        $this->upgrade_strings();
    173175
    174         if ( ! $language_updates )
     176        if ( ! $language_updates ) {
    175177            $language_updates = wp_get_translation_updates();
     178        }
    176179
    177180        if ( empty( $language_updates ) ) {
     
    184187        }
    185188
    186         if ( 'upgrader_process_complete' == current_filter() )
     189        if ( 'upgrader_process_complete' == current_filter() ) {
    187190            $this->skin->feedback( 'starting_upgrade' );
     191        }
    188192
    189193        // Remove any existing upgrade filters from the plugin/theme upgraders #WP29425 & #WP29230
     
    206210        $results = array();
    207211
    208         $this->update_count = count( $language_updates );
     212        $this->update_count   = count( $language_updates );
    209213        $this->update_current = 0;
    210214
     
    214218         */
    215219        $remote_destination = $wp_filesystem->find_folder( WP_LANG_DIR );
    216         if ( ! $wp_filesystem->exists( $remote_destination ) )
    217             if ( ! $wp_filesystem->mkdir( $remote_destination, FS_CHMOD_DIR ) )
     220        if ( ! $wp_filesystem->exists( $remote_destination ) ) {
     221            if ( ! $wp_filesystem->mkdir( $remote_destination, FS_CHMOD_DIR ) ) {
    218222                return new WP_Error( 'mkdir_failed_lang_dir', $this->strings['mkdir_failed'], $remote_destination );
     223            }
     224        }
    219225
    220226        $language_updates_results = array();
     
    225231
    226232            $destination = WP_LANG_DIR;
    227             if ( 'plugin' == $language_update->type )
     233            if ( 'plugin' == $language_update->type ) {
    228234                $destination .= '/plugins';
    229             elseif ( 'theme' == $language_update->type )
     235            } elseif ( 'theme' == $language_update->type ) {
    230236                $destination .= '/themes';
     237            }
    231238
    232239            $this->update_current++;
    233240
    234241            $options = array(
    235                 'package' => $language_update->package,
    236                 'destination' => $destination,
    237                 'clear_destination' => false,
     242                'package'                     => $language_update->package,
     243                'destination'                 => $destination,
     244                'clear_destination'           => false,
    238245                'abort_if_destination_exists' => false, // We expect the destination to exist.
    239                 'clear_working' => true,
    240                 'is_multi' => true,
    241                 'hook_extra' => array(
     246                'clear_working'               => true,
     247                'is_multi'                    => true,
     248                'hook_extra'                  => array(
    242249                    'language_update_type' => $language_update->type,
    243                     'language_update' => $language_update,
    244                 )
     250                    'language_update'      => $language_update,
     251                ),
    245252            );
    246253
     
    269276
    270277        /** This action is documented in wp-admin/includes/class-wp-upgrader.php */
    271         do_action( 'upgrader_process_complete', $this, array(
    272             'action'       => 'update',
    273             'type'         => 'translation',
    274             'bulk'         => true,
    275             'translations' => $language_updates_results
    276         ) );
     278        do_action(
     279            'upgrader_process_complete', $this, array(
     280                'action'       => 'update',
     281                'type'         => 'translation',
     282                'bulk'         => true,
     283                'translations' => $language_updates_results,
     284            )
     285        );
    277286
    278287        // Re-add upgrade hooks.
     
    312321        global $wp_filesystem;
    313322
    314         if ( is_wp_error( $source ) )
     323        if ( is_wp_error( $source ) ) {
    315324            return $source;
     325        }
    316326
    317327        // Check that the folder contains a valid language.
     
    321331        $po = $mo = false;
    322332        foreach ( (array) $files as $file => $filedata ) {
    323             if ( '.po' == substr( $file, -3 ) )
     333            if ( '.po' == substr( $file, -3 ) ) {
    324334                $po = true;
    325             elseif ( '.mo' == substr( $file, -3 ) )
     335            } elseif ( '.mo' == substr( $file, -3 ) ) {
    326336                $mo = true;
     337            }
    327338        }
    328339
    329340        if ( ! $mo || ! $po ) {
    330             return new WP_Error( 'incompatible_archive_pomo', $this->strings['incompatible_archive'],
     341            return new WP_Error(
     342                'incompatible_archive_pomo', $this->strings['incompatible_archive'],
    331343                /* translators: 1: .po 2: .mo */
    332                 sprintf( __( 'The language pack is missing either the %1$s or %2$s files.' ),
     344                sprintf(
     345                    __( 'The language pack is missing either the %1$s or %2$s files.' ),
    333346                    '<code>.po</code>',
    334347                    '<code>.mo</code>'
     
    355368            case 'theme':
    356369                $theme = wp_get_theme( $update->slug );
    357                 if ( $theme->exists() )
     370                if ( $theme->exists() ) {
    358371                    return $theme->Get( 'Name' );
     372                }
    359373                break;
    360374            case 'plugin':
    361375                $plugin_data = get_plugins( '/' . $update->slug );
    362376                $plugin_data = reset( $plugin_data );
    363                 if ( $plugin_data )
     377                if ( $plugin_data ) {
    364378                    return $plugin_data['Name'];
     379                }
    365380                break;
    366381        }
Note: See TracChangeset for help on using the changeset viewer.