Ticket #38024: 38024.2.diff
| File 38024.2.diff, 9.9 KB (added by , 9 years ago) |
|---|
-
src/wp-admin/includes/class-plugin-upgrader.php
class Plugin_Upgrader extends WP_Upgrade 156 156 $current = get_site_transient( 'update_plugins' ); 157 157 if ( !isset( $current->response[ $plugin ] ) ) { 158 158 $this->skin->before(); 159 159 $this->skin->set_result(false); 160 160 $this->skin->error('up_to_date'); 161 161 $this->skin->after(); 162 162 return false; 163 163 } 164 164 165 165 // Get the URL to the zip file 166 166 $r = $current->response[ $plugin ]; 167 167 168 168 add_filter('upgrader_pre_install', array($this, 'deactivate_plugin_before_upgrade'), 10, 2); 169 169 add_filter('upgrader_clear_destination', array($this, 'delete_old_plugin'), 10, 4); 170 170 //'source_selection' => array($this, 'source_selection'), //there's a trac ticket to move up the directory for zip's which are made a bit differently, useful for non-.org plugins. 171 // Clear cache so wp_update_plugins() knows about the new plugin. 172 add_action( 'upgrader_process_complete', 'wp_clean_plugins_cache', 9, 0 ); 171 if ( $parsed_args['clear_update_cache'] ) { 172 // Clear cache so wp_update_plugins() knows about the new plugin. 173 add_action( 'upgrader_process_complete', 'wp_clean_plugins_cache', 9, 0 ); 174 } 173 175 174 176 $this->run( array( 175 177 'package' => $r->package, 176 178 'destination' => WP_PLUGIN_DIR, 177 179 'clear_destination' => true, 178 180 'clear_working' => true, 179 181 'hook_extra' => array( 180 182 'plugin' => $plugin, 181 183 'type' => 'plugin', 182 184 'action' => 'update', 183 185 ), 184 186 ) ); 185 187 186 188 // Cleanup our hooks, in case something else does a upgrade on this connection. 187 189 remove_action( 'upgrader_process_complete', 'wp_clean_plugins_cache', 9 ); … … class Plugin_Upgrader extends WP_Upgrade 215 217 */ 216 218 public function bulk_upgrade( $plugins, $args = array() ) { 217 219 218 220 $defaults = array( 219 221 'clear_update_cache' => true, 220 222 ); 221 223 $parsed_args = wp_parse_args( $args, $defaults ); 222 224 223 225 $this->init(); 224 226 $this->bulk = true; 225 227 $this->upgrade_strings(); 226 228 227 229 $current = get_site_transient( 'update_plugins' ); 228 230 229 231 add_filter('upgrader_clear_destination', array($this, 'delete_old_plugin'), 10, 4); 230 add_action( 'upgrader_process_complete', 'wp_clean_plugins_cache', 9, 0 );231 232 232 233 $this->skin->header(); 233 234 234 235 // Connect to the Filesystem first. 235 236 $res = $this->fs_connect( array(WP_CONTENT_DIR, WP_PLUGIN_DIR) ); 236 237 if ( ! $res ) { 237 238 $this->skin->footer(); 238 239 return false; 239 240 } 240 241 241 242 $this->skin->bulk_header(); 242 243 243 244 /* 244 245 * Only start maintenance mode if: 245 246 * - running Multisite and there are one or more plugins specified, OR … … class Plugin_Upgrader extends WP_Upgrade 282 283 'is_multi' => true, 283 284 'hook_extra' => array( 284 285 'plugin' => $plugin 285 286 ) 286 287 ) ); 287 288 288 289 $results[$plugin] = $this->result; 289 290 290 291 // Prevent credentials auth screen from displaying multiple times 291 292 if ( false === $result ) 292 293 break; 293 294 } //end foreach $plugins 294 295 295 296 $this->maintenance_mode(false); 296 297 298 // Force refresh of plugin update information. 299 wp_clean_plugins_cache( $parsed_args['clear_update_cache'] ); 300 297 301 /** This action is documented in wp-admin/includes/class-wp-upgrader.php */ 298 302 do_action( 'upgrader_process_complete', $this, array( 299 303 'action' => 'update', 300 304 'type' => 'plugin', 301 305 'bulk' => true, 302 306 'plugins' => $plugins, 303 307 ) ); 304 308 305 309 $this->skin->bulk_footer(); 306 310 307 311 $this->skin->footer(); 308 312 309 313 // Cleanup our hooks, in case something else does a upgrade on this connection. 310 remove_action( 'upgrader_process_complete', 'wp_clean_plugins_cache', 9 );311 314 remove_filter('upgrader_clear_destination', array($this, 'delete_old_plugin')); 312 315 313 // Force refresh of plugin update information.314 wp_clean_plugins_cache( $parsed_args['clear_update_cache'] );315 316 316 return $results; 317 317 } 318 318 319 319 /** 320 320 * Check a source package to be sure it contains a plugin. 321 321 * 322 322 * This function is added to the {@see 'upgrader_source_selection'} filter by 323 323 * Plugin_Upgrader::install(). 324 324 * 325 325 * @since 3.3.0 326 326 * @access public 327 327 * 328 328 * @global WP_Filesystem_Base $wp_filesystem Subclass 329 329 * 330 330 * @param string $source The path to the downloaded package source. -
src/wp-admin/includes/class-theme-upgrader.php
class Theme_Upgrader extends WP_Upgrader 189 189 * 190 190 * @return bool|WP_Error True if the install was successful, false or a WP_Error object otherwise. 191 191 */ 192 192 public function install( $package, $args = array() ) { 193 193 194 194 $defaults = array( 195 195 'clear_update_cache' => true, 196 196 ); 197 197 $parsed_args = wp_parse_args( $args, $defaults ); 198 198 199 199 $this->init(); 200 200 $this->install_strings(); 201 201 202 202 add_filter('upgrader_source_selection', array($this, 'check_package') ); 203 203 add_filter('upgrader_post_install', array($this, 'check_parent_theme_filter'), 10, 3); 204 // Clear cache so wp_update_themes() knows about the new theme. 205 add_action( 'upgrader_process_complete', 'wp_clean_themes_cache', 9, 0 ); 204 if ( $parsed_args['clear_update_cache'] ) { 205 // Clear cache so wp_update_themes() knows about the new theme. 206 add_action( 'upgrader_process_complete', 'wp_clean_themes_cache', 9, 0 ); 207 } 206 208 207 209 $this->run( array( 208 210 'package' => $package, 209 211 'destination' => get_theme_root(), 210 212 'clear_destination' => false, //Do not overwrite files. 211 213 'clear_working' => true, 212 214 'hook_extra' => array( 213 215 'type' => 'theme', 214 216 'action' => 'install', 215 217 ), 216 218 ) ); 217 219 218 220 remove_action( 'upgrader_process_complete', 'wp_clean_themes_cache', 9 ); 219 221 remove_filter('upgrader_source_selection', array($this, 'check_package') ); 220 222 remove_filter('upgrader_post_install', array($this, 'check_parent_theme_filter')); … … class Theme_Upgrader extends WP_Upgrader 257 259 // Is an update available? 258 260 $current = get_site_transient( 'update_themes' ); 259 261 if ( !isset( $current->response[ $theme ] ) ) { 260 262 $this->skin->before(); 261 263 $this->skin->set_result(false); 262 264 $this->skin->error( 'up_to_date' ); 263 265 $this->skin->after(); 264 266 return false; 265 267 } 266 268 267 269 $r = $current->response[ $theme ]; 268 270 269 271 add_filter('upgrader_pre_install', array($this, 'current_before'), 10, 2); 270 272 add_filter('upgrader_post_install', array($this, 'current_after'), 10, 2); 271 273 add_filter('upgrader_clear_destination', array($this, 'delete_old_theme'), 10, 4); 272 // Clear cache so wp_update_themes() knows about the new theme. 273 add_action( 'upgrader_process_complete', 'wp_clean_themes_cache', 9, 0 ); 274 if ( $parsed_args['clear_update_cache'] ) { 275 // Clear cache so wp_update_themes() knows about the new theme. 276 add_action( 'upgrader_process_complete', 'wp_clean_themes_cache', 9, 0 ); 277 } 274 278 275 279 $this->run( array( 276 280 'package' => $r['package'], 277 281 'destination' => get_theme_root( $theme ), 278 282 'clear_destination' => true, 279 283 'clear_working' => true, 280 284 'hook_extra' => array( 281 285 'theme' => $theme, 282 286 'type' => 'theme', 283 287 'action' => 'update', 284 288 ), 285 289 ) ); 286 290 287 291 remove_action( 'upgrader_process_complete', 'wp_clean_themes_cache', 9 ); 288 292 remove_filter('upgrader_pre_install', array($this, 'current_before')); … … class Theme_Upgrader extends WP_Upgrader 317 321 318 322 $defaults = array( 319 323 'clear_update_cache' => true, 320 324 ); 321 325 $parsed_args = wp_parse_args( $args, $defaults ); 322 326 323 327 $this->init(); 324 328 $this->bulk = true; 325 329 $this->upgrade_strings(); 326 330 327 331 $current = get_site_transient( 'update_themes' ); 328 332 329 333 add_filter('upgrader_pre_install', array($this, 'current_before'), 10, 2); 330 334 add_filter('upgrader_post_install', array($this, 'current_after'), 10, 2); 331 335 add_filter('upgrader_clear_destination', array($this, 'delete_old_theme'), 10, 4); 332 // Clear cache so wp_update_themes() knows about the new theme.333 add_action( 'upgrader_process_complete', 'wp_clean_themes_cache', 9, 0 );334 336 335 337 $this->skin->header(); 336 338 337 339 // Connect to the Filesystem first. 338 340 $res = $this->fs_connect( array(WP_CONTENT_DIR) ); 339 341 if ( ! $res ) { 340 342 $this->skin->footer(); 341 343 return false; 342 344 } 343 345 344 346 $this->skin->bulk_header(); 345 347 346 348 // Only start maintenance mode if: 347 349 // - running Multisite and there are one or more themes specified, OR 348 350 // - a theme with an update available is currently in use. … … class Theme_Upgrader extends WP_Upgrader 382 384 'is_multi' => true, 383 385 'hook_extra' => array( 384 386 'theme' => $theme 385 387 ), 386 388 ) ); 387 389 388 390 $results[$theme] = $this->result; 389 391 390 392 // Prevent credentials auth screen from displaying multiple times 391 393 if ( false === $result ) 392 394 break; 393 395 } //end foreach $plugins 394 396 395 397 $this->maintenance_mode(false); 396 398 399 // Refresh the Theme Update information 400 wp_clean_themes_cache( $parsed_args['clear_update_cache'] ); 401 397 402 /** This action is documented in wp-admin/includes/class-wp-upgrader.php */ 398 403 do_action( 'upgrader_process_complete', $this, array( 399 404 'action' => 'update', 400 405 'type' => 'theme', 401 406 'bulk' => true, 402 407 'themes' => $themes, 403 408 ) ); 404 409 405 410 $this->skin->bulk_footer(); 406 411 407 412 $this->skin->footer(); 408 413 409 414 // Cleanup our hooks, in case something else does a upgrade on this connection. 410 remove_action( 'upgrader_process_complete', 'wp_clean_themes_cache', 9 );411 415 remove_filter('upgrader_pre_install', array($this, 'current_before')); 412 416 remove_filter('upgrader_post_install', array($this, 'current_after')); 413 417 remove_filter('upgrader_clear_destination', array($this, 'delete_old_theme')); 414 418 415 // Refresh the Theme Update information416 wp_clean_themes_cache( $parsed_args['clear_update_cache'] );417 418 419 return $results; 419 420 } 420 421 421 422 /** 422 423 * Check that the package source contains a valid theme. 423 424 * 424 425 * Hooked to the {@see 'upgrader_source_selection'} filter by Theme_Upgrader::install(). 425 426 * It will return an error if the theme doesn't have style.css or index.php 426 427 * files. 427 428 * 428 429 * @since 3.3.0 429 430 * @access public 430 431 * 431 432 * @global WP_Filesystem_Base $wp_filesystem Subclass 432 433 *