Make WordPress Core


Ignore:
Timestamp:
05/07/2021 04:08:42 PM (3 years ago)
Author:
desrosj
Message:

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.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-admin/includes/theme.php

    r50407 r50826  
    7373    }
    7474
     75    /**
     76     * Fires immediately before a theme deletion attempt.
     77     *
     78     * @since 5.8
     79     *
     80     * @param string $stylesheet Stylesheet of the theme to delete.
     81     */
     82    do_action( 'delete_theme', $stylesheet );
     83
    7584    $themes_dir = trailingslashit( $themes_dir );
    7685    $theme_dir  = trailingslashit( $themes_dir . $stylesheet );
    7786    $deleted    = $wp_filesystem->delete( $theme_dir, true );
     87
     88    /**
     89     * Fires immediately after a theme deletion attempt.
     90     *
     91     * @since 5.8
     92     *
     93     * @param string $stylesheet Stylesheet of the theme to delete.
     94     * @param bool   $deleted    Whether the theme deletion was successful.
     95     */
     96    do_action( 'deleted_theme', $stylesheet, $deleted );
    7897
    7998    if ( ! $deleted ) {
Note: See TracChangeset for help on using the changeset viewer.