- Timestamp:
- 11/30/2017 11:09:33 PM (8 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-admin/includes/class-language-pack-upgrader.php
r41908 r42343 95 95 $skin = $upgrader->skin; 96 96 } 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 ); 100 102 } 101 103 … … 111 113 public function upgrade_strings() { 112 114 $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.' ); 115 117 /* translators: %s: package URL */ 116 118 $this->strings['downloading_package'] = sprintf( __( 'Downloading translation from %s…' ), '<span class="code">%s</span>' ); 117 $this->strings['unpack_package'] = __( 'Unpacking the update…' );118 $this->strings['process_failed'] = __( 'Translation update failed.' );119 $this->strings['process_success'] = __( 'Translation updated successfully.' );119 $this->strings['unpack_package'] = __( 'Unpacking the update…' ); 120 $this->strings['process_failed'] = __( 'Translation update failed.' ); 121 $this->strings['process_success'] = __( 'Translation updated successfully.' ); 120 122 } 121 123 … … 164 166 global $wp_filesystem; 165 167 166 $defaults = array(168 $defaults = array( 167 169 'clear_update_cache' => true, 168 170 ); … … 172 174 $this->upgrade_strings(); 173 175 174 if ( ! $language_updates ) 176 if ( ! $language_updates ) { 175 177 $language_updates = wp_get_translation_updates(); 178 } 176 179 177 180 if ( empty( $language_updates ) ) { … … 184 187 } 185 188 186 if ( 'upgrader_process_complete' == current_filter() ) 189 if ( 'upgrader_process_complete' == current_filter() ) { 187 190 $this->skin->feedback( 'starting_upgrade' ); 191 } 188 192 189 193 // Remove any existing upgrade filters from the plugin/theme upgraders #WP29425 & #WP29230 … … 206 210 $results = array(); 207 211 208 $this->update_count = count( $language_updates );212 $this->update_count = count( $language_updates ); 209 213 $this->update_current = 0; 210 214 … … 214 218 */ 215 219 $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 ) ) { 218 222 return new WP_Error( 'mkdir_failed_lang_dir', $this->strings['mkdir_failed'], $remote_destination ); 223 } 224 } 219 225 220 226 $language_updates_results = array(); … … 225 231 226 232 $destination = WP_LANG_DIR; 227 if ( 'plugin' == $language_update->type ) 233 if ( 'plugin' == $language_update->type ) { 228 234 $destination .= '/plugins'; 229 elseif ( 'theme' == $language_update->type )235 } elseif ( 'theme' == $language_update->type ) { 230 236 $destination .= '/themes'; 237 } 231 238 232 239 $this->update_current++; 233 240 234 241 $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, 238 245 '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( 242 249 'language_update_type' => $language_update->type, 243 'language_update' => $language_update,244 ) 250 'language_update' => $language_update, 251 ), 245 252 ); 246 253 … … 269 276 270 277 /** 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 ); 277 286 278 287 // Re-add upgrade hooks. … … 312 321 global $wp_filesystem; 313 322 314 if ( is_wp_error( $source ) ) 323 if ( is_wp_error( $source ) ) { 315 324 return $source; 325 } 316 326 317 327 // Check that the folder contains a valid language. … … 321 331 $po = $mo = false; 322 332 foreach ( (array) $files as $file => $filedata ) { 323 if ( '.po' == substr( $file, -3 ) ) 333 if ( '.po' == substr( $file, -3 ) ) { 324 334 $po = true; 325 elseif ( '.mo' == substr( $file, -3 ) )335 } elseif ( '.mo' == substr( $file, -3 ) ) { 326 336 $mo = true; 337 } 327 338 } 328 339 329 340 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'], 331 343 /* 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.' ), 333 346 '<code>.po</code>', 334 347 '<code>.mo</code>' … … 355 368 case 'theme': 356 369 $theme = wp_get_theme( $update->slug ); 357 if ( $theme->exists() ) 370 if ( $theme->exists() ) { 358 371 return $theme->Get( 'Name' ); 372 } 359 373 break; 360 374 case 'plugin': 361 375 $plugin_data = get_plugins( '/' . $update->slug ); 362 376 $plugin_data = reset( $plugin_data ); 363 if ( $plugin_data ) 377 if ( $plugin_data ) { 364 378 return $plugin_data['Name']; 379 } 365 380 break; 366 381 }
Note: See TracChangeset
for help on using the changeset viewer.