Changeset 48390 for trunk/src/wp-admin/includes/class-theme-upgrader.php
- Timestamp:
- 07/07/2020 05:47:37 PM (4 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-admin/includes/class-theme-upgrader.php
r47814 r48390 39 39 40 40 /** 41 * New theme info. 42 * 43 * @since 5.5.0 44 * @var array $new_theme_data 45 * 46 * @see check_package() 47 */ 48 public $new_theme_data = array(); 49 50 /** 41 51 * Initialize the upgrade strings. 42 52 * … … 66 76 $this->strings['unpack_package'] = __( 'Unpacking the package…' ); 67 77 $this->strings['installing_package'] = __( 'Installing the theme…' ); 78 $this->strings['remove_old'] = __( 'Removing the old version of the theme…' ); 79 $this->strings['remove_old_failed'] = __( 'Could not remove the old theme.' ); 68 80 $this->strings['no_files'] = __( 'The theme contains no files.' ); 69 81 $this->strings['process_failed'] = __( 'Theme installation failed.' ); … … 80 92 /* translators: %s: Theme name. */ 81 93 $this->strings['parent_theme_not_found'] = sprintf( __( '<strong>The parent theme could not be found.</strong> You will need to install the parent theme, %s, before you can use this child theme.' ), '<strong>%s</strong>' ); 94 /* translators: %s: Theme error. */ 95 $this->strings['current_theme_has_errors'] = __( 'The current theme has the following error: "%s".' ); 96 97 if ( 'update-theme' === $this->skin->overwrite ) { 98 $this->strings['installing_package'] = __( 'Updating the theme…' ); 99 $this->strings['process_failed'] = __( 'Theme update failed.' ); 100 $this->strings['process_success'] = __( 'Theme updated successfully.' ); 101 } 102 103 if ( 'downgrade-theme' === $this->skin->overwrite ) { 104 $this->strings['installing_package'] = __( 'Downgrading the theme…' ); 105 $this->strings['process_failed'] = __( 'Theme downgrade failed.' ); 106 $this->strings['process_success'] = __( 'Theme downgraded successfully.' ); 107 } 82 108 } 83 109 … … 201 227 */ 202 228 public function install( $package, $args = array() ) { 203 204 229 $defaults = array( 205 230 'clear_update_cache' => true, 231 'overwrite_package' => false, // Do not overwrite files. 206 232 ); 207 233 $parsed_args = wp_parse_args( $args, $defaults ); … … 221 247 'package' => $package, 222 248 'destination' => get_theme_root(), 223 'clear_destination' => false, // Do not overwrite files.249 'clear_destination' => $args['overwrite_package'], 224 250 'clear_working' => true, 225 251 'hook_extra' => array( … … 241 267 wp_clean_themes_cache( $parsed_args['clear_update_cache'] ); 242 268 269 if ( $parsed_args['overwrite_package'] ) { 270 /** 271 * Fires when the upgrader has successfully overwritten a currently installed 272 * plugin or theme with an uploaded zip package. 273 * 274 * @since 5.5.0 275 * 276 * @param string $package The package file. 277 * @param array $new_plugin_data The new theme data. 278 * @param string $package_type The package type (plugin or theme). 279 */ 280 do_action( 'upgrader_overwrote_package', $package, $this->new_theme_data, 'theme' ); 281 } 282 243 283 return true; 244 284 } … … 260 300 */ 261 301 public function upgrade( $theme, $args = array() ) { 262 263 302 $defaults = array( 264 303 'clear_update_cache' => true, … … 333 372 */ 334 373 public function bulk_upgrade( $themes, $args = array() ) { 335 336 374 $defaults = array( 337 375 'clear_update_cache' => true, … … 462 500 global $wp_filesystem; 463 501 502 $this->new_theme_data = array(); 503 464 504 if ( is_wp_error( $source ) ) { 465 505 return $source; … … 485 525 } 486 526 527 // All these headers are needed on Theme_Installer_Skin::do_overwrite(). 487 528 $info = get_file_data( 488 529 $working_directory . 'style.css', 489 530 array( 490 'Name' => 'Theme Name', 491 'Template' => 'Template', 531 'Name' => 'Theme Name', 532 'Version' => 'Version', 533 'Author' => 'Author', 534 'Template' => 'Template', 535 'RequiresWP' => 'Requires at least', 536 'RequiresPHP' => 'Requires PHP', 492 537 ) 493 538 ); … … 518 563 } 519 564 565 $this->new_theme_data = $info; 520 566 return $source; 521 567 } … … 641 687 */ 642 688 public function theme_info( $theme = null ) { 643 644 689 if ( empty( $theme ) ) { 645 690 if ( ! empty( $this->result['destination_name'] ) ) { … … 649 694 } 650 695 } 651 return wp_get_theme( $theme ); 696 697 $theme = wp_get_theme( $theme ); 698 $theme->cache_delete(); 699 700 return $theme; 652 701 } 653 702
Note: See TracChangeset
for help on using the changeset viewer.