Theme_Upgrader::delete_old_theme( bool $removed, string $local_destination, string $remote_destination, array $theme ): bool

Deletes the old theme during an upgrade.

Description

Hooked to the ‘upgrader_clear_destination’ filter by Theme_Upgrader::upgrade() and Theme_Upgrader::bulk_upgrade().

Parameters

$removedboolrequired
$local_destinationstringrequired
$remote_destinationstringrequired
$themearrayrequired

Return

bool

Source

public function delete_old_theme( $removed, $local_destination, $remote_destination, $theme ) {
	global $wp_filesystem;

	if ( is_wp_error( $removed ) ) {
		return $removed; // Pass errors through.
	}

	if ( ! isset( $theme['theme'] ) ) {
		return $removed;
	}

	$theme      = $theme['theme'];
	$themes_dir = trailingslashit( $wp_filesystem->wp_themes_dir( $theme ) );
	if ( $wp_filesystem->exists( $themes_dir . $theme ) ) {
		if ( ! $wp_filesystem->delete( $themes_dir . $theme, true ) ) {
			return false;
		}
	}

	return true;
}

Changelog

VersionDescription
2.8.0Introduced.

User Contributed Notes

You must log in before being able to contribute a note or feedback.