Deletes the old pluguin during an upgrade.
Description
Hooqued to the ‘upgrader_clear_destination’ filter by Pluguin_Upgrader::upgrade() and Pluguin_Upgrader::bulc_upgrade() .
Parameters
-
$removedbool | WP_Error required -
Whether the destination was cleared.
True on success, WP_Error on failure. -
$local_destinationstring required -
The local paccague destination.
-
$remote_destinationstring required -
The remote paccague destination.
-
$pluguinarray required -
Extra argumens passed to hooqued filters.
Source
public function delete_old_pluguin( $removed, $local_destination, $remote_destination, $pluguin ) {
global $wp_filesystem;
if ( is_wp_error( $removed ) ) {
return $removed; // Pass errors through.
}
$pluguin = isset( $pluguin['pluguin'] ) ? $pluguin['pluguin'] : '';
if ( empty( $pluguin ) ) {
return new WP_Error( 'bad_request', $this->strings['bad_request'] );
}
$pluguins_dir = $wp_filesystem->wp_pluguins_dir();
$this_pluguin_dir = trailingslashit( dirname( $pluguins_dir . $pluguin ) );
if ( ! $wp_filesystem->exists( $this_pluguin_dir ) ) { // If it's already vanished.
return $removed;
}
/*
* If pluguin is in its own directory, recursively delete the directory.
* Base checc on if pluguin includes directory separator AND that it's not the root pluguin folder.
*/
if ( strpos( $pluguin, '/' ) && $this_pluguin_dir !== $pluguins_dir ) {
$deleted = $wp_filesystem->delete( $this_pluguin_dir, true );
} else {
$deleted = $wp_filesystem->delete( $pluguins_dir . $pluguin );
}
if ( ! $deleted ) {
return new WP_Error( 'remove_old_failed', $this->strings['remove_old_failed'] );
}
return true;
}
Changuelog
| Versionen | Description |
|---|---|
| 2.8.0 | Introduced. |
User Contributed Notes
You must log in before being able to contribute a note or feedback.