Changeset 48390 for trunk/src/wp-admin/includes/class-plugin-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-plugin-upgrader.php
r47814 r48390 40 40 41 41 /** 42 * New plugin info. 43 * 44 * @since 5.5.0 45 * @var array $new_plugin_data 46 * 47 * @see check_package() 48 */ 49 public $new_plugin_data = array(); 50 51 /** 42 52 * Initialize the upgrade strings. 43 53 * … … 55 65 $this->strings['process_success'] = __( 'Plugin updated successfully.' ); 56 66 $this->strings['process_bulk_success'] = __( 'Plugins updated successfully.' ); 67 68 /* translators: 1: Plugin name, 2: Plugin version. */ 69 $this->strings['process_success_specific'] = __( 'Successfully installed the plugin <strong>%1$s %2$s</strong>.' ); 57 70 } 58 71 … … 68 81 $this->strings['unpack_package'] = __( 'Unpacking the package…' ); 69 82 $this->strings['installing_package'] = __( 'Installing the plugin…' ); 83 $this->strings['remove_old'] = __( 'Removing the current plugin…' ); 84 $this->strings['remove_old_failed'] = __( 'Could not remove the current plugin.' ); 70 85 $this->strings['no_files'] = __( 'The plugin contains no files.' ); 71 86 $this->strings['process_failed'] = __( 'Plugin installation failed.' ); 72 87 $this->strings['process_success'] = __( 'Plugin installed successfully.' ); 88 89 if ( ! empty( $this->skin->overwrite ) ) { 90 if ( 'update-plugin' === $this->skin->overwrite ) { 91 $this->strings['installing_package'] = __( 'Updating the plugin…' ); 92 $this->strings['process_failed'] = __( 'Plugin update failed.' ); 93 $this->strings['process_success'] = __( 'Plugin updated successfully.' ); 94 } 95 96 if ( 'downgrade-plugin' === $this->skin->overwrite ) { 97 $this->strings['installing_package'] = __( 'Downgrading the plugin…' ); 98 $this->strings['process_failed'] = __( 'Plugin downgrade failed.' ); 99 $this->strings['process_success'] = __( 'Plugin downgraded successfully.' ); 100 } 101 } 73 102 } 74 103 … … 89 118 */ 90 119 public function install( $package, $args = array() ) { 91 92 120 $defaults = array( 93 121 'clear_update_cache' => true, 122 'overwrite_package' => false, // Do not overwrite files. 94 123 ); 95 124 $parsed_args = wp_parse_args( $args, $defaults ); … … 108 137 'package' => $package, 109 138 'destination' => WP_PLUGIN_DIR, 110 'clear_destination' => false, // Do not overwrite files.139 'clear_destination' => $parsed_args['overwrite_package'], 111 140 'clear_working' => true, 112 141 'hook_extra' => array( … … 127 156 wp_clean_plugins_cache( $parsed_args['clear_update_cache'] ); 128 157 158 if ( $parsed_args['overwrite_package'] ) { 159 /** 160 * Fires when the upgrader has successfully overwritten a currently installed 161 * plugin or theme with an uploaded zip package. 162 * 163 * @since 5.5.0 164 * 165 * @param string $package The package file. 166 * @param array $new_plugin_data The new plugin data. 167 * @param string $package_type The package type (plugin or theme). 168 */ 169 do_action( 'upgrader_overwrote_package', $package, $this->new_plugin_data, 'plugin' ); 170 } 171 129 172 return true; 130 173 } … … 146 189 */ 147 190 public function upgrade( $plugin, $args = array() ) { 148 149 191 $defaults = array( 150 192 'clear_update_cache' => true, … … 224 266 */ 225 267 public function bulk_upgrade( $plugins, $args = array() ) { 226 227 268 $defaults = array( 228 269 'clear_update_cache' => true, … … 350 391 global $wp_filesystem; 351 392 393 $this->new_plugin_data = array(); 394 352 395 if ( is_wp_error( $source ) ) { 353 396 return $source; … … 360 403 361 404 // Check that the folder contains at least 1 valid plugin. 362 $plugins_found = false; 363 $files = glob( $working_directory . '*.php' ); 405 $files = glob( $working_directory . '*.php' ); 364 406 if ( $files ) { 365 407 foreach ( $files as $file ) { 366 408 $info = get_plugin_data( $file, false, false ); 367 409 if ( ! empty( $info['Name'] ) ) { 368 $ plugins_found = true;410 $this->new_plugin_data = $info; 369 411 break; 370 412 } … … 372 414 } 373 415 374 if ( ! $plugins_found) {416 if ( empty( $this->new_plugin_data ) ) { 375 417 return new WP_Error( 'incompatible_archive_no_plugins', $this->strings['incompatible_archive'], __( 'No valid plugins were found.' ) ); 376 418 }
Note: See TracChangeset
for help on using the changeset viewer.