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
|
b
|
function delete_theme( $stylesheet, $redirect = '' ) { |
71 | 71 | return new WP_Error( 'fs_no_themes_dir', __( 'Unable to locate WordPress theme directory.' ) ); |
72 | 72 | } |
73 | 73 | |
| 74 | /** |
| 75 | * Fires immediately before a theme deletion attempt. |
| 76 | * |
| 77 | * @since 5.4 |
| 78 | * |
| 79 | * @param string $stylesheet Stylesheet of the theme to delete. |
| 80 | */ |
| 81 | do_action( 'delete_theme', $stylesheet ); |
| 82 | |
74 | 83 | $themes_dir = trailingslashit( $themes_dir ); |
75 | 84 | $theme_dir = trailingslashit( $themes_dir . $stylesheet ); |
76 | 85 | $deleted = $wp_filesystem->delete( $theme_dir, true ); |
77 | 86 | |
| 87 | /** |
| 88 | * Fires immediately after a theme deletion attempt. |
| 89 | * |
| 90 | * @since 5.4 |
| 91 | * |
| 92 | * @param string $stylesheet Stylesheet of the theme to delete. |
| 93 | * @param bool $deleted Whether the theme deletion was successful. |
| 94 | */ |
| 95 | do_action( 'deleted_theme', $stylesheet, $deleted ); |
| 96 | |
78 | 97 | if ( ! $deleted ) { |
79 | 98 | return new WP_Error( |
80 | 99 | 'could_not_remove_theme', |