WordPress.org

Make WordPress Core

Changeset 23912


Ignore:
Timestamp:
04/04/2013 09:10:54 PM (7 years ago)
Author:
nacin
Message:

WP_Upgrader: Add upgrader_process_complete hooks and add a abort_if_destination_exists flag (default is true). props dd32. see #18200.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/wp-admin/includes/class-wp-upgrader.php

    r23749 r23912  
    167167        $defaults = array( 'source' => '', 'destination' => '', //Please always pass these
    168168                        'clear_destination' => false, 'clear_working' => false,
     169                        'abort_if_destination_exists' => true,
    169170                        'hook_extra' => array());
    170171
     
    225226            else if ( ! $removed )
    226227                return new WP_Error('remove_old_failed', $this->strings['remove_old_failed']);
    227         } elseif ( $wp_filesystem->exists($remote_destination) ) {
     228        } elseif ( $abort_if_destination_exists && $wp_filesystem->exists($remote_destination) ) {
    228229            //If we're not clearing the destination folder and something exists there already, Bail.
    229230            //But first check to see if there are actually any files in the folder.
     
    273274                            'destination' => '', //And this
    274275                            'clear_destination' => false,
     276                            'abort_if_destination_exists' => true, // Abort if the Destination directory exists, Pass clear_destination as false please
    275277                            'clear_working' => true,
    276278                            'is_multi' => false,
     
    319321                                            'destination' => $destination,
    320322                                            'clear_destination' => $clear_destination,
     323                                            'abort_if_destination_exists' => $abort_if_destination_exists,
    321324                                            'clear_working' => $clear_working,
    322325                                            'hook_extra' => $hook_extra
     
    413416        delete_site_transient('update_plugins');
    414417        wp_cache_delete( 'plugins', 'plugins' );
     418        do_action( 'upgrader_process_complete', $this, array( 'action' => 'install', 'type' => 'plugin' ), $package );
    415419
    416420        return true;
     
    458462        delete_site_transient('update_plugins');
    459463        wp_cache_delete( 'plugins', 'plugins' );
     464        do_action( 'upgrader_process_complete', $this, array( 'action' => 'update', 'type' => 'plugin' ), $plugin );
    460465    }
    461466
     
    540545        delete_site_transient('update_plugins');
    541546        wp_cache_delete( 'plugins', 'plugins' );
     547        do_action( 'upgrader_process_complete', $this, array( 'action' => 'update', 'type' => 'plugin', 'bulk' => true ), $plugins );
    542548
    543549        return $results;
     
    765771        // Force refresh of theme update information
    766772        wp_clean_themes_cache();
     773        do_action( 'upgrader_process_complete', $this, array( 'action' => 'install', 'type' => 'theme' ), $package );
    767774
    768775        return true;
     
    811818        // Force refresh of theme update information
    812819        wp_clean_themes_cache();
     820        do_action( 'upgrader_process_complete', $this, array( 'action' => 'update', 'type' => 'theme' ), $theme );
    813821
    814822        return true;
     
    898906        // Force refresh of theme update information
    899907        wp_clean_themes_cache();
     908        do_action( 'upgrader_process_complete', $this, array( 'action' => 'update', 'type' => 'theme', 'bulk' => true ), $themes );
    900909
    901910        return $results;
     
    10681077            return new WP_Error( 'copy_failed_space', $this->strings['copy_failed_space'] );
    10691078
    1070         return update_core($working_dir, $wp_dir);
     1079        $result = update_core( $working_dir, $wp_dir );
     1080        do_action( 'upgrader_process_complete', $this, array( 'action' => 'update', 'type' => 'core' ), $result );
     1081        return $result;
    10711082    }
    10721083
Note: See TracChangeset for help on using the changeset viewer.