mirror of
git://develop.git.wordpress.org/
synced 2025-04-22 13:12:11 +02:00
Themes: Introduce the delete_theme
and deleted_theme
action hooks.
This change introduces the `delete_theme` and `deleted_theme` action hooks, which fire immediately before and after an attempt to delete a theme, respectively. Props scottconnerly, ptahdunbar, pbiron, vetyst, desrosj. Fixes #16401. git-svn-id: https://develop.svn.wordpress.org/trunk@50826 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
parent
35c1cdee74
commit
d6a37f9046
@ -72,10 +72,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.8
|
||||
*
|
||||
* @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.8
|
||||
*
|
||||
* @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',
|
||||
|
Loading…
x
Reference in New Issue
Block a user