From 3964e804aafe22e128dae4ca81d734ec1b6ad6a0 Mon Sep 17 00:00:00 2001
From: Paul Biron <paul@sparrowhawkcomputing.com>
Date: Tue, 15 Oct 2019 15:20:58 -0600
Subject: [PATCH] Add delete_theme and deleted_theme actions.

---
 src/wp-admin/includes/theme.php | 19 +++++++++++++++++++
 1 file changed, 19 insertions(+)

diff --git a/src/wp-admin/includes/theme.php b/src/wp-admin/includes/theme.php
index 12035e1fc9..e70fe71139 100644
--- a/src/wp-admin/includes/theme.php
+++ b/src/wp-admin/includes/theme.php
@@ -71,10 +71,29 @@ function delete_theme( $stylesheet, $redirect = '' ) {
 		return new WP_Error( 'fs_no_themes_dir', __( 'Unable to locate WordPress theme directory.' ) );
 	}
 
+	/**
+	 * Fires immediately before a theme deletion attempt.
+	 *
+	 * @since 5.4
+	 *
+	 * @param string $stylesheet Stylesheet of the theme to delete.
+	 */
+	do_action( 'delete_theme', $stylesheet );
+
 	$themes_dir = trailingslashit( $themes_dir );
 	$theme_dir  = trailingslashit( $themes_dir . $stylesheet );
 	$deleted    = $wp_filesystem->delete( $theme_dir, true );
 
+	/**
+	 * Fires immediately after a theme deletion attempt.
+	 *
+	 * @since 5.4
+	 *
+	 * @param string $stylesheet Stylesheet of the theme to delete.
+	 * @param bool   $deleted     Whether the theme deletion was successful.
+	 */
+	do_action( 'deleted_theme', $stylesheet, $deleted );
+
 	if ( ! $deleted ) {
 		return new WP_Error(
 			'could_not_remove_theme',
-- 
2.19.0.windows.1

