rebase on oct-10-2023
This commit is contained in:
@@ -49,7 +49,7 @@ class Plugin_Upgrader extends WP_Upgrader {
|
||||
public $new_plugin_data = array();
|
||||
|
||||
/**
|
||||
* Initialize the upgrade strings.
|
||||
* Initializes the upgrade strings.
|
||||
*
|
||||
* @since 2.8.0
|
||||
*/
|
||||
@@ -57,7 +57,7 @@ class Plugin_Upgrader extends WP_Upgrader {
|
||||
$this->strings['up_to_date'] = __( 'The plugin is at the latest version.' );
|
||||
$this->strings['no_package'] = __( 'Update package not available.' );
|
||||
/* translators: %s: Package URL. */
|
||||
$this->strings['downloading_package'] = sprintf( __( 'Downloading update from %s…' ), '<span class="code">%s</span>' );
|
||||
$this->strings['downloading_package'] = sprintf( __( 'Downloading update from %s…' ), '<span class="code pre">%s</span>' );
|
||||
$this->strings['unpack_package'] = __( 'Unpacking the update…' );
|
||||
$this->strings['remove_old'] = __( 'Removing the old version of the plugin…' );
|
||||
$this->strings['remove_old_failed'] = __( 'Could not remove the old plugin.' );
|
||||
@@ -67,14 +67,14 @@ class Plugin_Upgrader extends WP_Upgrader {
|
||||
}
|
||||
|
||||
/**
|
||||
* Initialize the installation strings.
|
||||
* Initializes the installation strings.
|
||||
*
|
||||
* @since 2.8.0
|
||||
*/
|
||||
public function install_strings() {
|
||||
$this->strings['no_package'] = __( 'Installation package not available.' );
|
||||
/* translators: %s: Package URL. */
|
||||
$this->strings['downloading_package'] = sprintf( __( 'Downloading installation package from %s…' ), '<span class="code">%s</span>' );
|
||||
$this->strings['downloading_package'] = sprintf( __( 'Downloading installation package from %s…' ), '<span class="code pre">%s</span>' );
|
||||
$this->strings['unpack_package'] = __( 'Unpacking the package…' );
|
||||
$this->strings['installing_package'] = __( 'Installing the plugin…' );
|
||||
$this->strings['remove_old'] = __( 'Removing the current plugin…' );
|
||||
@@ -173,7 +173,7 @@ class Plugin_Upgrader extends WP_Upgrader {
|
||||
}
|
||||
|
||||
/**
|
||||
* Upgrade a plugin.
|
||||
* Upgrades a plugin.
|
||||
*
|
||||
* @since 2.8.0
|
||||
* @since 3.7.0 The `$args` parameter was added, making clearing the plugin update cache optional.
|
||||
@@ -212,8 +212,10 @@ class Plugin_Upgrader extends WP_Upgrader {
|
||||
add_filter( 'upgrader_pre_install', array( $this, 'active_before' ), 10, 2 );
|
||||
add_filter( 'upgrader_clear_destination', array( $this, 'delete_old_plugin' ), 10, 4 );
|
||||
add_filter( 'upgrader_post_install', array( $this, 'active_after' ), 10, 2 );
|
||||
// There's a Trac ticket to move up the directory for zips which are made a bit differently, useful for non-.org plugins.
|
||||
// 'source_selection' => array( $this, 'source_selection' ),
|
||||
/*
|
||||
* There's a Trac ticket to move up the directory for zips which are made a bit differently, useful for non-.org plugins.
|
||||
* 'source_selection' => array( $this, 'source_selection' ),
|
||||
*/
|
||||
if ( $parsed_args['clear_update_cache'] ) {
|
||||
// Clear cache so wp_update_plugins() knows about the new plugin.
|
||||
add_action( 'upgrader_process_complete', 'wp_clean_plugins_cache', 9, 0 );
|
||||
@@ -226,14 +228,19 @@ class Plugin_Upgrader extends WP_Upgrader {
|
||||
'clear_destination' => true,
|
||||
'clear_working' => true,
|
||||
'hook_extra' => array(
|
||||
'plugin' => $plugin,
|
||||
'type' => 'plugin',
|
||||
'action' => 'update',
|
||||
'plugin' => $plugin,
|
||||
'type' => 'plugin',
|
||||
'action' => 'update',
|
||||
'temp_backup' => array(
|
||||
'slug' => dirname( $plugin ),
|
||||
'src' => WP_PLUGIN_DIR,
|
||||
'dir' => 'plugins',
|
||||
),
|
||||
),
|
||||
)
|
||||
);
|
||||
|
||||
// Cleanup our hooks, in case something else does a upgrade on this connection.
|
||||
// Cleanup our hooks, in case something else does an upgrade on this connection.
|
||||
remove_action( 'upgrader_process_complete', 'wp_clean_plugins_cache', 9 );
|
||||
remove_filter( 'upgrader_pre_install', array( $this, 'deactivate_plugin_before_upgrade' ) );
|
||||
remove_filter( 'upgrader_pre_install', array( $this, 'active_before' ) );
|
||||
@@ -247,8 +254,10 @@ class Plugin_Upgrader extends WP_Upgrader {
|
||||
// Force refresh of plugin update information.
|
||||
wp_clean_plugins_cache( $parsed_args['clear_update_cache'] );
|
||||
|
||||
// Ensure any future auto-update failures trigger a failure email by removing
|
||||
// the last failure notification from the list when plugins update successfully.
|
||||
/*
|
||||
* Ensure any future auto-update failures trigger a failure email by removing
|
||||
* the last failure notification from the list when plugins update successfully.
|
||||
*/
|
||||
$past_failure_emails = get_option( 'auto_plugin_theme_update_emails', array() );
|
||||
|
||||
if ( isset( $past_failure_emails[ $plugin ] ) ) {
|
||||
@@ -260,7 +269,7 @@ class Plugin_Upgrader extends WP_Upgrader {
|
||||
}
|
||||
|
||||
/**
|
||||
* Bulk upgrade several plugins at once.
|
||||
* Upgrades several plugins at once.
|
||||
*
|
||||
* @since 2.8.0
|
||||
* @since 3.7.0 The `$args` parameter was added, making clearing the plugin update cache optional.
|
||||
@@ -342,7 +351,12 @@ class Plugin_Upgrader extends WP_Upgrader {
|
||||
'clear_working' => true,
|
||||
'is_multi' => true,
|
||||
'hook_extra' => array(
|
||||
'plugin' => $plugin,
|
||||
'plugin' => $plugin,
|
||||
'temp_backup' => array(
|
||||
'slug' => dirname( $plugin ),
|
||||
'src' => WP_PLUGIN_DIR,
|
||||
'dir' => 'plugins',
|
||||
),
|
||||
),
|
||||
)
|
||||
);
|
||||
@@ -376,11 +390,13 @@ class Plugin_Upgrader extends WP_Upgrader {
|
||||
|
||||
$this->skin->footer();
|
||||
|
||||
// Cleanup our hooks, in case something else does a upgrade on this connection.
|
||||
// Cleanup our hooks, in case something else does an upgrade on this connection.
|
||||
remove_filter( 'upgrader_clear_destination', array( $this, 'delete_old_plugin' ) );
|
||||
|
||||
// Ensure any future auto-update failures trigger a failure email by removing
|
||||
// the last failure notification from the list when plugins update successfully.
|
||||
/*
|
||||
* Ensure any future auto-update failures trigger a failure email by removing
|
||||
* the last failure notification from the list when plugins update successfully.
|
||||
*/
|
||||
$past_failure_emails = get_option( 'auto_plugin_theme_update_emails', array() );
|
||||
|
||||
foreach ( $results as $plugin => $result ) {
|
||||
@@ -469,7 +485,7 @@ class Plugin_Upgrader extends WP_Upgrader {
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve the path to the file that contains the plugin info.
|
||||
* Retrieves the path to the file that contains the plugin info.
|
||||
*
|
||||
* This isn't used internally in the class, but is called by the skins.
|
||||
*
|
||||
@@ -641,8 +657,10 @@ class Plugin_Upgrader extends WP_Upgrader {
|
||||
return $removed;
|
||||
}
|
||||
|
||||
// If plugin is in its own directory, recursively delete the directory.
|
||||
// Base check on if plugin includes directory separator AND that it's not the root plugin folder.
|
||||
/*
|
||||
* If plugin is in its own directory, recursively delete the directory.
|
||||
* Base check on if plugin includes directory separator AND that it's not the root plugin folder.
|
||||
*/
|
||||
if ( strpos( $plugin, '/' ) && $this_plugin_dir !== $plugins_dir ) {
|
||||
$deleted = $wp_filesystem->delete( $this_plugin_dir, true );
|
||||
} else {
|
||||
|
||||
Reference in New Issue
Block a user