mirror of
https://github.com/WordPress/WordPress.git
synced 2025-02-13 02:51:33 +01: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. Built from https://develop.svn.wordpress.org/trunk@50826 git-svn-id: http://core.svn.wordpress.org/trunk@50435 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
0082070074
commit
102d9569c2
@ -72,10 +72,29 @@ function delete_theme( $stylesheet, $redirect = '' ) {
|
|||||||
return new WP_Error( 'fs_no_themes_dir', __( 'Unable to locate WordPress theme directory.' ) );
|
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 );
|
$themes_dir = trailingslashit( $themes_dir );
|
||||||
$theme_dir = trailingslashit( $themes_dir . $stylesheet );
|
$theme_dir = trailingslashit( $themes_dir . $stylesheet );
|
||||||
$deleted = $wp_filesystem->delete( $theme_dir, true );
|
$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 ) {
|
if ( ! $deleted ) {
|
||||||
return new WP_Error(
|
return new WP_Error(
|
||||||
'could_not_remove_theme',
|
'could_not_remove_theme',
|
||||||
|
@ -13,7 +13,7 @@
|
|||||||
*
|
*
|
||||||
* @global string $wp_version
|
* @global string $wp_version
|
||||||
*/
|
*/
|
||||||
$wp_version = '5.8-alpha-50825';
|
$wp_version = '5.8-alpha-50826';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.
|
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.
|
||||||
|
Loading…
Reference in New Issue
Block a user