Theme_Upgrader::delete_old_theme() WordPress Method

The delete_old_theme() method is used to delete an old theme from the Wordpress installation. This is useful when upgrading to a new theme, or when you want to remove an old theme that is no longer needed.

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

Delete the old theme during an upgrade.


Description

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


Top ↑

Parameters

$removed

(bool)(Required)

$local_destination

(string)(Required)

$remote_destination

(string)(Required)

$theme

(array)(Required)


Top ↑

Return

(bool)


Top ↑

Source

File: wp-admin/includes/class-theme-upgrader.php

	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;
	}


Top ↑

Changelog

Changelog
VersionDescription
2.8.0Introduced.

The content displayed on this page has been created in part by processing WordPress source code files which are made available under the GPLv2 (or a later version) license by theĀ Free Software Foundation. In addition to this, the content includes user-written examples and information. All material is subject to review and curation by the WPPaste.com community.